mirror of
https://tildegit.org/sbgodin/HtmGem.git
synced 2023-08-25 13:53:12 +02:00
Replaces several spaces to only one
This commit is contained in:
parent
91abafdce0
commit
c858b733f4
@ -254,6 +254,9 @@ class GemtextTranslate_html {
|
|||||||
|
|
||||||
# Adds no-break space to stick the (EM/EN dashes) to words : aaaaaa – bb. ==> aaaaaa –$bb.
|
# 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);
|
$text = mb_ereg_replace("([—–]) ([^.]+)\.", "\\1".self::NARROW_NO_BREAK_SPACE."\\2.", $text);
|
||||||
|
|
||||||
|
# Replaces several spaces (0x20) by only one
|
||||||
|
$text = preg_replace("/ +/", " ", $text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,11 +11,16 @@ function translateHtml($text): string {
|
|||||||
|
|
||||||
final class translateToHtmlTest extends TestCase {
|
final class translateToHtmlTest extends TestCase {
|
||||||
|
|
||||||
|
protected static function noSeveralSpaces($text): string {
|
||||||
|
# Replaces several spaces (0x20) by only one
|
||||||
|
return preg_replace("/ +/", " ", $text);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_translate_gemtext_smallTextSets(): void {
|
public function test_translate_gemtext_smallTextSets(): void {
|
||||||
$line1 = " Hello, how are you? ";
|
$line1 = " Hello, how are you? ";
|
||||||
$line2 = " Nice to meet you! ";
|
$line2 = " Nice to meet you! ";
|
||||||
$rline1 = rtrim($line1);
|
$rline1 = self::noSeveralSpaces(rtrim($line1));
|
||||||
$rline2 = rtrim($line2);
|
$rline2 = self::noSeveralSpaces(rtrim($line2));
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
"",
|
"",
|
||||||
translateHtml(null),
|
translateHtml(null),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user