terser / html-minifier-terser

actively maintained fork of html-minifier - minify HTML, CSS and JS code using terser - supports ES6 code
https://terser.org/html-minifier-terser
MIT License
370 stars 29 forks source link

maxLineLength will split after <pre><code> element #118

Open bmarwell opened 2 years ago

bmarwell commented 2 years ago

Hi,

maxLineLength will split after the pre code elements:

<pre class="highlight highlightjs"><code class="hljs language-shell" data-lang="shell">dig +nostats google.de

resulting into:

<--long line etc etc etc --><pre class="highlight highlightjs"><code class="hljs language-shell" data-lang="shell">
dig +nostats google.de

This on the other hand will add an extra whitespace into the code. If combined with a line enumerator, the line #1 will be empty and the code starts at line two.

carlosjeurissen commented 10 months ago

@bmarwell ran into the same issue for one of my projects. What seems to work is setting the noNewlinesBeforeTagClose option to true.

Edit: This does not seem to work either.

My related issue: with maxLineLength and the following snippet: <title id="ref-something">Something, https://github.com/terser/html-minifier-terser/ can put a linebreak in between the opening tag and the text, resulting in whitespace before Something which leads to layout issues and other bugs.