From 50128e5600166a515ccae7b17ef453c717d15615 Mon Sep 17 00:00:00 2001
From: Steve Clay
Date: Sat, 16 Aug 2008 21:24:33 +0000
Subject: [PATCH] Minify_HTML: shorter line lengths
---
lib/Minify/HTML.php | 8 +++---
web/test/_test_files/html/before.min.html | 32 +++++++++++++++++------
2 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/lib/Minify/HTML.php b/lib/Minify/HTML.php
index f6ba63d..5089833 100644
--- a/lib/Minify/HTML.php
+++ b/lib/Minify/HTML.php
@@ -77,9 +77,6 @@ class Minify_HTML {
.'|ol|opt(?:group|ion)|p|param|t(?:able|body|head|d|h||r|foot|itle)'
.'|ul)\\b[^>]*>)/i', '$1', $html);
- // line break within some tags to limit line lengths
- $html = preg_replace('/(<(?:div|span|a|p|input)) ([^>]+>)/i', "$1\n$2", $html);
-
// remove ws outside of all elements
$html = preg_replace_callback(
'/>([^<]+)'
@@ -90,7 +87,10 @@ class Minify_HTML {
self::_fillPlaceholders($html, self::$_pres, 'PRE');
self::_fillPlaceholders($html, self::$_tas, 'TEXTAREA');
self::_fillPlaceholders($html, self::$_scripts, 'SCRIPT');
- self::_fillPlaceholders($html, self::$_styles, 'STYLE');
+ self::_fillPlaceholders($html, self::$_styles, 'STYLE');
+
+ // use newlines before 1st attribute in open tags (to limit line lengths)
+ $html = preg_replace('/(<[a-z\\-]+)\\s+([^>]+>)/i', "$1\n$2", $html);
self::$_cssMinifier = self::$_jsMinifier = null;
return $html;
diff --git a/web/test/_test_files/html/before.min.html b/web/test/_test_files/html/before.min.html
index 4935cd8..d8862c2 100644
--- a/web/test/_test_files/html/before.min.html
+++ b/web/test/_test_files/html/before.min.html
@@ -1,9 +1,21 @@
-css Zen Garden: The Beauty in CSS Designcss Zen Garden
The Beauty of CSS Design
+id="pageHeader">css Zen Garden
The Beauty of CSS Design
White space is important here!
A demonstration of what can be accomplished visually through CSS-based design. Select any style sheet from the list to load it into this page.
A demonstration of what can be accomplished visually through CSS-based design. Select any style sheet from the list to load it into this page.
Download the sample html file and css file
\ No newline at end of file