Add syntax highlighting.
[ibg.git] / tools / transcript.py
diff --git a/tools/transcript.py b/tools/transcript.py
new file mode 100644 (file)
index 0000000..8fe45ce
--- /dev/null
@@ -0,0 +1,29 @@
+"""
+IF transcript syntax highlighting.
+"""
+
+import re
+
+from pygments.lexer import RegexLexer
+from pygments.token import Generic, Text
+
+class TranscriptLexer(RegexLexer):
+    """
+    IF transcript lexer.
+    """
+
+    name = 'Interactive Fiction transcript'
+    aliases = ['transcript']
+    filenames = ['*.scr']
+    mimetypes = ['text/x-scr', 'application/x-scr']
+
+    tokens = {
+        'root': [
+            (r'\n', Text),
+            (r'^[^>].*', Text),
+            (r'^>', Text, 'command'),
+        ],
+        'command': [
+            (r'.*', Generic.Strong, '#pop'),
+        ],
+    }