From 3a094f6447ae98f720c3a0a826b054a624b5483c Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 3 May 2019 11:54:54 -0400 Subject: [PATCH] Adjustment to WireTextTools::markupToText() method to prevent it from adding redundant newlines --- wire/core/WireTextTools.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wire/core/WireTextTools.php b/wire/core/WireTextTools.php index 58315c3d..bd4b8705 100644 --- a/wire/core/WireTextTools.php +++ b/wire/core/WireTextTools.php @@ -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); }