htacg / tidy-html5

The granddaddy of HTML tools, with support for modern standards
http://www.html-tidy.org
2.72k stars 419 forks source link

tidy-mark:no leaves blank line on pages with <script> in head #801

Open da2x opened 5 years ago

da2x commented 5 years ago

Steps to reproduce:

echo "<head><script>();</script></head>" | tidy -q --tidy-mark 0

Test results:

<!DOCTYPE html>
<html>
<head>

<script>
();
</script>
<title></title>
</head>
<body>
</body>
</html>

The problem doesn’t occur when the script is in body instead of in head:

echo "<body><script>();</script></body>" | tidy -q --tidy-mark 0

Test results:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
();
</script>
</body>
</html>

Also, doesn’t happen with a meta element in head instead of script.

Version: HTML Tidy for Linux version 5.6.0

Possibly related issues: #760

geoffmcl commented 5 years ago

@da2x thank you for the issue... and samples to easily reproduce, with v.5.6.0, even with tidy next... v.5.7.22... so is still there...

Yes, it is related to #760, but only where we maybe should have seen this extra newline in the output... but seem to have missed it...

Putting a script block <script>();</script> in the head, with a config --tidy-mark 0, adds an additional newline in the output... easily repeatable...

I am sure this can be corrected in the pretty print module... and will investigate... as time permits...

Meantime, look forward to feedback, patches, PR, etc... thanks...