Closed evanwarner closed 7 years ago
I understand that closing void elements is annoying. But IMHO, all void elements should be self-closed for clarity.
I added a new configuration option closeTag.ignoreTags
to ignore certain tags, possibilities are:
null
(ignore nothing)'html'
(ignore HTML void elements){ br: true, img: true }
(custom set of tags)By default, it ignore nothing. You may want to set it to html
so the engine will ignore HTML set of void elements.
The feature is out now on 1.1.0.
Enjoy!
Cool, thanks. If it were me I'd make 'html'
the default ignore (since I'd wager that an overwhelming majority of users will be writing HTML), but it works well now.
FYI, from the HTML 5.2 spec:
Void elements only have a start tag; end tags must not be specified for void elements.
That's cool it now fit your scenario.
In HTML spec:
Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single "/" (U+002F) character. This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.
So void element can be a self-closing start tag without end tag, making them XML-friendly. 😉
Right, but the existence of the self-closing /
on the void element is independent of the fact that there should not be an actual separate closing tag, which is what this plugin creates unless I set "closeTag.ignoreTags" = "html"
.
And now I am thinking to have an "auto" option. When the document is in HTML mode, it should automatically applies the HTML void set.
Will open a new issue on that. (Updated: issue #10)
Btw, thanks for your insight on HTML void tags.
With 1.0.0, your fix for #8 works better now, but if a void element is the first thing hit during the walkback, it still closes that instead of skipping it. If I have
<main><article><section><div><span><img>(cursor here)
then it closes the<img>
first before the others. But if I have<main><article><section><div><span><img></span>(cursor here)
then it correctly starts with the</div>
.