1
0
mirror of https://github.com/mrclay/minify.git synced 2025-01-29 19:27:45 +01:00

Minify_HTML no longer affects TEXTAREAs

This commit is contained in:
Steve Clay 2008-07-31 15:16:42 +00:00
parent 6ce0e380f0
commit 7e1f77f5d0
3 changed files with 27 additions and 1 deletions

View File

@ -56,6 +56,12 @@ class Minify_HTML {
,array('Minify_HTML', '_removePreCB')
, $html);
// replace TEXTAREAs with token text
self::$_tas = array();
$html = preg_replace_callback('/\\s*(<textarea\\b[^>]*?>[\\s\\S]*?<\\/textarea>)\\s*/i'
,array('Minify_HTML', '_removeTaCB')
, $html);
// trim each line.
// @todo take into account attribute values that span multiple lines.
$html = preg_replace('/^\\s+|\\s+$/m', '', $html);
@ -80,6 +86,14 @@ class Minify_HTML {
$i--;
}
// replace TEXTAREAs
$i = count(self::$_tas);
while ($i > 0) {
$rep = array_pop(self::$_tas);
$html = str_replace(self::$_replacementHash . 'TEXTAREA' . $i, $rep, $html);
$i--;
}
// replace SCRIPTs
$i = count(self::$_scripts);
while ($i > 0) {
@ -103,6 +117,7 @@ class Minify_HTML {
protected static $_isXhtml = false;
protected static $_replacementHash = null;
protected static $_pres = array();
protected static $_tas = array(); // textareas
protected static $_scripts = array();
protected static $_styles = array();
protected static $_cssMinifier = null;
@ -113,6 +128,12 @@ class Minify_HTML {
self::$_pres[] = $m[1];
return self::$_replacementHash . 'PRE' . count(self::$_pres);
}
protected static function _removeTaCB($m)
{
self::$_tas[] = $m[1];
return self::$_replacementHash . 'TEXTAREA' . count(self::$_tas);
}
protected static function _removeStyleCB($m)
{

View File

@ -87,6 +87,9 @@ Design</span></h2>
<p class="p1"><span>A demonstration of what can be accomplished visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p>
<p class="p2"><span>Download the sample <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p>
</div>
<textarea name="comment" id="comment" rows="6" class="maxwidth" cols="80">66666
1234567890</textarea>
</div>
</body>
</html>

View File

@ -12,4 +12,6 @@ type="application/rss+xml"
title="RSS"
href="http://www.csszengarden.com/zengarden.xml" /></head><body id="css-zen-garden"><div id="container"><div id="pageHeader"><h1><span>css Zen Garden</span></h1><h2><span>The Beauty of <acronym title="Cascading Style Sheets">CSS</acronym> Design</span></h2></div><pre>
White space is important here!
</pre><div id="quickSummary"><p class="p1"><span>A demonstration of what can be accomplished visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p><p class="p2"><span>Download the sample <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p></div></div></body></html>
</pre><div id="quickSummary"><p class="p1"><span>A demonstration of what can be accomplished visually through <acronym title="Cascading Style Sheets">CSS</acronym>-based design. Select any style sheet from the list to load it into this page.</span></p><p class="p2"><span>Download the sample <a href="/zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="/zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a></span></p></div><textarea name="comment" id="comment" rows="6" class="maxwidth" cols="80">66666
1234567890</textarea></div></body></html>