question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Drop space before slash in empty elements

See original GitHub issue

Currently, the plug-in enforces a space before the closing slash in empty elements when xmlSelfClosingTags is true, normalizing <foo></foo> and <foo/> to <foo />.

Some projects prefer the tighter <foo/> syntax, so if an option already exists to configure empty tag handling, perhaps a third value could be added to support this convention, like:

  • true (no space) – <foo/>
  • false<foo></foo>
  • space (current behavior) – <foo />

If so, this setting could also be applied to the XML declaration, to permit

<?xml version="1.0" encoding="UTF-8"?>

instead of rewriting to insert an extra space before the closing ?> as noted in #3:

<?xml version="1.0" encoding="UTF-8" ?>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kddnewtoncommented, Sep 26, 2021

Ehh alright. You convinced me. I’ll release that today.

1reaction
gtwohigcommented, Sep 24, 2021

@kddnewton too bad that it was dropped as lack of this feature is a blocker for us going to 1.0.

Use case: we are cleaning up/standardizing formatting on XML that is returned to us via the Salesforce metadata API. They (salesforce) do not include a space before the ?> on the xml version line nor do they on self closing elements. With xmlSelfClosingSpace: false the only files with a diff after the pull are ones that have a substantive change. This allows pretty-quick to run super fast because only a few files need to be prettified. With the 1.0 behavior we have thousands of files with whitespace only diffs that need to be cleaned up by prettier eliminating the significant speed improvements we get from pretty-quick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Space Before Closing Slash? - html - Stack Overflow
The answer is people wish to adhere to Appendix C of the XHTML1.0 specification. Which you only need to do if you are...
Read more >
Avoid space before slash of self closing Xml element - MSDN
I have requirement to not to generate space that appears before slash of self closing element. Following code reads a xml file and...
Read more >
Should I write "module/theme" or "module / theme"?
There are usually no spaces either before or after a slash. Exceptions are in representing the start of a new line when quoting...
Read more >
How to remove space that appears before slash of self closing ...
I have a requirement not to generate have requirement to not to generate space that appears before slash of self closing element.
Read more >
HTML Style Guide and Coding Conventions - W3Schools
Always Declare Document Type · Use Lowercase Element Names · Close All HTML Elements · Use Lowercase Attribute Names · Always Quote Attribute...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found