diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-09 00:34:38 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-09 00:34:38 +0300 |
| commit | 0177f9d40b7eb0dd33138923927b4d117a26c394 (patch) | |
| tree | 8369bdeec50d1860267494ad71aaaac7a3a4c209 | |
| parent | 0a29784db9e3355e7b0980ff9adc8e527aa7b0b0 (diff) | |
AUTO not yet supported
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | lib/html.source.sh | 22 |
2 files changed, 5 insertions, 19 deletions
@@ -122,7 +122,7 @@ The HTML output supports source code highlighting. The requirement is to have th ... ``` -Alternatively, you can set the language to `AUTO` to enable automatic language detection: +Not yet supported, but syntax is there already: Alternatively, you can set the language to `AUTO` to enable automatic language detection: ``` ```AUTO diff --git a/lib/html.source.sh b/lib/html.source.sh index 78b486e..3c2a3dc 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -141,24 +141,10 @@ html::source_highlight () { fi if [[ "$language" == "AUTO" ]]; then - 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 - if [[ "$output" == "$bare_text" || -z "$output" ]]; then - echo '<pre>' - html::encode "$bare_text" - echo '</pre>' - else - echo "$output" | $SED 's|<tt>||; s|</tt>||;' - fi + 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>||;' |
