Commit | Line | Data |
---|---|---|
20d1407b TD |
1 | define(["prism/prism"], function () { |
2 | Prism.languages.rest = { | |
3 | 'table': [ | |
4 | { | |
5 | pattern: /(\s*)(?:\+[=-]+)+\+(?:\r?\n|\r)(?:\1(?:[+|].+)+[+|](?:\r?\n|\r))+\1(?:\+[=-]+)+\+/, | |
6 | lookbehind: true, | |
7 | inside: { | |
8 | 'punctuation': /\||(?:\+[=-]+)+\+/ | |
9 | } | |
10 | }, | |
11 | { | |
12 | pattern: /(\s*)(?:=+ +)+=+(?:(?:\r?\n|\r)\1.+)+(?:\r?\n|\r)\1(?:=+ +)+=+(?=(?:\r?\n|\r){2}|\s*$)/, | |
13 | lookbehind: true, | |
14 | inside: { | |
15 | 'punctuation': /[=-]+/ | |
16 | } | |
17 | } | |
18 | ], | |
19 | ||
20 | // Directive-like patterns | |
21 | ||
22 | 'substitution-def': { | |
23 | pattern: /(^\s*\.\. )\|(?:[^|\s](?:[^|]*[^|\s])?)\| [^:]+::/m, | |
24 | lookbehind: true, | |
25 | inside: { | |
26 | 'substitution': { | |
27 | pattern: /^\|(?:[^|\s]|[^|\s][^|]*[^|\s])\|/, | |
28 | alias: 'attr-value', | |
29 | inside: { | |
30 | 'punctuation': /^\||\|$/ | |
31 | } | |
32 | }, | |
33 | 'directive': { | |
34 | pattern: /( +)[^:]+::/, | |
35 | lookbehind: true, | |
36 | alias: 'function', | |
37 | inside: { | |
38 | 'punctuation': /::$/ | |
39 | } | |
40 | } | |
41 | } | |
42 | }, | |
43 | 'link-target': [ | |
44 | { | |
45 | pattern: /(^\s*\.\. )\[[^\]]+\]/m, | |
46 | lookbehind: true, | |
47 | alias: 'string', | |
48 | inside: { | |
49 | 'punctuation': /^\[|\]$/ | |
50 | } | |
51 | }, | |
52 | { | |
53 | pattern: /(^\s*\.\. )_(?:`[^`]+`|(?:[^:\\]|\\.)+):/m, | |
54 | lookbehind: true, | |
55 | alias: 'string', | |
56 | inside: { | |
57 | 'punctuation': /^_|:$/ | |
58 | } | |
59 | } | |
60 | ], | |
61 | 'directive': { | |
62 | pattern: /(^\s*\.\. )[^:]+::/m, | |
63 | lookbehind: true, | |
64 | alias: 'function', | |
65 | inside: { | |
66 | 'punctuation': /::$/ | |
67 | } | |
68 | }, | |
69 | 'comment': { | |
70 | // The two alternatives try to prevent highlighting of blank comments | |
71 | pattern: /(^\s*\.\.)(?:(?: .+)?(?:(?:\r?\n|\r).+)+| .+)(?=(?:\r?\n|\r){2}|$)/m, | |
72 | lookbehind: true | |
73 | }, | |
74 | ||
75 | 'title': [ | |
76 | // Overlined and underlined | |
77 | { | |
78 | pattern: /^(([!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~])\2+)(?:\r?\n|\r).+(?:\r?\n|\r)\1$/m, | |
79 | inside: { | |
80 | 'punctuation': /^[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~]+|[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~]+$/, | |
81 | 'important': /.+/ | |
82 | } | |
83 | }, | |
84 | ||
85 | // Underlined only | |
86 | { | |
87 | pattern: /(^|(?:\r?\n|\r){2}).+(?:\r?\n|\r)([!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~])\2+(?=\r?\n|\r|$)/, | |
88 | lookbehind: true, | |
89 | inside: { | |
90 | 'punctuation': /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~]+$/, | |
91 | 'important': /.+/ | |
92 | } | |
93 | } | |
94 | ], | |
95 | 'hr': { | |
96 | pattern: /((?:\r?\n|\r){2})([!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~])\2{3,}(?=(?:\r?\n|\r){2})/, | |
97 | lookbehind: true, | |
98 | alias: 'punctuation' | |
99 | }, | |
100 | 'field': { | |
101 | pattern: /(^\s*):[^:\r\n]+:(?= )/m, | |
102 | lookbehind: true, | |
103 | alias: 'attr-name' | |
104 | }, | |
105 | 'command-line-option': { | |
106 | pattern: /(^\s*)(?:[+-][a-z\d]|(?:--|\/)[a-z\d-]+)(?:[ =](?:[a-z][\w-]*|<[^<>]+>))?(?:, (?:[+-][a-z\d]|(?:--|\/)[a-z\d-]+)(?:[ =](?:[a-z][\w-]*|<[^<>]+>))?)*(?=(?:\r?\n|\r)? {2,}\S)/im, | |
107 | lookbehind: true, | |
108 | alias: 'symbol' | |
109 | }, | |
110 | 'literal-block': { | |
111 | pattern: /::(?:\r?\n|\r){2}([ \t]+).+(?:(?:\r?\n|\r)\1.+)*/, | |
112 | inside: { | |
113 | 'literal-block-punctuation': { | |
114 | pattern: /^::/, | |
115 | alias: 'punctuation' | |
116 | } | |
117 | } | |
118 | }, | |
119 | 'quoted-literal-block': { | |
120 | pattern: /::(?:\r?\n|\r){2}([!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~]).*(?:(?:\r?\n|\r)\1.*)*/, | |
121 | inside: { | |
122 | 'literal-block-punctuation': { | |
123 | pattern: /^(?:::|([!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~])\1*)/m, | |
124 | alias: 'punctuation' | |
125 | } | |
126 | } | |
127 | }, | |
128 | 'list-bullet': { | |
129 | pattern: /(^\s*)(?:[*+\-•‣⁃]|\(?(?:\d+|[a-z]|[ivxdclm]+)\)|(?:\d+|[a-z]|[ivxdclm]+)\.)(?= )/im, | |
130 | lookbehind: true, | |
131 | alias: 'punctuation' | |
132 | }, | |
133 | 'doctest-block': { | |
134 | pattern: /(^\s*)>>> .+(?:(?:\r?\n|\r).+)*/m, | |
135 | lookbehind: true, | |
136 | inside: { | |
137 | 'punctuation': /^>>>/ | |
138 | } | |
139 | }, | |
140 | ||
141 | 'inline': [ | |
142 | { | |
143 | pattern: /(^|[\s\-:\/'"<(\[{])(?::[^:]+:`.*?`|`.*?`:[^:]+:|(\*\*?|``?|\|)(?!\s).*?[^\s]\2(?=[\s\-.,:;!?\\\/'")\]}]|$))/m, | |
144 | lookbehind: true, | |
145 | inside: { | |
146 | 'bold': { | |
147 | pattern: /(^\*\*).+(?=\*\*$)/, | |
148 | lookbehind: true | |
149 | }, | |
150 | 'italic': { | |
151 | pattern: /(^\*).+(?=\*$)/, | |
152 | lookbehind: true | |
153 | }, | |
154 | 'inline-literal': { | |
155 | pattern: /(^``).+(?=``$)/, | |
156 | lookbehind: true, | |
157 | alias: 'symbol' | |
158 | }, | |
159 | 'role': { | |
160 | pattern: /^:[^:]+:|:[^:]+:$/, | |
161 | alias: 'function', | |
162 | inside: { | |
163 | 'punctuation': /^:|:$/ | |
164 | } | |
165 | }, | |
166 | 'interpreted-text': { | |
167 | pattern: /(^`).+(?=`$)/, | |
168 | lookbehind: true, | |
169 | alias: 'attr-value' | |
170 | }, | |
171 | 'substitution': { | |
172 | pattern: /(^\|).+(?=\|$)/, | |
173 | lookbehind: true, | |
174 | alias: 'attr-value' | |
175 | }, | |
176 | 'punctuation': /\*\*?|``?|\|/ | |
177 | } | |
178 | } | |
179 | ], | |
180 | ||
181 | 'link': [ | |
182 | { | |
183 | pattern: /\[[^\]]+\]_(?=[\s\-.,:;!?\\\/'")\]}]|$)/, | |
184 | alias: 'string', | |
185 | inside: { | |
186 | 'punctuation': /^\[|\]_$/ | |
187 | } | |
188 | }, | |
189 | { | |
a59d0557 | 190 | pattern: /(?:\b[a-z\d]+(?:[_.:+][a-z\d]+)*_?_|`[^`]+`_?_|_`[^`]+`)(?=[\s\-.,:;!?\\\/'")\]}]|$)/i, |
20d1407b TD |
191 | alias: 'string', |
192 | inside: { | |
193 | 'punctuation': /^_?`|`$|`?_?_$/ | |
194 | } | |
195 | } | |
196 | ], | |
197 | ||
198 | // Line block start, | |
199 | // quote attribution, | |
200 | // explicit markup start, | |
201 | // and anonymous hyperlink target shortcut (__) | |
202 | 'punctuation': { | |
203 | pattern: /(^\s*)(?:\|(?= |$)|(?:---?|—|\.\.|__)(?= )|\.\.$)/m, | |
204 | lookbehind: true | |
205 | } | |
206 | }; | |
a59d0557 | 207 | |
20d1407b | 208 | return Prism; }) |