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

The detection of a content- and childless tag does not account for namespaces #2

Open
mr-stephan opened this issue Apr 23, 2021 · 0 comments

Comments

@mr-stephan
Copy link

When using the html formatter for xml I found that if the elements have a namespace prefix, the element after a self-closing-tag is in the same line as the self-closing-tag.

For example:

<ns1:Apple><ns1:Banana><ns1:CitrusFruit/></ns1:Banana></ns1:Apple>

is formatted to something like:

<ns1:Apple>
  <ns1:Banana>
    <ns1:CitrusFruit/></ns1:Banana>
  </ns1:Apple>

There is a simple fix:
Replace token_text.match(/\w+/) with token_text.match(/[\w:]+/) and
replace .match(/<\s*(\w+)/) with .match(/<\s*([\w:]+)/)

The example is contrived and the output may not be absolutely correct, but the point is, that the pattern does not account for a namespace prefix.


If you give me enough time, I will send a pull request

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

1 participant