krz/orgo
Lightning fast org-mode static site generator.
clone: git clone https://gitbay.org/krz/orgo.git
v0.22.0: syntaxes/Org.sublime-syntax · raw
1%YAML 1.2
2---
3# Org mode, for syntect. syntect bundles no Org definition, which is a conspicuous gap in
4# a tool whose users write about org — every `#+BEGIN_SRC org` block in the documentation
5# needs it.
6#
7# This highlights org as *source text you are reading about*, which is a different job
8# from parsing it: orgo's own parser (src/parser.rs) is what turns org into a
9# document. Where the two could disagree, this one stays conservative — a highlighter
10# that colours something wrongly is a cosmetic bug, and one that swallows a line is not.
11name: Org
12file_extensions: [org]
13scope: text.org
14
15contexts:
16 main:
17 - include: headings
18 - include: blocks
19 - include: keywords
20 - include: comments
21 - include: lists
22 - include: tables
23 - include: inline
24
25 headings:
26 # The whole line is the heading; TODO keyword, priority and tags are picked out
27 # within it.
28 - match: '^(\*+)\s'
29 captures:
30 1: punctuation.definition.heading.org
31 push:
32 - meta_scope: markup.heading.org
33 - match: $\n?
34 pop: true
35 - match: '\b(TODO|NEXT|WAITING|STARTED|DONE|CANCELLED|CANCELED)\b'
36 scope: keyword.other.todo.org
37 - match: '\[#[A-Z]\]'
38 scope: constant.other.priority.org
39 - match: '(:[A-Za-z0-9_@#%:]+:)\s*$'
40 scope: entity.name.tag.org
41 - include: inline
42
43 blocks:
44 # A source block delegates nothing: the inner language is not embedded, because the
45 # point here is reading org, not rendering the code inside it.
46 - match: '^\s*(#\+(?i:BEGIN_SRC|BEGIN_EXAMPLE|BEGIN_QUOTE|BEGIN_CENTER|BEGIN_EXPORT|BEGIN_VERSE|BEGIN_COMMENT))(.*)$'
47 captures:
48 1: keyword.control.block.begin.org
49 2: variable.parameter.org
50 push:
51 - meta_scope: markup.raw.block.org
52 - match: '^\s*(#\+(?i:END_\w+))\s*$'
53 captures:
54 1: keyword.control.block.end.org
55 pop: true
56
57 keywords:
58 # #+TITLE:, #+DATE:, #+SLUG: and friends — the metadata at the top of a file.
59 - match: '^\s*(#\+[A-Za-z_]+:)(.*)$'
60 captures:
61 1: keyword.other.keyword.org
62 2: string.unquoted.org
63
64 comments:
65 # `#` followed by a space. `#+` is a keyword and is matched above.
66 - match: '^\s*#\s.*$'
67 scope: comment.line.org
68
69 lists:
70 - match: '^\s*([-+*]|\d+[.)])\s'
71 scope: punctuation.definition.list.org
72 - match: '\[[ xX-]\]'
73 scope: constant.language.checkbox.org
74
75 tables:
76 - match: '^\s*\|.*$'
77 scope: markup.other.table.org
78
79 inline:
80 - include: links
81 - include: timestamps
82 - match: '\[fn:[^\]]*\]'
83 scope: markup.other.footnote.org
84 # Verbatim and code carry no nested markup, so they come first.
85 - match: '=[^\s=][^=]*='
86 scope: markup.raw.inline.org
87 - match: '~[^\s~][^~]*~'
88 scope: markup.raw.inline.org
89 - match: '\*[^\s*][^*]*\*'
90 scope: markup.bold.org
91 - match: '/[^\s/][^/]*/'
92 scope: markup.italic.org
93 - match: '_[^\s_][^_]*_'
94 scope: markup.underline.org
95 - match: '\+[^\s+][^+]*\+'
96 scope: markup.strikethrough.org
97
98 links:
99 - match: '(\[\[)([^\]]*)(\])'
100 captures:
101 1: punctuation.definition.link.org
102 2: markup.underline.link.org
103 3: punctuation.definition.link.org
104 push:
105 - match: '(\[)([^\]]*)(\]\])'
106 captures:
107 1: punctuation.definition.link.org
108 2: string.other.link.title.org
109 3: punctuation.definition.link.org
110 pop: true
111 - match: '\]'
112 scope: punctuation.definition.link.org
113 pop: true
114 - match: ''
115 pop: true
116
117 timestamps:
118 - match: '[<\[]\d{4}-\d{2}-\d{2}[^>\]]*[>\]]'
119 scope: constant.other.timestamp.org