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

Retain closing br tag as though it were a normal br tag #185

Closed
IMSoP opened this issue Jun 22, 2020 · 2 comments · Fixed by #186
Closed

Retain closing br tag as though it were a normal br tag #185

IMSoP opened this issue Jun 22, 2020 · 2 comments · Fixed by #186

Comments

@IMSoP
Copy link
Contributor

IMSoP commented Jun 22, 2020

The WHATWG spec includes a special rule for handling </br>, in the section on parsing when "in body":

An end tag whose tag name is "br"
Parse error. Drop the attributes from the token, and act as described in the next entry; i.e. act as if this was a "br" start tag token with no attributes, rather than the end tag token that it actually is.

The result is that invalid HTML like Hello <br>World</br>! will be rendered by browsers as though it had two linebreaks, Hello <br>World<br>!. This library currently (quite reasonably!) removes the erroneous end tag instead, giving Hello <br>World!

I'm using this library for processing some messy HTML, and it would be useful to have this rule match the spec / browser behaviour.

@goetas
Copy link
Member

goetas commented Jun 24, 2020

if that is the browsers behavior, I think that we should do the same.

Are you willing to submit a patch for this?

@IMSoP
Copy link
Contributor Author

IMSoP commented Jun 24, 2020

I'll give it a go; by the looks of it, it will just need a special case at the top of DOMTreeBuilder::endTag

IMSoP added a commit to IMSoP/html5-php that referenced this issue Jun 24, 2020
Normally, an end tag for a void element would simply be discarded,
but the spec includes a special rule as follows:

> An end tag whose tag name is "br"
> Parse error. Drop the attributes from the token, and act as
> described in the next entry; i.e. act as if this was a "br"
> start tag token with no attributes, rather than the end tag
> token that it actually is.
@goetas goetas self-assigned this Jun 24, 2020
goetas added a commit that referenced this issue Jun 24, 2020
Add special case for end tag </br>. Fixes #185
lyrixx pushed a commit to lyrixx/html5-php that referenced this issue Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants