Compare commits

..

No commits in common. "4e42fed6b40f0c85fdec02cf4c3c03e623b74615" and "cef2417f91667d744e5b7b40b1744ce6a8082dab" have entirely different histories.

4 changed files with 10 additions and 15 deletions

View File

@ -114,7 +114,7 @@ pre {
h3 {
font-size: 3rem;
}
p, pre, ul, blockquote {
p, pre, ul {
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
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 :
> 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
mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches);
$page_title = @$matches[1];
$fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_QUOTES, "UTF-8", true);
$fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false);
echo <<<EOL
<!DOCTYPE html>
<html>

View File

@ -168,7 +168,7 @@ class GemtextTranslate_html {
protected $pageTitle = "";
public $translatedGemtext;
function __construct($parsedGemtext, $textDecoration=true) {
function __construct($parsedGemtext, $textDecorationEnabled=true) {
if (empty($parsedGemtext))
$parsedGemtext = "";
elseif (is_string($parsedGemtext))
@ -177,7 +177,7 @@ class GemtextTranslate_html {
// The text must be parsed
$parsedGemtext = gemtextParser($parsedGemtext);
$this->parsedGemtext = $parsedGemtext;
$this->translate($textDecoration);
$this->translate($textDecorationEnabled);
}
function addCss($css) {
@ -232,7 +232,7 @@ class GemtextTranslate_html {
if (empty($text)) {
$text = "&nbsp;";
} else {
$text = htmlspecialchars($text, ENT_HTML5|ENT_QUOTES, "UTF-8", true);
$text = htmlspecialchars($text, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false);
$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
@ -271,11 +271,9 @@ class GemtextTranslate_html {
echo "<pre>\n$text\n</pre>\n";
break;
case ">":
foreach ($node["texts"] as &$text) {
self::htmlPrepare($text);
if ($textDecoration) self::addTextDecoration($text);
}
$text = implode("<br>\n", $node["texts"]);
$text = implode("\n", $node["texts"]);
self::htmlPrepare($text);
if ($textDecoration) self::addTextDecoration($text);
echo "<blockquote>\n$text\n</blockquote>\n";
break;
case "=>":
@ -285,9 +283,6 @@ class GemtextTranslate_html {
$linkText = $link;
self::htmlPrepare($linkText);
} 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);
if ($textDecoration) self::addTextDecoration($linkText);
}
@ -313,7 +308,7 @@ class GemtextTranslate_html {
echo "<h3>$title</h3>\n";
break;
case "^^^":
$textDecoration = !$textDecoration;
$this->textDecorationEnabled = !$this->textDecorationEnabled;
break;
default:
die("Unknown mode: '{$node["mode"]}'\n");