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

Tidy mangles whitespace in pre and code tags #1094

Open
matheusmoreira opened this issue Aug 13, 2023 · 2 comments
Open

Tidy mangles whitespace in pre and code tags #1094

matheusmoreira opened this issue Aug 13, 2023 · 2 comments

Comments

@matheusmoreira
Copy link

It appears tidy does not preserve spaces in in <pre> and <code> tags. It renders the entire tag contents as a single line, destroying code formatting.

$ HTML_TIDY=/dev/null tidy -q <<EXAMPLE
<pre>
  <code>
if (true) {
    return false;
}
  </code>
</pre>
EXAMPLE

<!DOCTYPE html>
<html>
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for Linux version 5.9.14">
<title></title>
</head>
<body>
<pre>
  <code> if (true) { return false; } </code>
</pre>
</body>
</html>

I scoured the manuals for an option that would fix this but found none. The closest would be --literal-attributes but using it did not work, as expected.

@step-
Copy link

step- commented Aug 19, 2023

It looks like a regression from 5.8.0

$ HTML_TIDY=/dev/null tidy -q <<EXAMPLE
<pre>
  <code>
if (true) {
    return false;
}
  </code>
</pre>
EXAMPLE
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 1 column 1 - Warning: inserting implicit <body>
line 1 column 1 - Warning: inserting missing 'title' element
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for Linux version 5.8.0">
<title></title>
</head>
<body>
<pre>
  <code>
if (true) {
    return false;
}
  </code>
</pre>
</body>
</html>

@Seirdy
Copy link

Seirdy commented Nov 15, 2023

I've identified 91f29ea as the source of this regression.

Seirdy added a commit to Seirdy/seirdy.one that referenced this issue Nov 15, 2023
See htacg/tidy-html5#1094. The most recent
commit without that regression can't handle `dl` elements with `div`
children.
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

No branches or pull requests

3 participants