1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-17 12:10:45 +02:00

Adjustment to WireTextTools::markupToText() method to prevent it from adding redundant newlines

This commit is contained in:
Ryan Cramer
2019-05-03 11:54:54 -04:00
parent 12f6253af6
commit 3a094f6447

View File

@@ -101,11 +101,6 @@ class WireTextTools extends Wire {
}
}
// normalize newlines and whitespace around newlines
while(strpos($str, " \n") !== false) $str = str_replace(" \n", "\n", $str);
while(strpos($str, "\n ") !== false) $str = str_replace("\n ", "\n", $str);
while(strpos($str, "\n\n\n") !== false) $str = str_replace("\n\n\n", "\n\n", $str);
// strip tags
if(count($options['keepTags'])) {
// some tags will be allowed to remain
@@ -131,6 +126,11 @@ class WireTextTools extends Wire {
if($options['convertEntities'] && strpos($str, '&') !== false) {
$str = $this->wire('sanitizer')->unentities($str);
}
// normalize newlines and whitespace around newlines
while(strpos($str, " \n") !== false) $str = str_replace(" \n", "\n", $str);
while(strpos($str, "\n ") !== false) $str = str_replace("\n ", "\n", $str);
while(strpos($str, "\n\n\n") !== false) $str = str_replace("\n\n\n", "\n\n", $str);
return trim($str);
}