Giter Club home page Giter Club logo

html-minifier's People

Contributors

zaininnari avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

html-minifier's Issues

Advanced optimisation does not respect required inline white spaces

Hi,

Your minifier is one of the most awesome I could find ! Thanks a lot for this job !
However, I had a little trouble using advanced optimisation option.

For that kind of html :

<p>Here is some <strong>bold</strong> text</p>

It will output :

<p>Here is some<strong>bold</strong>text</p>

I also made a test with more inline tags

<p>
    And here is some <strong>bold</strong> with <b>b</b> tag.
    Hey, what about <em>emphasis</em> and <i>italic</i> ?
    And also <u>underline</u> string ?!
</p>

Which gave me this :

<p>And here is some<strong>bold</strong> with <b>b</b> tag.
Hey, what about <em>emphasis</em> and <i>italic</i> ?
And also <u>underline</u>string ?!</p>

Considering that the standard optimisation level works fine, I fixed it using this code I'm not really proud of :

$minifier = new \zz\Html\HTMLMinify($html, array(
    'doctype'               => \zz\Html\HTMLMinify::DOCTYPE_HTML5,
    'optimizationLevel'     => \zz\Html\HTMLMinify::OPTIMIZATION_ADVANCED,
));
$minified = $minifier->process();
$lines = preg_split('/(\r\n|\n)/', $minified);

$minified = '';
$forceNewLine = false;
foreach($lines as $line) {

    // For now an then add new line characters after this one
    if(mb_strpos($line, '<pre>') !== false)
        $forceNewLine = true;

    // Since here, stop adding new line characters
    if(mb_strpos($line, '</pre>') !== false)
        $forceNewLine = false;

    $minified .= $line;

    if($forceNewLine)
        $minified .= "\r\n";

}

$html = $minified;

I would prefer using the package dedicated option, is there a way to fix it in your code ?

Whitespace after <strong>-tag is removed

Unfortunately, it seems that whitespaces around tags within text contents are removed.

HTML-Code (plain):

<p>
    <strong>Keywords</strong> are really important!
</p>

HTML-Code (minimized)

<p><strong>Keywords</strong>are really important!</p>

Result:

Keywordsare really important!

Used code:

$minimized = HTMLMinify::minify($html, [
    'doctype' => HTMLMinify::DOCTYPE_HTML5,
    'optimizationLevel' => HTMLMinify::OPTIMIZATION_ADVANCED
]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.