summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extras/html/footer.html.part8
-rw-r--r--lib/html.source.sh27
2 files changed, 27 insertions, 8 deletions
diff --git a/extras/html/footer.html.part b/extras/html/footer.html.part
index 2d37d57..f82ee8e 100644
--- a/extras/html/footer.html.part
+++ b/extras/html/footer.html.part
@@ -1,7 +1,9 @@
<p class="footer">
-Generated with <a href="https://codeberg.org/snonux/gemtexter">%%GEMTEXTER%%</a> |
-served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/relayd.8">relayd(8)</a>+<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |
-<a href="https://%%DOMAIN%%/site-mirrors.html">Site Mirrors</a>
+ Generated with <a href="https://codeberg.org/snonux/gemtexter">%%GEMTEXTER%%</a> |
+ served by <a href="https://www.OpenBSD.org">OpenBSD</a>/<a href="https://man.openbsd.org/relayd.8">relayd(8)</a>+<a href="https://man.openbsd.org/httpd.8">httpd(8)</a> |
+ <a href="https://%%DOMAIN%%/site-mirrors.html">Site Mirrors</a>
+ <br />
+ Webring: <a href="https://shring.sh/foo.zone/previous">previous</a> | <a href="https://shring.sh">shring</a> | <a href="https://shring.sh/foo.zone/next">next</a>
</p>
</body>
</html>
diff --git a/lib/html.source.sh b/lib/html.source.sh
index f6ee8e6..1d5b34c 100644
--- a/lib/html.source.sh
+++ b/lib/html.source.sh
@@ -130,7 +130,10 @@ html::source_highlight () {
local -r bare_text="$1"; shift
local -r language="$1"; shift
- if [[ -z "$language" || -z "$SOURCE_HIGHLIGHT" ]]; then
+ # Trim whitespace from language (handles cases like "``` ")
+ local -r lang_trimmed="$($SED -E 's/^ +| +$//g' <<< "$language")"
+
+ if [[ -z "$lang_trimmed" || -z "$SOURCE_HIGHLIGHT" ]]; then
echo '<pre>'
html::encode "$bare_text"
echo '</pre>'
@@ -140,14 +143,18 @@ html::source_highlight () {
style_css="--style-css-file=$SOURCE_HIGHLIGHT_CSS"
fi
- if [[ "$language" == "AUTO" ]]; then
+ if [[ "$lang_trimmed" == "AUTO" ]]; then
log WARN "GNU Source Highlight auto detection not yet supported!"
echo '<pre>'
html::encode "$bare_text"
echo '</pre>'
else
- $SOURCE_HIGHLIGHT --src-lang="$language" "$style_css" <<< "$bare_text" |
- $SED 's|<tt>||; s|</tt>||;'
+ # Build command safely to avoid empty args and word splitting
+ local -a cmd=("$SOURCE_HIGHLIGHT" "--src-lang=$lang_trimmed")
+ if [ -n "$SOURCE_HIGHLIGHT_CSS" ]; then
+ cmd+=("--style-css-file=$SOURCE_HIGHLIGHT_CSS")
+ fi
+ "${cmd[@]}" <<< "$bare_text" | $SED 's|<tt>||; s|</tt>||;'
fi
fi
}
@@ -217,7 +224,8 @@ $line"
echo "<li>$(html::list::encode "${line/\* /}")</li>" | html::process_inline
;;
'```'*)
- language=$(cut -d'`' -f4 <<< "$line")
+ # Extract language after the opening backticks and trim spaces
+ language=$($SED -E 's/^```\s*//; s/\s+$//' <<< "$line")
is_bare=yes
;;
'# '*)
@@ -338,6 +346,15 @@ this
assert::equals "$(html::fromgmi <<< "$input_block")" "$output_block"
+ # Trailing space after fence should not trigger source-highlight
+ input_block='```
+code
+```'
+ output_block='<pre>
+code
+</pre>'
+ assert::equals "$(html::fromgmi <<< "$input_block")" "$output_block"
+
if [ -n "$SOURCE_HIGHLIGHT" ]; then
input_block='```bash
if [ -z $foo ]; then