markup.rs
markup.rs copied to clipboard
Correctly render void elements
A void element is an HTML element that cannot have any children. In XML you'd use such an element like <br />.
HTML5 is very lenient, in that you don't have to write the trailing slash. A correctly implemented HTML parser knows which elements are void elements, and it closes the element automagically for you. The parser even "corrects" an input like a<br></br>b to a<br /><br />b for you, which might not be desirable.
If you want to render SVG, XHTML, or other more strict XML applications, you have to close void elements correctly: <br />, NOT <br> or <br></br>.
This PR adds the missing slash to generated void elements, so markup can be used to render e.g. SVG files.
Can you please restart the checks? It looks like the runner had a problem, not the code.
So, 3 out of 4 commits are now unrelated to the title of the PR. Should I move them into a new PR, or do you not mind?