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

Void elements are given closing tags #162

Closed
mjbshaw opened this issue Feb 17, 2015 · 2 comments
Closed

Void elements are given closing tags #162

mjbshaw opened this issue Feb 17, 2015 · 2 comments
Labels
Milestone

Comments

@mjbshaw
Copy link

mjbshaw commented Feb 17, 2015

Given the following input file:

<html>
<head>
<title>Hello</title>
</head>
<body>
<p>
Hello world!
<p>
How are you?
<p> Good!
<img alt="baz" src="baz.png"/>
<img alt="foo" src="foo.png">
<br/>
<br>
foo:bar>asdf/foo:bar>
</body></html>

Running ./tidy5 -access 1 --vertical-space f -wrap 0 file.html produces:

<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>Hello world!</p>
<p>How are you?</p>
<p>Good! <img alt="baz" src="baz.png"></img> <img alt="foo" src="foo.png"><br></br>
<br>
foo:bar&gt;asdf/foo:bar&gt;</p>
</body>
</html>

Tidy shouldn't add closing tags for void elements (note the </img> and </br>), as those aren't legal in HTML5.

@balthisar balthisar added the Bug label Feb 23, 2015
@balthisar balthisar added this to the 5.0.0 milestone Feb 23, 2015
geoffmcl pushed a commit that referenced this issue Feb 24, 2015
The fix for #111 added an end tag for all StartEnd tags, when outputting
HTML5, but there should be some exceptions to this.

Added a new service, isVoidElement(node) for the void elements. Perhaps
this service could be further optimised.
geoffmcl pushed a commit that referenced this issue Feb 24, 2015
@geoffmcl
Copy link
Contributor

@mjbshaw, @ermshiperete, have pushed a fix for this.

This occurred during the fix for Issue #111 (#112 & #113), adding an end tag to ALL elements marked StartEnd when outputting HTML5. Have left that in place but excepted all the void elements listed here http://www.w3.org/TR/html-markup/syntax.html#syntax-elements...

Established a new service isVoidElement(node) which returns yes if in the list... maybe this service could be optimized more...

Would be pleased if you could both get a chance to retest, and if ok, close this issue.

Bumped version to 4.9.17 in the develop-500 branch for this fix.

@mjbshaw
Copy link
Author

mjbshaw commented Feb 24, 2015

Looks good. Output is now:

<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<p>Hello world!</p>
<p>How are you?</p>
<p>Good! <img alt="baz" src="baz.png"> <img alt="foo" src="foo.png"><br>
<br>
foo:bar&gt;asdf/foo:bar&gt;</p>
</body>
</html>

@mjbshaw mjbshaw closed this as completed Feb 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants