UNPKG

htmlclean

Version:

Simple and safety HTML/SVG cleaner to minify without changing its structure.

86 lines (62 loc) 2.05 kB
<html> <!-- The whitespaces, tabs and line-breaks before html tag will be removed. And this tag too. --> <body> <!--[if lt IE 7]>This line will be kept.<![endif]--> <p>The more than two whitespaces, tabs and line-breaks will be suppressed to one space.</p> <p> <em> <i> The </i> <font> <i> clean </i> HTML </font> </em> is here. </p> <p>The <strong> clean <span> <em> HTML is here. </em> </span> </strong> </p> < p class = "clean" >The vain whitespaces< br / > in tags.< / p > <!-- Commented out HTML <div>foo<span>bar</span></div> <p>foo bar</p> --> <script> var foo = 'The text in script element' + ' will be kept.'; </script> <script type="text/x-handlebars-template"> <!-- These are unprotected by option --> <div> <div>{{firstName}}</div> <div>{{lastName}}</div> </div> </script> <div title="The whitespaces before 'title' will be suppressed to one space. This text will be kept.">The tabs and</div> <div>line-breaks between HTML tags will be removed.</div> <div><span>'</span> <span>'</span> is one space(this will be kept).</div> <div><!--#echo var="LAST_MODIFIED" -->Apache SSI tag will be kept.</div> <?php $foo = 'The text in PHP code'; ?> <div><!--[htmlclean-protect]-->Here, text will be kept.<!--[/htmlclean-protect]--></div> <!-- These are protected by option --> <div><!--%fooTemplate-head%--></div> <div><!--%fooTemplate-content%--></div> <div title="This egg is protected.">These Eggs are unprotected.</div> <svg version="1.1"> <rect x="3" y="3" width="42" height="18" rx="5" ry="5" /> <path d="M 13,9 L 15,8" /> <text>This is text in SVG.</text> <text>This is text in <tspan font-size="1.5em"> SVG<tspan font-size="0.9em">. </tspan> </tspan> </text> </svg> </body> <!-- The whitespaces, tabs and line-breaks after html close-tag will be removed. And this tag too. --> </html>