-
Notifications
You must be signed in to change notification settings - Fork 92
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
ConstructingParser adds space between two predefined entities when no other text is present #107
Comments
The problem is that predefined entities are turned into Atom(c), where c is the character represented by the entity. For example, < turns into an Atom('<'). This happens in MarkupParser:
The &+ operator is defined in NodeBuffer as follows:
That sounds innocuous, but there is no good way to save such a thing. Calling XML.write or PrettyPrinter.formatNodes ultimately goes through Utilities.sequenceToXML and this branch:
When saving an element that contains only non-text atoms, they are separated by spaces.
to
in MarkupParser. |
Good analysis of the problem. Not sure if that change to The parser will need some work to be smart enough to preserve white space between entities. Obviously, white space shouldn't be preserved, when it's not desired, between other types of XML "nodes". However, that feature seems to be the source of the problem. An The |
Add unit tests to check for white space between XML entities. One test is the original example of two adjacent entities. An additional test case *has* white space between entities, and is just an affirmation of the existing behavior, and should be preserved. This bug pops up when the preserveWS option is either enabled or disabled for ConstructingParser. This doubles the number of unit tests to four. The fifth unit test, listed first, of adjacent text characters is rhetoric, and doesn't need to be included in the final merge. The previous sentence shouldn't be merged either. [error] Test XMLTest.preserveNoSpaceBetweenEntitiesOptionEnabled failed: [error] expected: <<div><[]<</div>> [error] but was: <<div><[ ]<</div>> [error] Test XMLTest.preserveNoSpaceBetweenEntitiesOptionDisabled failed: [error] expected: <<div><[]<</div>> [error] but was: <<div><[ ]<</div>>
I've taken a first pass at writing unit tests should anyone want to take this one on. |
Hi @ashawley, I have tried to fix this issue and also added the tests you provided. It would be great if you could take a look at it. Thanks! |
Note the space between the two
<
.The text was updated successfully, but these errors were encountered: