-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce initialIndentationLevel option for the XMLBuilder #565
Comments
We're glad you find this project helpful. We'll try to address this issue ASAP. You can vist https://solothought.com to know recent features. Don't forget to star this repo. |
What if you set |
as far as i can tell from examining the code base that option will just overwrite indentation symbols. i.e. if we set indentBy to
making it unfittable for my usecase(trans-unit not indented, even tho nested indentation can be set) tbh at first i thought this option will help me solve my problem, but unfortunately it doesn't. also for now i have an mvp version with only
etc... |
First of all, what is the need of this? formatting doesn't cause parsing issue. And I believe, you don't have to show it. What you can do probably is format the whole document through prettify at last. |
I don't remember ever stating this.
not sure if i get what you are trying to say, but if you are saying that i can still use XMLBuilder without this feature, Then yes i can and i do. but it is far from optimal. i am rendering like this:
and then split on each like and prefixing with appropriate indentation to make it look like this
also i could generate javascript plain object dynamically and only then use XMLBuilder in the end. But that will make project hard dependent on your project and that's not the architecture solution i am up to. The bottom line this change would make my usage of the library convenient and optimal(runtime complexity wise). So let me know if you are up to merging this(introducing this functional into the library). If there is any other work that needs to be done to make it land into master, let me know. Also i do understand that my usecase sounds esoteric and i would understand if you wouldn't want to merge it. But since it is an easy change that doesn't break things and just allows to start indenting from different level instead of constant 0 literal i decided to try to land it. |
Let me check your implementation. However, |
Hello there! I’ve started using
XMLParser
/XMLBuilder
in my project markdown-translation and arrived at use case that is not really supported in theXMLBuilder
.First i render XML template/wrapper which makes skeleton base of the rendered document with
{format: true}
options.example of the generated template:
After rendering template i split it at the
<!-- split point -->
so that later i can dynamically render<trans-unit></trans-unit>
with content inside thebody
tag.The problem is that later when i render each
trans-unit
tagXMLBuilder
unaware of the fact thattrans-unit
tag is going to be injected into other document(template) at thelevel: 3
point of indentation.Result is going to be something like this:
Hence i propose the solution - Introduce new option
initialIndentationLevel
and initializebuilder
with it instead of the literal value0
.The option
initialIndentationLevel
is going to default to0
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?
The text was updated successfully, but these errors were encountered: