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

Adjustment to spaceBeforeSlash to add a spaceBeforeSlash only if the tag has attributes? #132

Open
jasonkhanlar opened this issue Apr 8, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jasonkhanlar
Copy link

jasonkhanlar commented Apr 8, 2022

Is your feature request related to a problem? Please describe.
Adjustment to spaceBeforeSlash to add a spaceBeforeSlash only if the tag has attributes

Describe the solution you'd like

<namespace key="0" case="first-letter" /> // space before slash here (okay)
<text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" xml:space="preserve" /> // space before slash here (okay)
<minor/> // do not add a space before slash here (not possible yet)

Describe alternatives you've considered
I can write my own post processing code to handle this, but I thought I'd mention it as a feature suggestion also.

Additional context

@jasonkhanlar jasonkhanlar added the enhancement New feature or request label Apr 8, 2022
@jasonkhanlar
Copy link
Author

jasonkhanlar commented Apr 8, 2022

Note that rather than this ""feature"" idea being built in to the library, I whipped up this code to match what appears to be hard-coded inconsistency in MediaWiki Special:Export XML dumps (and as far as this point in time, I haven't found any further inconsistency than these two instances: "minor/sha1" tags):

xmlbuilder2.convert(
  { keepEntityCharRefs: true },
  xmlobj,
  { format: 'xml', prettyPrint: true, spaceBeforeSlash: true })
.replace(/<(minor|sha1) \/>/g, '<$1/>');

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

No branches or pull requests

2 participants