1 | (function (Prism) {
|
2 |
|
3 | var attributes = {
|
4 | pattern: /(^[ \t]*)\[(?!\[)(?:(["'$`])(?:(?!\2)[^\\]|\\.)*\2|\[(?:[^\]\\]|\\.)*\]|[^\]\\]|\\.)*\]/m,
|
5 | lookbehind: true,
|
6 | inside: {
|
7 | 'quoted': {
|
8 | pattern: /([$`])(?:(?!\1)[^\\]|\\.)*\1/,
|
9 | inside: {
|
10 | 'punctuation': /^[$`]|[$`]$/
|
11 | }
|
12 | },
|
13 | 'interpreted': {
|
14 | pattern: /'(?:[^'\\]|\\.)*'/,
|
15 | inside: {
|
16 | 'punctuation': /^'|'$/
|
17 |
|
18 | }
|
19 | },
|
20 | 'string': /"(?:[^"\\]|\\.)*"/,
|
21 | 'variable': /\w+(?==)/,
|
22 | 'punctuation': /^\[|\]$|,/,
|
23 | 'operator': /=/,
|
24 |
|
25 | 'attr-value': /(?!^\s+$).+/
|
26 | }
|
27 | };
|
28 | Prism.languages.asciidoc = {
|
29 | 'comment-block': {
|
30 | pattern: /^(\/{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1/m,
|
31 | alias: 'comment'
|
32 | },
|
33 | 'table': {
|
34 | pattern: /^\|={3,}(?:(?:\r?\n|\r).*)*?(?:\r?\n|\r)\|={3,}$/m,
|
35 | inside: {
|
36 | 'specifiers': {
|
37 | pattern: /(?!\|)(?:(?:(?:\d+(?:\.\d+)?|\.\d+)[+*])?(?:[<^>](?:\.[<^>])?|\.[<^>])?[a-z]*)(?=\|)/,
|
38 | alias: 'attr-value'
|
39 | },
|
40 | 'punctuation': {
|
41 | pattern: /(^|[^\\])[|!]=*/,
|
42 | lookbehind: true
|
43 | }
|
44 |
|
45 | }
|
46 | },
|
47 |
|
48 | 'passthrough-block': {
|
49 | pattern: /^(\+{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m,
|
50 | inside: {
|
51 | 'punctuation': /^\++|\++$/
|
52 |
|
53 | }
|
54 | },
|
55 |
|
56 | 'literal-block': {
|
57 | pattern: /^(-{4,}|\.{4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m,
|
58 | inside: {
|
59 | 'punctuation': /^(?:-+|\.+)|(?:-+|\.+)$/
|
60 |
|
61 | }
|
62 | },
|
63 |
|
64 | 'other-block': {
|
65 | pattern: /^(--|\*{4,}|_{4,}|={4,})(?:\r?\n|\r)(?:[\s\S]*(?:\r?\n|\r))??\1$/m,
|
66 | inside: {
|
67 | 'punctuation': /^(?:-+|\*+|_+|=+)|(?:-+|\*+|_+|=+)$/
|
68 |
|
69 | }
|
70 | },
|
71 |
|
72 |
|
73 | 'list-punctuation': {
|
74 | pattern: /(^[ \t]*)(?:-|\*{1,5}|\.{1,5}|(?:[a-z]|\d+)\.|[xvi]+\))(?= )/im,
|
75 | lookbehind: true,
|
76 | alias: 'punctuation'
|
77 | },
|
78 | 'list-label': {
|
79 | pattern: /(^[ \t]*)[a-z\d].+(?::{2,4}|;;)(?=\s)/im,
|
80 | lookbehind: true,
|
81 | alias: 'symbol'
|
82 | },
|
83 | 'indented-block': {
|
84 | pattern: /((\r?\n|\r)\2)([ \t]+)\S.*(?:(?:\r?\n|\r)\3.+)*(?=\2{2}|$)/,
|
85 | lookbehind: true
|
86 | },
|
87 |
|
88 | 'comment': /^\/\/.*/m,
|
89 | 'title': {
|
90 | pattern: /^.+(?:\r?\n|\r)(?:={3,}|-{3,}|~{3,}|\^{3,}|\+{3,})$|^={1,5} +.+|^\.(?![\s.]).*/m,
|
91 | alias: 'important',
|
92 | inside: {
|
93 | 'punctuation': /^(?:\.|=+)|(?:=+|-+|~+|\^+|\++)$/
|
94 |
|
95 | }
|
96 | },
|
97 | 'attribute-entry': {
|
98 | pattern: /^:[^:\r\n]+:(?: .*?(?: \+(?:\r?\n|\r).*?)*)?$/m,
|
99 | alias: 'tag'
|
100 | },
|
101 | 'attributes': attributes,
|
102 | 'hr': {
|
103 | pattern: /^'{3,}$/m,
|
104 | alias: 'punctuation'
|
105 | },
|
106 | 'page-break': {
|
107 | pattern: /^<{3,}$/m,
|
108 | alias: 'punctuation'
|
109 | },
|
110 | 'admonition': {
|
111 | pattern: /^(?:TIP|NOTE|IMPORTANT|WARNING|CAUTION):/m,
|
112 | alias: 'keyword'
|
113 | },
|
114 | 'callout': [
|
115 | {
|
116 | pattern: /(^[ \t]*)<?\d*>/m,
|
117 | lookbehind: true,
|
118 | alias: 'symbol'
|
119 | },
|
120 | {
|
121 | pattern: /<\d+>/,
|
122 | alias: 'symbol'
|
123 | }
|
124 | ],
|
125 | 'macro': {
|
126 | pattern: /\b[a-z\d][a-z\d-]*::?(?:(?:\S+)??\[(?:[^\]\\"]|(["'])(?:(?!\1)[^\\]|\\.)*\1|\\.)*\])/,
|
127 | inside: {
|
128 | 'function': /^[a-z\d-]+(?=:)/,
|
129 | 'punctuation': /^::?/,
|
130 | 'attributes': {
|
131 | pattern: /(?:\[(?:[^\]\\"]|(["'])(?:(?!\1)[^\\]|\\.)*\1|\\.)*\])/,
|
132 | inside: attributes.inside
|
133 | }
|
134 | }
|
135 | },
|
136 | 'inline': {
|
137 | |
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 | pattern: /(^|[^\\])(?:(?:\B\[(?:[^\]\\"]|(["'])(?:(?!\2)[^\\]|\\.)*\2|\\.)*\])?(?:\b_(?!\s)(?: _|[^_\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: _|[^_\\\r\n]|\\.)+)*_\b|\B``(?!\s).+?(?:(?:\r?\n|\r).+?)*''\B|\B`(?!\s)(?: ['`]|.)+?(?:(?:\r?\n|\r)(?: ['`]|.)+?)*['`]\B|\B(['*+#])(?!\s)(?: \3|(?!\3)[^\\\r\n]|\\.)+(?:(?:\r?\n|\r)(?: \3|(?!\3)[^\\\r\n]|\\.)+)*\3\B)|(?:\[(?:[^\]\\"]|(["'])(?:(?!\4)[^\\]|\\.)*\4|\\.)*\])?(?:(__|\*\*|\+\+\+?|##|\$\$|[~^]).+?(?:(?:\r?\n|\r).+?)*\5|\{[^}\r\n]+\}|\[\[\[?.+?(?:(?:\r?\n|\r).+?)*\]?\]\]|<<.+?(?:(?:\r?\n|\r).+?)*>>|\(\(\(?.+?(?:(?:\r?\n|\r).+?)*\)?\)\)))/m,
|
152 | lookbehind: true,
|
153 | inside: {
|
154 | 'attributes': attributes,
|
155 | 'url': {
|
156 | pattern: /^(?:\[\[\[?.+?\]?\]\]|<<.+?>>)$/,
|
157 | inside: {
|
158 | 'punctuation': /^(?:\[\[\[?|<<)|(?:\]\]\]?|>>)$/
|
159 | }
|
160 | },
|
161 | 'attribute-ref': {
|
162 | pattern: /^\{.+\}$/,
|
163 | inside: {
|
164 | 'variable': {
|
165 | pattern: /(^\{)[a-z\d,+_-]+/,
|
166 | lookbehind: true
|
167 | },
|
168 | 'operator': /^[=?!#%@$]|!(?=[:}])/,
|
169 | 'punctuation': /^\{|\}$|::?/
|
170 | }
|
171 | },
|
172 | 'italic': {
|
173 | pattern: /^(['_])[\s\S]+\1$/,
|
174 | inside: {
|
175 | 'punctuation': /^(?:''?|__?)|(?:''?|__?)$/
|
176 | }
|
177 | },
|
178 | 'bold': {
|
179 | pattern: /^\*[\s\S]+\*$/,
|
180 | inside: {
|
181 | punctuation: /^\*\*?|\*\*?$/
|
182 | }
|
183 | },
|
184 | 'punctuation': /^(?:``?|\+{1,3}|##?|\$\$|[~^]|\(\(\(?)|(?:''?|\+{1,3}|##?|\$\$|[~^`]|\)?\)\))$/
|
185 | }
|
186 | },
|
187 | 'replacement': {
|
188 | pattern: /\((?:C|TM|R)\)/,
|
189 | alias: 'builtin'
|
190 | },
|
191 | 'entity': /&#?[\da-z]{1,8};/i,
|
192 | 'line-continuation': {
|
193 | pattern: /(^| )\+$/m,
|
194 | lookbehind: true,
|
195 | alias: 'punctuation'
|
196 | }
|
197 | };
|
198 |
|
199 |
|
200 |
|
201 |
|
202 | attributes.inside['interpreted'].inside.rest = {
|
203 | 'macro': Prism.languages.asciidoc['macro'],
|
204 | 'inline': Prism.languages.asciidoc['inline'],
|
205 | 'replacement': Prism.languages.asciidoc['replacement'],
|
206 | 'entity': Prism.languages.asciidoc['entity']
|
207 | };
|
208 |
|
209 | Prism.languages.asciidoc['passthrough-block'].inside.rest = {
|
210 | 'macro': Prism.languages.asciidoc['macro']
|
211 | };
|
212 |
|
213 | Prism.languages.asciidoc['literal-block'].inside.rest = {
|
214 | 'callout': Prism.languages.asciidoc['callout']
|
215 | };
|
216 |
|
217 | Prism.languages.asciidoc['table'].inside.rest = {
|
218 | 'comment-block': Prism.languages.asciidoc['comment-block'],
|
219 | 'passthrough-block': Prism.languages.asciidoc['passthrough-block'],
|
220 | 'literal-block': Prism.languages.asciidoc['literal-block'],
|
221 | 'other-block': Prism.languages.asciidoc['other-block'],
|
222 | 'list-punctuation': Prism.languages.asciidoc['list-punctuation'],
|
223 | 'indented-block': Prism.languages.asciidoc['indented-block'],
|
224 | 'comment': Prism.languages.asciidoc['comment'],
|
225 | 'title': Prism.languages.asciidoc['title'],
|
226 | 'attribute-entry': Prism.languages.asciidoc['attribute-entry'],
|
227 | 'attributes': Prism.languages.asciidoc['attributes'],
|
228 | 'hr': Prism.languages.asciidoc['hr'],
|
229 | 'page-break': Prism.languages.asciidoc['page-break'],
|
230 | 'admonition': Prism.languages.asciidoc['admonition'],
|
231 | 'list-label': Prism.languages.asciidoc['list-label'],
|
232 | 'callout': Prism.languages.asciidoc['callout'],
|
233 | 'macro': Prism.languages.asciidoc['macro'],
|
234 | 'inline': Prism.languages.asciidoc['inline'],
|
235 | 'replacement': Prism.languages.asciidoc['replacement'],
|
236 | 'entity': Prism.languages.asciidoc['entity'],
|
237 | 'line-continuation': Prism.languages.asciidoc['line-continuation']
|
238 | };
|
239 |
|
240 | Prism.languages.asciidoc['other-block'].inside.rest = {
|
241 | 'table': Prism.languages.asciidoc['table'],
|
242 | 'list-punctuation': Prism.languages.asciidoc['list-punctuation'],
|
243 | 'indented-block': Prism.languages.asciidoc['indented-block'],
|
244 | 'comment': Prism.languages.asciidoc['comment'],
|
245 | 'attribute-entry': Prism.languages.asciidoc['attribute-entry'],
|
246 | 'attributes': Prism.languages.asciidoc['attributes'],
|
247 | 'hr': Prism.languages.asciidoc['hr'],
|
248 | 'page-break': Prism.languages.asciidoc['page-break'],
|
249 | 'admonition': Prism.languages.asciidoc['admonition'],
|
250 | 'list-label': Prism.languages.asciidoc['list-label'],
|
251 | 'macro': Prism.languages.asciidoc['macro'],
|
252 | 'inline': Prism.languages.asciidoc['inline'],
|
253 | 'replacement': Prism.languages.asciidoc['replacement'],
|
254 | 'entity': Prism.languages.asciidoc['entity'],
|
255 | 'line-continuation': Prism.languages.asciidoc['line-continuation']
|
256 | };
|
257 |
|
258 | Prism.languages.asciidoc['title'].inside.rest = {
|
259 | 'macro': Prism.languages.asciidoc['macro'],
|
260 | 'inline': Prism.languages.asciidoc['inline'],
|
261 | 'replacement': Prism.languages.asciidoc['replacement'],
|
262 | 'entity': Prism.languages.asciidoc['entity']
|
263 | };
|
264 |
|
265 |
|
266 | Prism.hooks.add('wrap', function(env) {
|
267 | if (env.type === 'entity') {
|
268 | env.attributes['title'] = env.content.replace(/&/, '&');
|
269 | }
|
270 | });
|
271 | }(Prism)); |
\ | No newline at end of file |