Welcome! » Log In » Create A New Profile

Mnify output

Posted by AJenbo 
Mnify output
May 22, 2013 06:43PM

It might be nice to minify the output. I have a rather simple implementation for minifying xHTML 1.0:

//Combine all white space
$html = preg_replace('/\s+/us', ' ', $html);
//Strip all white space surrounding block level elements
$html =  preg_replace(
//Strip all whitespace surounding line breaks
$html = preg_replace(&#039;/\s*<br \/>\s*/us&#039;, &#039;<br />&#039;, $html);

It's has a few backsides that i personally can live with

1: Does not respect literal (not written an an html entity) nbsp

2: Strips whitespace form "pre" content.

I think this should be rather fixable though

Edit: Line breaks, don't strip look-a-likes, less greedy regex

Re: Mnify output
May 22, 2013 06:47PM

Hmm, this wouldn't be too hard to add to the Generator.php class. I'm not going to implement it though.

Your Email:


HTML input is enabled. Make sure you escape all HTML and angled brackets with &lt; and &gt;.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

Place code here

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}