Introduce initialIndentationLevel option for the XMLBuilder
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- javascript
- Domain
- tooling
Research direction
Start at the XMLBuilder initialization described in the issue, where the indentation level is currently fixed at 0, and review the proposed PR NaturalIntelligence/fast-xml-parser#566. Done means supporting initialIndentationLevel while preserving the default output and producing correctly indented inserted trans-unit content.
Written by the indexing model from the issue text.
Description
Hello there! I’ve started using XMLParser/XMLBuilder in my project markdown-translation and arrived at use case that is not really supported in the XMLBuilder.
First i render XML template/wrapper which makes skeleton base of the rendered document with {format: true} options.
example of the generated template:
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="file.md" source-language="ru-RU" target-language="en-US" datatype="markdown">
<header>
<skeleton>
<external-file href="file.skl.md"></external-file>
</skeleton>
</header>
<body>
<!-- split point -->
</body>
</file>
</xliff>
After rendering template i split it at the <!-- split point --> so that later i can dynamically render <trans-unit></trans-unit> with content inside the body tag.
The problem is that later when i render each trans-unit tag XMLBuilder unaware of the fact that trans-unit tag is going to be injected into other document(template) at the level: 3 point of indentation.
Result is going to be something like this:
<?xml version="1.0" encoding="UTF-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
<file original="file.md" source-language="ru-RU" target-language="en-US" datatype="markdown">
<header>
<skeleton>
<external-file href="file.skl.md"></external-file>
</skeleton>
</header>
<body>
<trans-unit>
<source>str</source>
<target>target</target>
</trans-unit>
</body>
</file>
</xliff>
Hence i propose the solution - Introduce new option initialIndentationLevel and initialize builder with it instead of the literal value 0.
The option initialIndentationLevel is going to default to 0 so that default behaviour will be preserved.
Yet will allow my use case and generally make it more convenient building part of the XML document in the pretty format.
Please let me know what you think about it.
There is already PR for this feature: NaturalIntelligence/fast-xml-parser#566.
Would you like to work on this issue?
- Yes
- No
- Dominant language
- JavaScript
- Stars
- 22
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NaturalIntelligence/fast-xml-builder
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
`preserveOrder: true` with `format: true` formats mixed content wrongly and adds whitespace to content that ends with `>`Possibly taken @neumaennl claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
`XMLBuilder` object should be exported as a named export, not just the typePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NaturalIntelligence/fast-xml-builder#25 · 1 comment ·
-
sanitizeName not applied to names inside stopNodes (quote injection / tag break-out bypass)Possibly taken @hicay claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
NaturalIntelligence/fast-xml-builder#34 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 54/100
All issues in NaturalIntelligence/fast-xml-builder
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
Extended search drops any query term that contains a line breakPossibly taken @goranai claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
area:mcp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day