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: #566.
Would you like to work on this issue?
- Yes
- No