Small change to getopt stuff
[enscript.git] / states / hl / rfc.st
1 /**
2  * Name: rfc
3  * Description: RFC and Internet Draft reformatter.
4  *
5  *              Some RFCs and Internet Drafts are broken in such a way
6  *              that there is no linefeed character separating the
7  *              pages.  These documents are really pain to print
8  *              because you have to know the exact page height.  The
9  *              `rfc' highlighting state fixes these broken documents
10  *              by removing all unnecessary blank lines from the page
11  *              breaks and by separating the pages with a formfeed
12  *              character.  This style also highlights the MUST, MUST
13  *              NOT, REQUIRED SHALL, SHALL NOT, SHOULD, SHOULD NOT,
14  *              RECOMMENDED, MAY, and OPTIONAL keywords, described by
15  *              the RFC 2119.
16  *
17  * Author: Markku Rossi <mtr@iki.fi>
18  */
19
20 state rfc_page_separator_garbage extends Highlight
21 {
22   /^[ \t\f\r]*\n/ {
23     /* Skip all whitespace lines. */
24   }
25   /./ {
26     /* Print the correct separator line. */
27     language_print("\f\n");
28     language_print($0);
29     return;
30   }
31 }
32
33 state rfc extends HighlightEntry
34 {
35   /* Find the page separators and skip all whitespace lines after that. */
36   /\[[Pp]age[ \t]+[0-9]+[ \t]*\]\n/ {
37     language_print($0);
38     call(rfc_page_separator_garbage);
39   }
40   /* Highlight the keywords, described by the RFC 2119.
41      (build-re '(MUST NOT REQUIRED SHALL SHOULD RECOMMENDED MAY OPTIONAL))
42    */
43   /\b(M(AY|UST)|NOT|OPTIONAL|RE(COMMENDED|QUIRED)|SH(ALL|OULD))\b/ {
44     highlight_face(true);
45     language_print($0);
46     highlight_face(false);
47   }
48 }
49
50 \f
51 /*
52 Local variables:
53 mode: c
54 End:
55 */