From: cgit at cryptocrack.de (Lukas Fleischer)
Subject: [PATCH v2 3/3] highlight: fix syntax highlighting for program versions > 2
Date: Tue, 21 Feb 2012 15:21:56 +0100 [thread overview]
Message-ID: <20120221142156.GA28585@blizzard> (raw)
In-Reply-To: <4F43A087.8090903@hupie.com>
On Tue, Feb 21, 2012 at 02:47:51PM +0100, Ferry Huberts wrote:
>
>
> On 21-02-12 14:27, Lukas Fleischer wrote:
> >On Tue, Feb 21, 2012 at 01:13:31PM +0100, Ferry Huberts wrote:
> >>From: Ferry Huberts<ferry.huberts at pelagic.nl>
> >>
> >>Signed-off-by: Ferry Huberts<ferry.huberts at pelagic.nl>
> >>---
> >> filters/syntax-highlighting.sh | 22 ++++++++++++++++++++--
> >> 1 files changed, 20 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/filters/syntax-highlighting.sh b/filters/syntax-highlighting.sh
> >>index 0f97fea..387960d 100755
> >>--- a/filters/syntax-highlighting.sh
> >>+++ b/filters/syntax-highlighting.sh
> >>@@ -42,5 +42,23 @@ declare EXTENSION="${BASENAME##*.}"
> >> # map Makefile and Makefile.* to .mk
> >> [ "${BASENAME%%.*}" == "Makefile" ]&& EXTENSION=mk
> >>
> >>-# the sed with is a workaround for empty lines getting filtered out
> >>-exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null | sed -r 's/^[[:space:]]*$/\ /'
> >>+# get highlight version
> >>+declare regex='^[[:space:]]*highlight[[:space:]]+version[[:space:]]+([[:digit:]]+).*'
> >>+declare -i highlightVersion=$(highlight --version | grep -E "${regex}" | sed -r "s/${regex}/\1/")
> >>+
> >>+if [[ ${highlightVersion} -le 2 ]]; then
> >>+ # for highlight<= 2.x
> >>+
> >>+ # the sed with is a workaround for empty lines getting filtered out
> >>+ exec highlight --force -f -I -X -S $EXTENSION 2>/dev/null | sed -r 's/^[[:space:]]*$/\ /'
> >>+else
> >>+ # for other highlight versions
> >>+
> >>+ # workaround for --force bug:
> >>+ # set to plain text when highlight doesn't know the format
> >>+ echo "test" | highlight -f -I -O xhtml -S $EXTENSION&>/dev/null
> >>+ [ ${?} -ne 0 ]&& EXTENSION="txt"
> >>+
> >>+ # the sed with is a workaround for empty lines getting filtered out
> >>+ exec highlight -f -I -O xhtml -S $EXTENSION 2>/dev/null | sed -r 's/^[[:space:]]*$/\ /'
> >>+fi
> >
> >Good to know that this is broken, but your solution seems like a hack
> >without any explanation... Could you elaborate why this is needed and
> >why this is the proper way to fix this regression, please?
> >
>
> ok, thought it was clear.
>
> On CentOS 6.2 (use highlight from EPEL), when highlight doesn't know
> about an EXTENSION, it outputs a lua error and _no_ text, even when
> the --force option is used.
Ok, so this is something that can be reverted as soon as the bug in
highlight(1) is fixed. It probably makes sense to mention this in the
commit message :)
You should also try to report this bug upstream (unless you did already)
and add a link to the Red Hat bug report, since this is unlikely to be a
packaging bug...
>
>
> see https://bugzilla.redhat.com/show_bug.cgi?id=795567
>
> --
> Ferry Huberts
next prev parent reply other threads:[~2012-02-21 14:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-21 12:13 [PATCH v2 1/3] highlight: add workaround for empty lines getting filtered out mailings
2012-02-21 12:13 ` [PATCH v2 2/3] highlight: declare variables mailings
2012-02-21 13:23 ` cgit
2012-02-21 12:13 ` [PATCH v2 3/3] highlight: fix syntax highlighting for program versions > 2 mailings
2012-02-21 13:27 ` cgit
2012-02-21 13:47 ` mailings
2012-02-21 14:21 ` cgit [this message]
2012-02-21 13:16 ` [PATCH v2 1/3] highlight: add workaround for empty lines getting filtered out cgit
2012-02-21 13:45 ` mailings
2012-02-21 14:23 ` cgit
2012-02-21 15:21 ` mailings
2012-02-21 18:41 ` mailings
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=20120221142156.GA28585@blizzard \
--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).