source: node_modules/refractor/lang/rest.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

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