Compare commits

...

5 Commits

Author SHA1 Message Date
Christophe HENRY 4e42fed6b4 Adds null space between two slashes 2021-03-21 00:21:41 +01:00
Christophe HENRY c1299a2bdb FIX: adds line feed inside a blockquote
Example:
> line_1
> line_2

Before :
line_1 line_2

After :
Line_1
Line_2
2021-03-21 00:14:55 +01:00
Christophe HENRY 710bd1bf07 Corrects blockquote size on mobile 2021-03-20 22:41:04 +00:00
Christophe HENRY 731a8eef6a Escapes the quotes and enable double encode 2021-03-20 15:21:43 +01:00
Christophe HENRY 5df9d5ff15 FIX: textDecoration switch not updated 2021-03-19 17:49:21 +01:00
4 changed files with 15 additions and 10 deletions

View File

@ -114,7 +114,7 @@ pre {
h3 { h3 {
font-size: 3rem; font-size: 3rem;
} }
p, pre, ul { p, pre, ul, blockquote {
font-size: 2.6rem; font-size: 2.6rem;
} }
} }

View File

@ -88,7 +88,7 @@ Lorsque loption css est activé dans la configuration (voir //rewrite// plus
## Réécriture dURL pour préciser le style à utiliser ## Réécriture dURL pour préciser le style à utiliser
Modifier la configuration du serveur web fonctionne mais est assez lourd. On peut tester un style en particulier de la façon suivante : Modifier la configuration du serveur web fonctionne mais est assez lourd. On peut tester un style en particulier de la façon suivante :
> https://site.tld/htmgem/index.php?url=/url/page.gmi&style=<…> > https://site.tld/htmgem/index.php?url=/url/page.gmi&style=<…>
Il est aussi possible de faire une réécriture dURL qui intègre le style : Il est aussi possible de faire une réécriture dURL qui intègre le style :
> rewrite ^(.+\.gmi)$ /htmgem/?url=$1; > rewrite ^(.+\.gmi)$ /htmgem/?url=$1;

View File

@ -80,7 +80,7 @@ if ("source" == $style) {
# Gets the page title: the first occurrence with # at the line start # Gets the page title: the first occurrence with # at the line start
mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches); mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches);
$page_title = @$matches[1]; $page_title = @$matches[1];
$fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false); $fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_QUOTES, "UTF-8", true);
echo <<<EOL echo <<<EOL
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>

View File

@ -168,7 +168,7 @@ class GemtextTranslate_html {
protected $pageTitle = ""; protected $pageTitle = "";
public $translatedGemtext; public $translatedGemtext;
function __construct($parsedGemtext, $textDecorationEnabled=true) { function __construct($parsedGemtext, $textDecoration=true) {
if (empty($parsedGemtext)) if (empty($parsedGemtext))
$parsedGemtext = ""; $parsedGemtext = "";
elseif (is_string($parsedGemtext)) elseif (is_string($parsedGemtext))
@ -177,7 +177,7 @@ class GemtextTranslate_html {
// The text must be parsed // The text must be parsed
$parsedGemtext = gemtextParser($parsedGemtext); $parsedGemtext = gemtextParser($parsedGemtext);
$this->parsedGemtext = $parsedGemtext; $this->parsedGemtext = $parsedGemtext;
$this->translate($textDecorationEnabled); $this->translate($textDecoration);
} }
function addCss($css) { function addCss($css) {
@ -232,7 +232,7 @@ class GemtextTranslate_html {
if (empty($text)) { if (empty($text)) {
$text = "&nbsp;"; $text = "&nbsp;";
} else { } else {
$text = htmlspecialchars($text, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false); $text = htmlspecialchars($text, ENT_HTML5|ENT_QUOTES, "UTF-8", true);
$text = mb_ereg_replace("\ ([?!:;»€$])", self::NARROW_NO_BREAK_SPACE."\\1", $text); $text = mb_ereg_replace("\ ([?!:;»€$])", self::NARROW_NO_BREAK_SPACE."\\1", $text);
$text = mb_ereg_replace("([«])\ ", "\\1".self::NARROW_NO_BREAK_SPACE, $text); # Espace fine insécable $text = mb_ereg_replace("([«])\ ", "\\1".self::NARROW_NO_BREAK_SPACE, $text); # Espace fine insécable
@ -271,9 +271,11 @@ class GemtextTranslate_html {
echo "<pre>\n$text\n</pre>\n"; echo "<pre>\n$text\n</pre>\n";
break; break;
case ">": case ">":
$text = implode("\n", $node["texts"]); foreach ($node["texts"] as &$text) {
self::htmlPrepare($text); self::htmlPrepare($text);
if ($textDecoration) self::addTextDecoration($text); if ($textDecoration) self::addTextDecoration($text);
}
$text = implode("<br>\n", $node["texts"]);
echo "<blockquote>\n$text\n</blockquote>\n"; echo "<blockquote>\n$text\n</blockquote>\n";
break; break;
case "=>": case "=>":
@ -283,6 +285,9 @@ class GemtextTranslate_html {
$linkText = $link; $linkText = $link;
self::htmlPrepare($linkText); self::htmlPrepare($linkText);
} else { } else {
// Don't double encode, just escapes quotes, "<" and ">".
// So "I'm&gt" becomes "I&apos;&gt". The & remains untouched.
$link = htmlspecialchars($link, ENT_HTML5|ENT_QUOTES, "UTF-8", false);
self::htmlPrepare($linkText); self::htmlPrepare($linkText);
if ($textDecoration) self::addTextDecoration($linkText); if ($textDecoration) self::addTextDecoration($linkText);
} }
@ -308,7 +313,7 @@ class GemtextTranslate_html {
echo "<h3>$title</h3>\n"; echo "<h3>$title</h3>\n";
break; break;
case "^^^": case "^^^":
$this->textDecorationEnabled = !$this->textDecorationEnabled; $textDecoration = !$textDecoration;
break; break;
default: default:
die("Unknown mode: '{$node["mode"]}'\n"); die("Unknown mode: '{$node["mode"]}'\n");