summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-12-06 23:41:47 +0200
committerPaul Buetow <paul@buetow.org>2025-12-06 23:41:54 +0200
commit68ac117821e757dc26a92fbaa4057870eb38667c (patch)
tree0c3b682fb42518775367149bede11eed9a749f4d /lib
parent48de4390f9cb6e4ebebb1182a0748296b483d697 (diff)
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 <pre> when source-highlight fails (e.g., yaml)
Diffstat (limited to 'lib')
-rw-r--r--lib/generate.source.sh2
-rw-r--r--lib/html.source.sh12
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/generate.source.sh b/lib/generate.source.sh
index db9dc95..313531d 100644
--- a/lib/generate.source.sh
+++ b/lib/generate.source.sh
@@ -185,7 +185,7 @@ generate::fromgmi () {
# Anoter note: The CNAME file is required by GitHub pages as well for custom domains.
for format in "$@"; do
find "$CONTENT_BASE_DIR/$format" -type f |
- $GREP -E -v '(\.git.*|_config.yml|CNAME|.domains|robots.txt|static)$'|
+ $GREP -E -v '(\.git.*|_config.yml|CNAME|.domains|robots.txt|static|\.tmp)$'|
while read -r src; do
generate::fromgmi_cleanup_docs "$src" "$format"
done &
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 '</pre>'
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 '<pre>'
@@ -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|<tt>||; s|</tt>||;'
+ if ! "${cmd[@]}" <<< "$bare_text" 2>/dev/null | $SED 's|<tt>||; s|</tt>||;'; then
+ # Fallback if source-highlight doesn't support the language
+ echo '<pre>'
+ html::encode "$bare_text"
+ echo '</pre>'
+ fi
fi
fi
}