List for cgit developers and users
 help / color / mirror / Atom feed
From: aklhfex at gmail.com (Chris Mayo)
Subject: [PATCH] syntax-highlighting.sh: revise and add highlight 3.50 support
Date: Fri, 15 Mar 2019 20:10:22 +0000	[thread overview]
Message-ID: <20190315201022.32351-1-aklhfex@gmail.com> (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



                 reply	other threads:[~2019-03-15 20:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190315201022.32351-1-aklhfex@gmail.com \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).