htacg / tidy-html5

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

insertion of spurious linebreak before P end tag if paragraph contains only an anchor #742

Open phloxic opened 6 years ago

phloxic commented 6 years ago
$ echo '<p>test <a href="/example/">expected</a></p>' | tidy -config /dev/null 2>/dev/null
<!DOCTYPE html>
<html>
<head>
  <title>
  </title>
</head>
<body>
  <p>test <a href="/example/">expected</a></p>
</body>
</html>
$ echo '<p><a href="/example/">unexpected</a></p>' | tidy -config /dev/null 2>/dev/null
<!DOCTYPE html>
<html>
<head>
  <title>
  </title>
</head>
<body>
  <p><a href="/example/">unexpected</a>
  </p>
</body>
</html>
~$ tidy -version
HTML Tidy for Apple macOS version 5.6.0
geoffmcl commented 5 years ago

@blacktrash sorry for the delay, but was hoping someone else would pick this up...

The only way I can duplicate your unexpected output, is to add --vertical-space yes to the tidy configuration... tested with 5.6.0 release, through to next 5.7.16...

There must be some default configuration in play, otherwise there should be a <meta name="generator" content="<tidy-version>"> in both the expected, and unexpected outputs you have shown...

I do agree there is a strangeness about why that vertical-space: yes option only effects when the paragraph content is solely a anchor, a link... and not if mixed with other text content...

Just an extra note about the vertical-space option... original tidy, sometimes referred to as classic mode in the code, had lots, and lots of vertical space... too much for many... later developers sort to reduce these, hence the current default of vertical-space: no... and where vertical-space: auto became almost no vertical space at all - a sort of single line compressed html stream...

Anyway, appreciate patches, PR to make this consistent in each type of paragraph case... thanks...

phloxic commented 5 years ago

@geoffmcl - thanks for getting back. I do have vertical-space: yes set, but I would have expected -config /dev/null to override any tidyrc, according to the fine manual?

ler762 commented 5 years ago

@blacktrash if the fine manual says -config /dev/null overrides any tidyrc then it's wrong; see PR #754

phloxic commented 5 years ago

@ler762 - thanks. Indeed with -config /dev/null I believed to have found an obvious way to report a potential bug/glitch which happens also in the default config scenario. I believed wrong ;-) Other than that I think that vertical-space should not influence this particular scenario.