markup.rs icon indicating copy to clipboard operation
markup.rs copied to clipboard

Correctly render void elements

Open Kijewski opened this issue 1 year ago • 2 comments

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.

Kijewski avatar Feb 04 '24 02:02 Kijewski

Can you please restart the checks? It looks like the runner had a problem, not the code.

Kijewski avatar Feb 09 '24 04:02 Kijewski

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?

Kijewski avatar Feb 12 '24 18:02 Kijewski