Skip to content
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

Pretty print not adding proper tabs #201

Open
theshoeshiner opened this issue Jul 16, 2023 · 2 comments
Open

Pretty print not adding proper tabs #201

theshoeshiner opened this issue Jul 16, 2023 · 2 comments

Comments

@theshoeshiner
Copy link

theshoeshiner commented Jul 16, 2023

Im using XMLTools 3.1.1.13

When I use the following line of XML:

<table><tr><th><span><span>t</span></span></th></tr></table>

And do pretty print, I get:

<table>
	<tr>
		<th>
			<span>
				<span>t</span>
</span>
		</th>
	</tr>
</table>
@rdipardo
Copy link

It looks like the above text was formatted by QuickXML. Browsing the code (which I can't debug because of issues with the Nuget packages), I see that ::writeEOL and ::writeIndentation are guarded by a condition that is false when text is encountered right before a closing tag:

else if (!(lastAppliedTokenType & (XmlTokenType::Text | XmlTokenType::CDATA | XmlTokenType::TagOpeningEnd | XmlTokenType::Undefined))) {

This means QuickXML will not insert a newline between text and a closing tag. In the sample text above, text is adjacent to a closing tag inside the innermost span:

       closing tag
       ...........
       v
<span>t</span>
      ^...
      text

Using one of the other formatters, the result is the same or even worse:

xmltools-formatters-compared

All the above were formatted with the same options:

Auto-close tags             True
Ensure conformity           False
Apply xml:space="preserve"  False

Go to Plugins > XMLTools > Options to find them:

xmltools-format-options

@theshoeshiner
Copy link
Author

theshoeshiner commented Jul 20, 2023

@rdipardo Did you mean to say "SimpleXML"? Your screenshots match what I'm seeing. QuickXML actually produces correct indentation, SimpleXML produces the incorrect indentation that I initially encountered, and StringXML produces even worse indentation.

Im not sure why my installation was defaulting to SimpleXML, since on other machines a fresh install defaulted to QuickXML, but switching to QuickXML is a work-around for this specific issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants