From 68ac117821e757dc26a92fbaa4057870eb38667c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Dec 2025 23:41:47 +0200 Subject: Fix draft HTML generation for files with unsupported source-highlight languages - Add .tmp to exclusion pattern in cleanup to prevent race condition - Gracefully fallback to plain
 when source-highlight fails (e.g., yaml)
---
 lib/html.source.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'lib/html.source.sh')

diff --git a/lib/html.source.sh b/lib/html.source.sh
index 1d5b34c..f772e22 100644
--- a/lib/html.source.sh
+++ b/lib/html.source.sh
@@ -138,11 +138,6 @@ html::source_highlight () {
         html::encode "$bare_text"
         echo '
' else - local style_css='' - if [ -n "$SOURCE_HIGHLIGHT_CSS" ]; then - style_css="--style-css-file=$SOURCE_HIGHLIGHT_CSS" - fi - if [[ "$lang_trimmed" == "AUTO" ]]; then log WARN "GNU Source Highlight auto detection not yet supported!" echo '
'
@@ -154,7 +149,12 @@ html::source_highlight () {
             if [ -n "$SOURCE_HIGHLIGHT_CSS" ]; then
                 cmd+=("--style-css-file=$SOURCE_HIGHLIGHT_CSS")
             fi
-            "${cmd[@]}" <<< "$bare_text" | $SED 's|||; s|||;'
+            if ! "${cmd[@]}" <<< "$bare_text" 2>/dev/null | $SED 's|||; s|||;'; then
+                # Fallback if source-highlight doesn't support the language
+                echo '
'
+                html::encode "$bare_text"
+                echo '
' + fi fi fi } -- cgit v1.2.3