Repository navigation
Expand file tree
/
Copy pathRTF.sublime-syntax
More file actions
73 lines (68 loc) · 2.66 KB
/
Copy pathRTF.sublime-syntax
File metadata and controls
73 lines (68 loc) · 2.66 KB
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
%YAML 1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
# http://www.biblioscape.com/rtf15_spec.htm
file_extensions:
- rtf
first_line_match: '^{\\rtf'
scope: text.rtf # Note that scopes are currently set for best syntax highlighting, not for semantic accuracy
contexts:
main:
- match: '({)(\\rtf)(\d?)'
captures:
1: punctuation.section.document.begin.rtf
2: support.function.rtf
3: constant.numeric.rtf
set: root
- match: '(?=.)' # RTF snippet
set: rtf_snippet
rtf_snippet:
- include: rtf
- match: '}'
scope: invalid.illegal.stray-bracket-end.rtf
rtf:
- match: '\\\\'
scope: constant.character.escape.rtf
- match: '\\[{}]'
scope: constant.character.escape.rtf
- match: '\\(?:\*|~|-|_|:|\|)'
scope: constant.language.rtf # control symbol
- match: \\'\h{2}
scope: constant.character.entity.rtf
- match: '(\\fldinst\s)\s*(\w+)\s+("[^"]*")'
captures:
1: keyword.control.rtf
2: support.constant.rtf
3: string.quoted.double.rtf
- match: '(\\bkmk(?:start|end)\s)\s*(\w+)'
captures:
1: storage.type.rtf
2: entity.name.bookmark.rtf meta.toc-list.bookmark.rtf # bookmark name will show up in Goto Symbol
- match: '\\([a-z]+)(-?\d+)?(\s?)' # control words are lowercase and can have an optional numeric parameter, and, if followed by a space, that space becomes part of the control word
captures:
0: keyword.control.rtf
2: constant.numeric.rtf
- match: '\\$\n?' # A carriage return (character value 13) or linefeed (character value 10) will be treated as a \par control word if the character is preceded by a backslash.
scope: invalid.deprecated.keyword.control.rtf
- match: '\\' #'\\(?!$|\})'
scope: invalid.illegal.unescaped-backslash.rtf
- match: '{'
scope: punctuation.section.group.begin.rtf
push: inside_group
root:
- meta_content_scope: meta.document.body.rtf
- match: '}'
scope: punctuation.section.document.end.rtf
set: expect_eof # stop highlighting after the end of document closing brace to clearly show where the final closing bracket is when there is additional unexpected content
- include: rtf
inside_group:
- match: '}'
scope: punctuation.section.group.end.rtf
pop: true
- match: ';'
scope: punctuation.separator.rtf
- include: rtf
expect_eof:
- match: '\S'
push:
- meta_scope: invalid.illegal.unexpected-content-at-end-of-document.rtf text.plain # anything other than whitespace after the closing brace that marks the end of the document will be ignored by RTF software, so mark it as invalid