List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH] syntax-highlighting.sh: revise and add highlight 3.50 support
@ 2019-03-15 20:10 aklhfex
  0 siblings, 0 replies; only message in thread
From: aklhfex @ 2019-03-15 20:10 UTC (permalink / raw)


- Remove CSS declarations not relevant to the output of highlight -f
- cgit now using non-XML HTML5, which means highlight 2 & 3 (<3.50)
  commands are the same
- Use --syntax-by-name with highlight 3.50 to take advantage of whole
  filename e.g. Meson and CMake, and shebang matching.

Signed-off-by: Chris Mayo <aklhfex at gmail.com>
---

N.B. Highlight 3.50 not released at the time of writing.

I have modified my own copy of cgit to prefix the filename sent to
cgit_open_filter with --syntax-by-name. This means I don't need this script and
configure source-filter=/usr/bin/highlight (separately in the environment I set
HIGHLIGHT_OPTIONS=-f -I --force). That's just hard-coding at the moment,
if there is any interest or ideas about how to make it acceptable do say.

Chris


 filters/syntax-highlighting.sh | 33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
index 840bc34..e45a07f 100755
--- a/filters/syntax-highlighting.sh
+++ b/filters/syntax-highlighting.sh
@@ -3,13 +3,14 @@
 # tree-view by referring to this file with the source-filter or repo.source-
 # filter options in cgitrc.
 #
-# This script requires a shell supporting the ${var##pattern} syntax.
-# It is supported by at least dash and bash, however busybox environments
-# might have to use an external call to sed instead.
+# highlight (http://www.andre-simon.de/) is used to create formatted HTML.
 #
-# Note: the highlight command (http://www.andre-simon.de/) uses css for syntax
-# highlighting, so you'll probably want something like the following included
-# in your css file:
+# For highlight versions before 3.50 this script requires a shell supporting
+# the ${var##pattern} syntax. It is supported by at least dash and bash,
+# however busybox environments might have to use an external call to sed.
+#
+# The colors applied to the output of highlight are defined with CSS, a
+# variant of the following will be needed in your CSS file:
 #
 # Style definition file generated by highlight 2.4.8, http://www.andre-simon.de/
 #
@@ -29,8 +30,6 @@
 #
 # Style definition file generated by highlight 2.6.14, http://www.andre-simon.de/
 #
-# body.hl  { background-color:#ffffff; }
-# pre.hl   { color:#000000; background-color:#ffffff; font-size:10pt; font-family:'Courier New';}
 # .hl.num  { color:#2928ff; }
 # .hl.esc  { color:#ff00ff; }
 # .hl.str  { color:#ff0000; }
@@ -49,8 +48,6 @@
 #
 # Style definition file generated by highlight 3.8, http://www.andre-simon.de/
 #
-# body.hl { background-color:#e0eaee; }
-# pre.hl  { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New';}
 # .hl.num { color:#b07e00; }
 # .hl.esc { color:#ff00ff; }
 # .hl.str { color:#bf0303; }
@@ -68,8 +65,6 @@
 #
 # Style definition file generated by highlight 3.13, http://www.andre-simon.de/
 #
-# body.hl { background-color:#e0eaee; }
-# pre.hl  { color:#000000; background-color:#e0eaee; font-size:10pt; font-family:'Courier New',monospace;}
 # .hl.num { color:#b07e00; }
 # .hl.esc { color:#ff00ff; }
 # .hl.str { color:#bf0303; }
@@ -107,15 +102,7 @@ EXTENSION="${BASENAME##*.}"
 # map Makefile and Makefile.* to .mk
 [ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk
 
-# highlight versions 2 and 3 have different commandline options. Specifically,
-# the -X option that is used for version 2 is replaced by the -O xhtml option
-# for version 3.
-#
-# Version 2 can be found (for example) on EPEL 5, while version 3 can be
-# found (for example) on EPEL 6.
-#
-# This is for version 2
-exec highlight --force -f -I -X -S "$EXTENSION" 2>/dev/null
+exec highlight --force -f -I -S "$EXTENSION" 2>/dev/null
 
-# This is for version 3
-#exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null
+# This is for highlight 3.50 onwards, none of the above code is required
+#exec highlight --force -f -I --syntax-by-name="${1}" 2>/dev/null
-- 
2.21.0



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-03-15 20:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15 20:10 [PATCH] syntax-highlighting.sh: revise and add highlight 3.50 support aklhfex

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).