[PATCH 1/1] highlight: fix syntax highlighting for program versions > 2
Ferry Huberts
mailings at hupie.com
Sun Feb 19 18:33:01 CET 2012
From: Ferry Huberts <ferry.huberts at pelagic.nl>
Signed-off-by: Ferry Huberts <ferry.huberts at pelagic.nl>
---
filters/syntax-highlighting.sh | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
index 6283ce9..9ff3d34 100755
--- a/filters/syntax-highlighting.sh
+++ b/filters/syntax-highlighting.sh
@@ -42,4 +42,15 @@ EXTENSION="${BASENAME##*.}"
# map Makefile and Makefile.* to .mk
[ "${BASENAME%%.*}" == "Makefile" ] && EXTENSION=mk
-exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null
+# get highlight version
+regex='^[[:space:]]*highlight[[:space:]]+version[[:space:]]+([[:digit:]]+).*'
+highlightVersion="$(highlight --version | grep -E "${regex}" | sed -r "s/${regex}/\1/")"
+
+if [[ "${highlightVersion}" == "2" ]]; then
+ # for highlight 2.x
+ exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null
+else
+ # for other versions
+ exec highlight --force -f -I -O xhtml -S $EXTENSION 2>/dev/null
+fi
+
--
1.7.7.6
More information about the CGit
mailing list