Compare commits
3 Commits
c37549d50c
...
2261dac656
Author | SHA1 | Date |
---|---|---|
Christophe HENRY | 2261dac656 | |
Christophe HENRY | c858b733f4 | |
Christophe HENRY | 91abafdce0 |
|
@ -254,6 +254,9 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,10 +286,13 @@ class GemtextTranslate_html {
|
|||
$output .= "<pre>\n$text\n</pre>\n";
|
||||
break;
|
||||
case ">":
|
||||
$text = implode("\n", $node["texts"]);
|
||||
$output .= "<blockquote>\n";
|
||||
foreach ($node["texts"] as $text) {
|
||||
self::htmlPrepare($text);
|
||||
if ($textDecoration) self::addTextDecoration($text);
|
||||
$output .= "<blockquote>\n$text\n</blockquote>\n";
|
||||
$output .= "<p>$text</p>\n";
|
||||
}
|
||||
$output .= "</blockquote>\n";
|
||||
break;
|
||||
case "=>":
|
||||
$link = $node["link"];
|
||||
|
|
|
@ -5,6 +5,5 @@ $fileName = $argv[1];
|
|||
require_once dirname(__FILE__)."/../../lib-htmgem.php";
|
||||
|
||||
$text = file_get_contents($fileName);
|
||||
$parsedGemtext = \htmgem\gemtextParser($text);
|
||||
$gt_gemtext = new \htmgem\GemtextTranslate_gemtext($parsedGemtext);
|
||||
$gt_gemtext = new \htmgem\GemtextTranslate_gemtext($text);
|
||||
echo strval($gt_gemtext);
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<p>This text is made of empty quotes :</p>
|
||||
<blockquote>
|
||||
|
||||
<p> </p>
|
||||
</blockquote>
|
||||
<p> </p>
|
||||
<p>Quotes with one word:</p>
|
||||
<blockquote>
|
||||
one
|
||||
<p>one</p>
|
||||
</blockquote>
|
||||
<p>Quotes with two words:</p>
|
||||
<blockquote>
|
||||
A B
|
||||
<p>A B</p>
|
||||
</blockquote>
|
||||
<p> </p>
|
||||
<p>Several quotes :</p>
|
||||
<blockquote>
|
||||
1
|
||||
2
|
||||
3
|
||||
<p>1</p>
|
||||
<p>2</p>
|
||||
<p>3</p>
|
||||
</blockquote>
|
||||
<p> </p>
|
||||
<p>Quotes with an empty one in between:</p>
|
||||
<blockquote>
|
||||
1
|
||||
|
||||
3
|
||||
<p>1</p>
|
||||
<p> </p>
|
||||
<p>3</p>
|
||||
</blockquote>
|
||||
|
|
|
@ -11,11 +11,16 @@ function translateHtml($text): string {
|
|||
|
||||
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 {
|
||||
$line1 = " Hello, how are you? ";
|
||||
$line2 = " Nice to meet you! ";
|
||||
$rline1 = rtrim($line1);
|
||||
$rline2 = rtrim($line2);
|
||||
$rline1 = self::noSeveralSpaces(rtrim($line1));
|
||||
$rline2 = self::noSeveralSpaces(rtrim($line2));
|
||||
$this->assertSame(
|
||||
"",
|
||||
translateHtml(null),
|
||||
|
|
Loading…
Reference in New Issue