Add chapter 5.
[ibg.git] / tools / transcript.py
1 """
2 IF transcript syntax highlighting.
3 """
4
5 import re
6
7 from pygments.lexer import RegexLexer
8 from pygments.token import Generic, Text
9
10 class TranscriptLexer(RegexLexer):
11     """
12     IF transcript lexer.
13     """
14
15     name = 'Interactive Fiction transcript'
16     aliases = ['transcript']
17     filenames = ['*.scr']
18     mimetypes = ['text/x-scr', 'application/x-scr']
19
20     tokens = {
21         'root': [
22             (r'\n', Text),
23             (r'^[^>].*', Text),
24             (r'^>', Text, 'command'),
25         ],
26         'command': [
27             (r'.*', Generic.Strong, '#pop'),
28         ],
29     }