aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php
diff options
context:
space:
mode:
authorThomas Willingham <beardyunixer@beardyunixer.com>2014-12-11 20:15:27 +0000
committerThomas Willingham <beardyunixer@beardyunixer.com>2014-12-11 20:15:27 +0000
commit967ab871b836f618107fe144978bd1453c3c6634 (patch)
tree1bcb1b4bb1b25c904a2bc06f5c6d526d29909eaa /library/Smarty/libs/plugins/outputfilter.trimwhitespace.php
parent960c35bad3a0dbaa7a1f2191aef60ad014d926ca (diff)
downloadvolse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.gz
volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.bz2
volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.zip
Update Smarty
Diffstat (limited to 'library/Smarty/libs/plugins/outputfilter.trimwhitespace.php')
-rw-r--r--library/Smarty/libs/plugins/outputfilter.trimwhitespace.php34
1 files changed, 15 insertions, 19 deletions
diff --git a/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php b/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php
index 87cf8c781..62ab4e776 100644
--- a/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php
+++ b/library/Smarty/libs/plugins/outputfilter.trimwhitespace.php
@@ -2,22 +2,22 @@
/**
* Smarty plugin
*
- * @package Smarty
+ * @package Smarty
* @subpackage PluginsFilter
*/
/**
* Smarty trimwhitespace outputfilter plugin
- *
* Trim unnecessary whitespace from HTML markup.
*
* @author Rodney Rehm
- * @param string $source input string
- * @param Smarty_Internal_Template $smarty Smarty object
+ *
+ * @param string $source input string
+ *
* @return string filtered output
- * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
+ * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
*/
-function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $smarty)
+function smarty_outputfilter_trimwhitespace($source)
{
$store = array();
$_store = 0;
@@ -35,13 +35,13 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace);
- $_store++;
+ $_store ++;
}
}
// Strip all HTML-Comments
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
- $source = preg_replace( '#<!--.*?-->#ms', '', $source );
+ $source = preg_replace('#<!--.*?-->#ms', '', $source);
// capture html elements not to be messed with
$_offset = 0;
@@ -53,42 +53,38 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace);
- $_store++;
+ $_store ++;
}
}
$expressions = array(
// replace multiple spaces between tags by a single space
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
- '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
+ '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
- '#^\s+<#Ss' => '<',
- '#>\s+$#Ss' => '>',
+ '#^\s+<#Ss' => '<',
+ '#>\s+$#Ss' => '>',
);
- $source = preg_replace( array_keys($expressions), array_values($expressions), $source );
+ $source = preg_replace(array_keys($expressions), array_values($expressions), $source);
// note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering?
// $source = trim( $source );
- // capture html elements not to be messed with
$_offset = 0;
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
foreach ($matches as $match) {
- $store[] = $match[0][0];
$_length = strlen($match[0][0]);
- $replace = array_shift($store);
+ $replace = $store[$match[1][0]];
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
$_offset += strlen($replace) - $_length;
- $_store++;
+ $_store ++;
}
}
return $source;
}
-
-?> \ No newline at end of file