Skip to content

Tidy mangles whitespace in pre and code tags #1094

Open
@matheusmoreira

Description

@matheusmoreira

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions