diff options
| author | Paul Buetow <paul@buetow.org> | 2025-07-09 00:13:52 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-07-09 00:13:52 +0300 |
| commit | 2e70c6bf1f0d7a16c3d70512de1650bb010d13b6 (patch) | |
| tree | 8966f70191b27ec6854ef4472a0958ed8e4d1d3f | |
| parent | 1c1109b7e0d741a113af1d94a5741d9fe7373f04 (diff) | |
fix: unbound variable in html::source_highlight
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | lib/html.source.sh | 2 |
2 files changed, 11 insertions, 1 deletions
@@ -122,6 +122,16 @@ 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: + +``` + ```AUTO + if [ -n "$foo" ]; then + echo "$foo" + fi + ... +``` + Please run `source-highlight --lang-list` for a list of all supported languages. For available styles, have a look here: [GNU Source-highlight Style Examples](https://www.gnu.org/savannah-checkouts/gnu/src-highlite/style_examples.html) diff --git a/lib/html.source.sh b/lib/html.source.sh index 3e16264..8dab622 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -129,6 +129,7 @@ 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>' @@ -141,7 +142,6 @@ html::source_highlight () { fi if [[ "$language" == "AUTO" ]]; then - local tmp_file tmp_file=$(mktemp) trap 'rm -f "$tmp_file"' RETURN printf %s "$bare_text" > "$tmp_file" |
