correctly handle unknown syntaxes when highlighting

This commit is contained in:
Alexander 2025-06-16 19:27:42 -04:00
parent 18b0b14e25
commit 64acf09214
6 changed files with 56 additions and 60 deletions

9
syntax_wrapper.sh Executable file
View file

@ -0,0 +1,9 @@
#! /usr/bin/env bash
if [[ $# -lt 1 ]] || ! { pygmentize -L lexers | grep -qw "$1"; }; then
printf "<code>"
cat
printf "</code>"
else
pygmentize -l $1 -f html | head -c -13 | awk -F '<pre>' '{print $NF}'
fi