diff --git a/lib-htmgem.php b/lib-htmgem.php index d0a0cf6..2a2cb80 100644 --- a/lib-htmgem.php +++ b/lib-htmgem.php @@ -254,12 +254,14 @@ class GemtextTranslate_html { # Adds no-break space to stick the (EM/EN dashes) to words : aaaaaa – bb. ==> aaaaaa –$bb. $text = mb_ereg_replace("([—–]) ([^.]+)\.", "\\1".self::NARROW_NO_BREAK_SPACE."\\2.", $text); - - # Replaces several spaces (0x20) by only one - $text = preg_replace("/ +/", " ", $text); } } + protected static function spacesCompress(&$text) { + # Replaces several spaces (0x20) by only one + $text = preg_replace("/ +/", " ", $text); + } + public function translate($textDecoration=true) { $output = ""; foreach ($this->parsedGemtext as $node) { @@ -267,6 +269,7 @@ class GemtextTranslate_html { switch($mode) { case "": $text = $node["text"]; + self::spacesCompress($text); self::htmlPrepare($text); if ($textDecoration) self::addTextDecoration($text); $output .= "

$text

\n"; @@ -274,6 +277,7 @@ class GemtextTranslate_html { case "*": $output .= "