Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly render void elements #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Kijewski
Copy link
Contributor

@Kijewski Kijewski commented Feb 4, 2024

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.

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 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.

[void element]: https://developer.mozilla.org/en-US/docs/Glossary/Void_element
@Kijewski

This comment was marked as resolved.

Make sure to lint and check everything in every configuration.

Don't fail if an updated (transitive) dependency requires a newer msrv
than the current msrv of markup.
@Kijewski
Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant