From d280ceff94c2d805c8c908d4948cfdf9c93ae63a Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Thu, 18 Mar 2021 14:43:02 +0100 Subject: [PATCH] WIP --- index.php | 34 +++++++++++++++++----------------- lib-htmgem.php | 3 +-- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/index.php b/index.php index 5832956..2942a24 100644 --- a/index.php +++ b/index.php @@ -83,24 +83,24 @@ $fileContents EOL; exit(); -} else { - $t = new \htmgem\GemTextTranslate_html($fileContents); - if ("none" == $style) { - $t->addCss(""); - } elseif ("/" == @$style[0]) { - $t->addCss($style); - } elseif (empty($style)) { - $parts = pathinfo($filePath); - $localCss = $parts["filename"].".css"; - $localCssFilePath = $parts["dirname"]."/".$localCss; - if (file_exists($localCssFilePath)) { - # Warning, using htmhem.php?url=… will make $localCss not found - # as the path is relative to htmgem.php and not / ! - $t->addCss($localCss); - } - } else { #TODO: regex check for $style - $t->addCss("/htmgem/css/$style.css"); +} + +$t = new \htmgem\GemTextTranslate_html($fileContents, $textDecoration); +if ("none" == $style) { + $t->addCss(""); +} elseif ("/" == @$style[0]) { + $t->addCss($style); +} elseif (empty($style)) { + $parts = pathinfo($filePath); + $localCss = $parts["filename"].".css"; + $localCssFilePath = $parts["dirname"]."/".$localCss; + if (file_exists($localCssFilePath)) { + # Warning, using htmhem.php?url=… will make $localCss not found + # as the path is relative to htmgem.php and not / ! + $t->addCss($localCss); } +} else { #TODO: regex check for $style + $t->addCss("/htmgem/css/$style.css"); } echo $t->getFullHtml(); diff --git a/lib-htmgem.php b/lib-htmgem.php index 1b40b39..cf2c3cc 100644 --- a/lib-htmgem.php +++ b/lib-htmgem.php @@ -170,8 +170,7 @@ class GemtextTranslate_html { function __construct($parsedGemtext, $textDecorationEnabled=true) { if (empty($parsedGemtext)) - // So translate() will do no loop. - $parsedGemtext = array(); + $parsedGemtext = ""; elseif (is_string($parsedGemtext)) // to delete the last empty line,

 

in HTML $parsedGemtext = rtrim($parsedGemtext);