Skip to content

tidy removes line breaks inside a pre element containing another element #1006

Open
@David-Apps

Description

@David-Apps

Tidy removes the line breaks from the contents of a pre element when that element contains another element such as the code element. I expected tidy to preserve the line breaks inside the pre element (except perhaps a line break that immediately follows the

 tag).

I used HTML Tidy for Linux/x86 version 5.9.17.

Input:

<!DOCTYPE html>
<html lang="en">
<head>
<title>code inside pre</title>
<meta charset="UTF-8">
</head>
<body>
<h1>code inside pre</h1>
<p>This example uses an example from the <a href="https://html.spec.whatwg.org/#the-pre-element">HTML specification</a>.</p>
<pre><code>function Panel(element, canClose, closeHandler) {
  this.element = element;
  this.canClose = canClose;
  this.closeHandler = function () { if (closeHandler) closeHandler() };
}</code></pre>
</body>
</html>

Output:

Info: Document content looks like HTML5
No warnings or errors were found.

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 for Linux/x86 version 5.9.17">
<title>code inside pre</title>
<meta charset="UTF-8">
</head>
<body>
<h1>code inside pre</h1>
<p>This example uses an example from the <a href=
"https://html.spec.whatwg.org/#the-pre-element">HTML
specification</a>.</p>
<pre><code>function Panel(element, canClose, closeHandler) { this.element = element; this.canClose = canClose; this.closeHandler = function () { if (closeHandler) closeHandler() }; }</code></pre>
</body>
</html>

About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
Latest HTML specification: https://html.spec.whatwg.org/multipage/
Validate your HTML documents: https://validator.w3.org/nu/
Lobby your company to join the W3C: https://www.w3.org/Consortium


Would you like to see Tidy in proper, British English? Please consider 
helping us to localise HTML Tidy. For details please see 
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md

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