Halibut highlighting mode for GNU enscript. This allows our ViewCVS
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 8 Dec 2004 17:58:17 +0000 (17:58 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 8 Dec 2004 17:58:17 +0000 (17:58 +0000)
installation to syntax-highlight the numerous .but files kicking
around the Subversion repository.

git-svn-id: svn://svn.tartarus.org/sgt/halibut@4962 cda61777-01e9-0310-a592-d414129be87e

misc/halibut.st [new file with mode: 0644]

diff --git a/misc/halibut.st b/misc/halibut.st
new file mode 100644 (file)
index 0000000..2f9fb54
--- /dev/null
@@ -0,0 +1,99 @@
+/* -*- c -*-
+ * Name: halibut
+ * Description: Halibut document formatter.
+ * Author: Simon Tatham <anakin@pobox.com>
+ */
+
+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);
+    }
+}