summaryrefslogtreecommitdiff
path: root/lib/html.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-07-09 00:17:11 +0300
committerPaul Buetow <paul@buetow.org>2025-07-09 00:17:11 +0300
commit0a29784db9e3355e7b0980ff9adc8e527aa7b0b0 (patch)
treecb1b1cfb7d75d74dd19e20d3389ea1eeae80c445 /lib/html.source.sh
parent2e70c6bf1f0d7a16c3d70512de1650bb010d13b6 (diff)
fix: unbound variable in html::source_highlight
Diffstat (limited to 'lib/html.source.sh')
-rw-r--r--lib/html.source.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/html.source.sh b/lib/html.source.sh
index 8dab622..78b486e 100644
--- a/lib/html.source.sh
+++ b/lib/html.source.sh
@@ -129,7 +129,6 @@ html::theme::webfonts () {
html::source_highlight () {
local -r bare_text="$1"; shift
local -r language="$1"; shift
- local tmp_file=''
if [[ -z "$language" || -z "$SOURCE_HIGHLIGHT" ]]; then
echo '<pre>'
@@ -142,13 +141,14 @@ html::source_highlight () {
fi
if [[ "$language" == "AUTO" ]]; then
- tmp_file=$(mktemp)
- trap 'rm -f "$tmp_file"' RETURN
+ local tmp_file
+ tmp_file="/tmp/gemtexter-source-highlight-$(date +%s%N)"
printf %s "$bare_text" > "$tmp_file"
local output
# redirect stderr to avoid printing the error message
output=$($SOURCE_HIGHLIGHT --infer-lang --failsafe -i "$tmp_file" "$style_css" 2>/dev/null)
+ rm -f "$tmp_file"
# if output is same as input, highlighting failed
# also check if output is empty, which also means failure