Swaagie / minimize

Minimize HTML
MIT License
162 stars 18 forks source link

Tag <code> #12

Closed JerryCauser closed 9 years ago

JerryCauser commented 10 years ago

Tag "code" shouldn't be minimyzed, bcs it retain chars like "\s","\n".

Swaagie commented 10 years ago

From what I can tell from tests this is actually the case. code element content will be left intact. If you can show me something where this is not the case, I'm happy to fix/patch against it.

For the current tests see: https://github.com/Moveo/minimize/blob/master/test/minimize-test.js#L133-L138 or https://github.com/Moveo/minimize/blob/master/test/helpers-test.js#L408-L414

JerryCauser commented 10 years ago

I sent this page's HTML [ https://www.npmjs.org/package/minimize ] in node.js via post request, minimized that, took response and parse it in page. After that everything was ok except "code".

Swaagie commented 10 years ago

Do note that that npmjs.org runs a client side library (prism.js) over the page that will update the content of the code element. It will most likely look different without it. That said, i'll try to reproduce it.

Swaagie commented 10 years ago

Couldn't reproduce this with a really minimal test code, e.g.

require('request').get('https://www.npmjs.org/package/minimize', function (err, resp, body) {
  (new (require('./lib/minimize'))).parse(body, function done(err, result) {
    require('fs').writeFileSync(__dirname + '/test.html', result, 'utf-8');
  });
});

test.html seems to have the proper output. In the browser it does not render exactly like the npm site, but that is due to relative paths to css/js assets

Swaagie commented 10 years ago

Note: the code above is ran from within the minimize project, after a npm install request

JerryCauser commented 10 years ago

Oh, You're trying to take the html using "request" on the side Nodejs. I take full page on the frontend side and sends it to the server (I'm writing a browser-extension).

chpio commented 10 years ago

same here

working code:

<pre><code class="lang-bash">git clone https://github.com/cjdelisle/cjdns.git cjdns
<span class="hljs-built_in">cd</span> cjdns
./<span class="hljs-keyword">do</span>
</code></pre>

after minification:

<pre><code class=lang-bash>git clone https://github.com/cjdelisle/cjdns.git cjdns <span class=hljs-built_in>cd</span> cjdns
./<span class=hljs-keyword>do</span></code></pre>