File: halibut.st

package info (click to toggle)
halibut 1.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,692 kB
  • ctags: 2,186
  • sloc: ansic: 53,839; makefile: 281; perl: 162; sh: 27
file content (99 lines) | stat: -rw-r--r-- 1,741 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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);
    }
}