Open jasonkhanlar opened 2 years ago
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/>');
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
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
"space before slash if the tag has attributes, otherwise no space"
Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="karen.jpg" alt="Karen" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents.
"