From f05862b9fa9772942ab9cb594d8c42e6a5576b11 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Wed, 8 Dec 2004 17:58:17 +0000 Subject: Halibut highlighting mode for GNU enscript. This allows our ViewCVS installation to syntax-highlight the numerous .but files kicking around the Subversion repository. [originally from svn r4962] --- misc/halibut.st | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 misc/halibut.st (limited to 'misc') diff --git a/misc/halibut.st b/misc/halibut.st new file mode 100644 index 0000000..2f9fb54 --- /dev/null +++ b/misc/halibut.st @@ -0,0 +1,99 @@ +/* -*- c -*- + * Name: halibut + * Description: Halibut document formatter. + * Author: Simon Tatham + */ + +state halibut_paragraph extends Highlight +{ + /^[[:space:]]*$/ { + language_print($0); + return; + } +} + +state halibut_nested_braces extends Highlight +{ + BEGIN { + nestlevel = 1; + } + + /{/ { + language_print($0); + nestlevel++; + } + + /}/ { + language_print($0); + nestlevel--; + if (nestlevel == 0) + return; + } +} + +state halibut extends HighlightEntry +{ + /* one-non-letter commands */ + /\\\\[-\\\\_{}.]/ { + keyword_face(true); + language_print($0); + keyword_face(false); + } + + /* code paragraphs */ + /^\\\\c / { + keyword_face(true); + language_print($0); + keyword_face(false); + string_face(true); + call(eat_one_line); + string_face(false); + } + + /* emphasis in code paragraphs */ + /^\\\\e / { + keyword_face(true); + language_print($0); + keyword_face(false); + builtin_face(true); + call(eat_one_line); + builtin_face(false); + } + + /* \uXXXX Unicode commands */ + /\\\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]/ { + keyword_face(true); + language_print($0); + keyword_face(false); + } + + /* multi letter commands */ + /\\\\[0-9a-tv-zA-Z][0-9a-zA-Z]*/ { + keyword_face(true); + language_print($0); + keyword_face(false); + } + + /* paragraph-type comments */ + /\\\\#/ { + comment_face(true); + language_print($0); + call(halibut_paragraph); + comment_face(false); + } + + /* intra-paragraph type comments */ + /\\\\#{/ { + comment_face(true); + language_print($0); + call(halibut_nested_braces); + comment_face(false); + } + + /* I want to have braces highlighted; they're *special* */ + /[{}]/ { + keyword_face(true); + language_print($0); + keyword_face(false); + } +} -- cgit v1.1