60daa966 |
1 | /* -*- c -*- |
2 | * Name: halibut |
3 | * Description: Halibut document formatter. |
4 | * Author: Simon Tatham <anakin@pobox.com> |
5 | */ |
6 | |
7 | state halibut_paragraph extends Highlight |
8 | { |
9 | /^[[:space:]]*$/ { |
10 | language_print($0); |
11 | return; |
12 | } |
13 | } |
14 | |
15 | state halibut_nested_braces extends Highlight |
16 | { |
17 | BEGIN { |
18 | nestlevel = 1; |
19 | } |
20 | |
21 | /{/ { |
22 | language_print($0); |
23 | nestlevel++; |
24 | } |
25 | |
26 | /}/ { |
27 | language_print($0); |
28 | nestlevel--; |
29 | if (nestlevel == 0) |
30 | return; |
31 | } |
32 | } |
33 | |
34 | state halibut extends HighlightEntry |
35 | { |
36 | /* one-non-letter commands */ |
37 | /\\\\[-\\\\_{}.]/ { |
38 | keyword_face(true); |
39 | language_print($0); |
40 | keyword_face(false); |
41 | } |
42 | |
43 | /* code paragraphs */ |
44 | /^\\\\c / { |
45 | keyword_face(true); |
46 | language_print($0); |
47 | keyword_face(false); |
48 | string_face(true); |
49 | call(eat_one_line); |
50 | string_face(false); |
51 | } |
52 | |
53 | /* emphasis in code paragraphs */ |
54 | /^\\\\e / { |
55 | keyword_face(true); |
56 | language_print($0); |
57 | keyword_face(false); |
58 | builtin_face(true); |
59 | call(eat_one_line); |
60 | builtin_face(false); |
61 | } |
62 | |
63 | /* \uXXXX Unicode commands */ |
64 | /\\\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]/ { |
65 | keyword_face(true); |
66 | language_print($0); |
67 | keyword_face(false); |
68 | } |
69 | |
70 | /* multi letter commands */ |
71 | /\\\\[0-9a-tv-zA-Z][0-9a-zA-Z]*/ { |
72 | keyword_face(true); |
73 | language_print($0); |
74 | keyword_face(false); |
75 | } |
76 | |
77 | /* paragraph-type comments */ |
78 | /\\\\#/ { |
79 | comment_face(true); |
80 | language_print($0); |
81 | call(halibut_paragraph); |
82 | comment_face(false); |
83 | } |
84 | |
85 | /* intra-paragraph type comments */ |
86 | /\\\\#{/ { |
87 | comment_face(true); |
88 | language_print($0); |
89 | call(halibut_nested_braces); |
90 | comment_face(false); |
91 | } |
92 | |
93 | /* I want to have braces highlighted; they're *special* */ |
94 | /[{}]/ { |
95 | keyword_face(true); |
96 | language_print($0); |
97 | keyword_face(false); |
98 | } |
99 | } |