@wdprlib/render 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2332 -2032
- package/dist/index.d.cts +15 -13
- package/dist/index.d.ts +15 -13
- package/dist/index.js +2336 -2036
- package/package.json +5 -3
- package/src/context/attributes.ts +14 -0
- package/src/context/bibliography.ts +109 -0
- package/src/context/counters.ts +51 -0
- package/src/context/image-urls.ts +31 -0
- package/src/context/index.ts +285 -0
- package/src/context/output.ts +17 -0
- package/src/context/page-urls.ts +81 -0
- package/src/context/style-slots.ts +29 -0
- package/src/context/urls.ts +2 -0
- package/src/elements/bibliography/block.ts +27 -0
- package/src/elements/bibliography/cite.ts +23 -0
- package/src/elements/bibliography/ids.ts +9 -0
- package/src/elements/bibliography/index.ts +9 -0
- package/src/elements/clear-float.ts +27 -0
- package/src/elements/code/contents.ts +18 -0
- package/src/elements/code/index.ts +29 -0
- package/src/elements/collapsible/index.ts +31 -0
- package/src/elements/collapsible/labels.ts +35 -0
- package/src/elements/collapsible/link.ts +11 -0
- package/src/elements/collapsible/sections.ts +39 -0
- package/src/elements/color.ts +32 -0
- package/src/elements/container/attributes.ts +28 -0
- package/src/elements/container/header.ts +27 -0
- package/src/elements/container/index.ts +35 -0
- package/src/elements/container/string-container.ts +40 -0
- package/src/elements/container/string-types.ts +63 -0
- package/src/elements/container/wrappers.ts +32 -0
- package/src/elements/date/format.ts +20 -0
- package/src/elements/date/index.ts +34 -0
- package/src/elements/date/output.ts +6 -0
- package/src/elements/embed/iframe.ts +8 -0
- package/src/elements/embed/index.ts +28 -0
- package/src/elements/embed/providers.ts +43 -0
- package/src/elements/embed/validation.ts +15 -0
- package/src/elements/embed-block/allowlist.ts +60 -0
- package/src/elements/embed-block/boolean-attributes.ts +38 -0
- package/src/elements/embed-block/iframe.ts +33 -0
- package/src/elements/embed-block/index.ts +31 -0
- package/src/elements/embed-block/sanitize-config.ts +22 -0
- package/src/elements/embed-block/sanitize.ts +44 -0
- package/src/elements/expr/branch.ts +29 -0
- package/src/elements/expr/index.ts +63 -0
- package/src/elements/expr/result.ts +19 -0
- package/src/elements/footnote/body.ts +11 -0
- package/src/elements/footnote/index.ts +35 -0
- package/src/elements/footnote/ref.ts +16 -0
- package/src/elements/html/attributes.ts +24 -0
- package/src/elements/html/index.ts +39 -0
- package/src/elements/html/url.ts +19 -0
- package/src/elements/iframe/attributes.ts +28 -0
- package/src/elements/iframe/index.ts +22 -0
- package/src/elements/iftags/condition.ts +42 -0
- package/src/elements/iftags/index.ts +39 -0
- package/src/elements/iftags/style-slot.ts +23 -0
- package/src/elements/iftags/tokens.ts +36 -0
- package/src/elements/image/alignment.ts +44 -0
- package/src/elements/image/attributes.ts +10 -0
- package/src/elements/image/img-attributes.ts +26 -0
- package/src/elements/image/index.ts +36 -0
- package/src/elements/image/link-href.ts +24 -0
- package/src/elements/image/link.ts +13 -0
- package/src/elements/image/source.ts +16 -0
- package/src/elements/include/index.ts +35 -0
- package/src/elements/include/missing.ts +15 -0
- package/src/elements/index.ts +35 -0
- package/src/elements/line-break.ts +22 -0
- package/src/elements/link/anchor-name.ts +6 -0
- package/src/elements/link/anchor.ts +27 -0
- package/src/elements/link/attributes.ts +47 -0
- package/src/elements/link/index.ts +26 -0
- package/src/elements/link/label.ts +23 -0
- package/src/elements/link/target.ts +20 -0
- package/src/elements/list/attributes.ts +19 -0
- package/src/elements/list/definition-list.ts +16 -0
- package/src/elements/list/index.ts +48 -0
- package/src/elements/list/item-rendering.ts +38 -0
- package/src/elements/list/items.ts +61 -0
- package/src/elements/list/no-marker.ts +53 -0
- package/src/elements/list/paragraphs.ts +34 -0
- package/src/elements/list/trim.ts +38 -0
- package/src/elements/math/block.ts +29 -0
- package/src/elements/math/equation-ref.ts +12 -0
- package/src/elements/math/index.ts +14 -0
- package/src/elements/math/inline.ts +19 -0
- package/src/elements/math/latex.ts +27 -0
- package/src/elements/math/source.ts +18 -0
- package/src/elements/module/backlinks.ts +29 -0
- package/src/elements/module/categories.ts +27 -0
- package/src/elements/module/empty-container.ts +10 -0
- package/src/elements/module/index.ts +65 -0
- package/src/elements/module/join-markup.ts +10 -0
- package/src/elements/module/join.ts +28 -0
- package/src/elements/module/listpages.ts +27 -0
- package/src/elements/module/listusers.ts +27 -0
- package/src/elements/module/page-tree.ts +27 -0
- package/src/elements/module/rate-markup.ts +10 -0
- package/src/elements/module/rate.ts +35 -0
- package/src/elements/module/unknown.ts +11 -0
- package/src/elements/tab-view/ids.ts +16 -0
- package/src/elements/tab-view/index.ts +31 -0
- package/src/elements/tab-view/navigation.ts +15 -0
- package/src/elements/tab-view/panels.ts +16 -0
- package/src/elements/table/attributes.ts +23 -0
- package/src/elements/table/cell-attributes.ts +62 -0
- package/src/elements/table/cell.ts +13 -0
- package/src/elements/table/index.ts +27 -0
- package/src/elements/text/email.ts +20 -0
- package/src/elements/text/index.ts +11 -0
- package/src/elements/text/plain.ts +11 -0
- package/src/elements/text/raw.ts +20 -0
- package/src/elements/toc/body.ts +12 -0
- package/src/elements/toc/entries.ts +34 -0
- package/src/elements/toc/frame.ts +27 -0
- package/src/elements/toc/index.ts +17 -0
- package/src/elements/toc/link.ts +26 -0
- package/src/elements/user/index.ts +40 -0
- package/src/elements/user/markup.ts +34 -0
- package/src/elements/user/resolve.ts +6 -0
- package/src/escape/attribute-allowlists.ts +101 -0
- package/src/escape/attributes.ts +62 -0
- package/src/escape/css-color-functions.ts +18 -0
- package/src/escape/css-colors.ts +183 -0
- package/src/escape/css-danger.ts +22 -0
- package/src/escape/css-normalize.ts +54 -0
- package/src/escape/css-style.ts +78 -0
- package/src/escape/css-urls.ts +76 -0
- package/src/escape/css.ts +4 -0
- package/src/escape/email.ts +22 -0
- package/src/escape/html.ts +68 -0
- package/src/escape/index.ts +15 -0
- package/src/escape/url.ts +18 -0
- package/src/hash.ts +62 -0
- package/src/index.ts +26 -0
- package/src/libs/highlighter/engine/end-pattern.ts +26 -0
- package/src/libs/highlighter/engine/html.ts +19 -0
- package/src/libs/highlighter/engine/index.ts +3 -0
- package/src/libs/highlighter/engine/keywords.ts +22 -0
- package/src/libs/highlighter/engine/parts.ts +36 -0
- package/src/libs/highlighter/engine/preprocess.ts +10 -0
- package/src/libs/highlighter/engine/render.ts +31 -0
- package/src/libs/highlighter/engine/token.ts +7 -0
- package/src/libs/highlighter/engine/tokenizer.ts +266 -0
- package/src/libs/highlighter/engine/utils.ts +38 -0
- package/src/libs/highlighter/index.ts +70 -0
- package/src/libs/highlighter/languages/cpp.ts +345 -0
- package/src/libs/highlighter/languages/css.ts +104 -0
- package/src/libs/highlighter/languages/diff.ts +154 -0
- package/src/libs/highlighter/languages/dtd.ts +99 -0
- package/src/libs/highlighter/languages/html.ts +59 -0
- package/src/libs/highlighter/languages/java.ts +251 -0
- package/src/libs/highlighter/languages/javascript.ts +213 -0
- package/src/libs/highlighter/languages/php.ts +433 -0
- package/src/libs/highlighter/languages/python.ts +308 -0
- package/src/libs/highlighter/languages/ruby.ts +360 -0
- package/src/libs/highlighter/languages/sql.ts +125 -0
- package/src/libs/highlighter/languages/xml.ts +68 -0
- package/src/libs/highlighter/types.ts +44 -0
- package/src/render/collected-styles.ts +22 -0
- package/src/render/dispatch.ts +181 -0
- package/src/render/index.ts +28 -0
- package/src/render/primitives.ts +17 -0
- package/src/render/style-tag.ts +6 -0
- package/src/render/style.ts +15 -0
- package/src/types.ts +144 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import type { LanguageDefinition } from "../types";
|
|
2
|
+
|
|
3
|
+
export const pythonLang: LanguageDefinition = {
|
|
4
|
+
language: "python",
|
|
5
|
+
defClass: "code",
|
|
6
|
+
regs: {
|
|
7
|
+
[-1]: /(''')|(""")|(")|(')|(\()|(\[)|([a-z_]\w*(?=\s*\())|([a-z_]\w*)|(((\d+|((\d*\.\d+)|(\d+\.\d*)))[eE][+-]?\d+))|(((\d*\.\d+)|(\d+\.\d*)|(\d+))j)|((\d*\.\d+)|(\d+\.\d*))|(\d+l?|\b0l?\b)|(0[xX][\da-f]+l?)|(0[0-7]+l?)|(#.+)/gi,
|
|
8
|
+
0: /(\\.)/gi,
|
|
9
|
+
1: /(\\.)/gi,
|
|
10
|
+
2: /(\\.)/gi,
|
|
11
|
+
3: /(\\.)/gi,
|
|
12
|
+
4: /(''')|(""")|(")|(')|(\()|(\[)|([a-z_]\w*(?=\s*\())|([a-z_]\w*)|(((\d+|((\d*\.\d+)|(\d+\.\d*)))[eE][+-]?\d+))|(((\d*\.\d+)|(\d+\.\d*)|(\d+))j)|((\d*\.\d+)|(\d+\.\d*))|(\d+l?|\b0l?\b)|(0[xX][\da-f]+l?)|(0[0-7]+l?)|(#.+)/gi,
|
|
13
|
+
5: /(''')|(""")|(")|(')|(\()|(\[)|([a-z_]\w*(?=\s*\())|([a-z_]\w*)|(((\d+|((\d*\.\d+)|(\d+\.\d*)))[eE][+-]?\d+))|(((\d*\.\d+)|(\d+\.\d*)|(\d+))j)|((\d*\.\d+)|(\d+\.\d*))|(\d+l?|\b0l?\b)|(0[xX][\da-f]+l?)|(0[0-7]+l?)|(#.+)/gi,
|
|
14
|
+
},
|
|
15
|
+
counts: {
|
|
16
|
+
[-1]: [0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 2, 0, 0, 0, 0],
|
|
17
|
+
0: [0],
|
|
18
|
+
1: [0],
|
|
19
|
+
2: [0],
|
|
20
|
+
3: [0],
|
|
21
|
+
4: [0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 2, 0, 0, 0, 0],
|
|
22
|
+
5: [0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 2, 0, 0, 0, 0],
|
|
23
|
+
},
|
|
24
|
+
delim: {
|
|
25
|
+
[-1]: [
|
|
26
|
+
"quotes",
|
|
27
|
+
"quotes",
|
|
28
|
+
"quotes",
|
|
29
|
+
"quotes",
|
|
30
|
+
"brackets",
|
|
31
|
+
"brackets",
|
|
32
|
+
"",
|
|
33
|
+
"",
|
|
34
|
+
"",
|
|
35
|
+
"",
|
|
36
|
+
"",
|
|
37
|
+
"",
|
|
38
|
+
"",
|
|
39
|
+
"",
|
|
40
|
+
"",
|
|
41
|
+
],
|
|
42
|
+
0: [""],
|
|
43
|
+
1: [""],
|
|
44
|
+
2: [""],
|
|
45
|
+
3: [""],
|
|
46
|
+
4: [
|
|
47
|
+
"quotes",
|
|
48
|
+
"quotes",
|
|
49
|
+
"quotes",
|
|
50
|
+
"quotes",
|
|
51
|
+
"brackets",
|
|
52
|
+
"brackets",
|
|
53
|
+
"",
|
|
54
|
+
"",
|
|
55
|
+
"",
|
|
56
|
+
"",
|
|
57
|
+
"",
|
|
58
|
+
"",
|
|
59
|
+
"",
|
|
60
|
+
"",
|
|
61
|
+
"",
|
|
62
|
+
],
|
|
63
|
+
5: [
|
|
64
|
+
"quotes",
|
|
65
|
+
"quotes",
|
|
66
|
+
"quotes",
|
|
67
|
+
"quotes",
|
|
68
|
+
"brackets",
|
|
69
|
+
"brackets",
|
|
70
|
+
"",
|
|
71
|
+
"",
|
|
72
|
+
"",
|
|
73
|
+
"",
|
|
74
|
+
"",
|
|
75
|
+
"",
|
|
76
|
+
"",
|
|
77
|
+
"",
|
|
78
|
+
"",
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
inner: {
|
|
82
|
+
[-1]: [
|
|
83
|
+
"string",
|
|
84
|
+
"string",
|
|
85
|
+
"string",
|
|
86
|
+
"string",
|
|
87
|
+
"code",
|
|
88
|
+
"code",
|
|
89
|
+
"identifier",
|
|
90
|
+
"identifier",
|
|
91
|
+
"number",
|
|
92
|
+
"number",
|
|
93
|
+
"number",
|
|
94
|
+
"number",
|
|
95
|
+
"number",
|
|
96
|
+
"number",
|
|
97
|
+
"comment",
|
|
98
|
+
],
|
|
99
|
+
0: ["special"],
|
|
100
|
+
1: ["special"],
|
|
101
|
+
2: ["special"],
|
|
102
|
+
3: ["special"],
|
|
103
|
+
4: [
|
|
104
|
+
"string",
|
|
105
|
+
"string",
|
|
106
|
+
"string",
|
|
107
|
+
"string",
|
|
108
|
+
"code",
|
|
109
|
+
"code",
|
|
110
|
+
"identifier",
|
|
111
|
+
"identifier",
|
|
112
|
+
"number",
|
|
113
|
+
"number",
|
|
114
|
+
"number",
|
|
115
|
+
"number",
|
|
116
|
+
"number",
|
|
117
|
+
"number",
|
|
118
|
+
"comment",
|
|
119
|
+
],
|
|
120
|
+
5: [
|
|
121
|
+
"string",
|
|
122
|
+
"string",
|
|
123
|
+
"string",
|
|
124
|
+
"string",
|
|
125
|
+
"code",
|
|
126
|
+
"code",
|
|
127
|
+
"identifier",
|
|
128
|
+
"identifier",
|
|
129
|
+
"number",
|
|
130
|
+
"number",
|
|
131
|
+
"number",
|
|
132
|
+
"number",
|
|
133
|
+
"number",
|
|
134
|
+
"number",
|
|
135
|
+
"comment",
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
end: {
|
|
139
|
+
0: /'''/gi,
|
|
140
|
+
1: /"""/gi,
|
|
141
|
+
2: /"/gi,
|
|
142
|
+
3: /'/gi,
|
|
143
|
+
4: /\)/gi,
|
|
144
|
+
5: /\]/gi,
|
|
145
|
+
},
|
|
146
|
+
states: {
|
|
147
|
+
[-1]: [0, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1],
|
|
148
|
+
0: [-1],
|
|
149
|
+
1: [-1],
|
|
150
|
+
2: [-1],
|
|
151
|
+
3: [-1],
|
|
152
|
+
4: [0, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1],
|
|
153
|
+
5: [0, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1],
|
|
154
|
+
},
|
|
155
|
+
keywords: {
|
|
156
|
+
[-1]: [
|
|
157
|
+
-1,
|
|
158
|
+
-1,
|
|
159
|
+
-1,
|
|
160
|
+
-1,
|
|
161
|
+
-1,
|
|
162
|
+
-1,
|
|
163
|
+
{
|
|
164
|
+
builtin:
|
|
165
|
+
/^(__import__|abs|apply|basestring|bool|buffer|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|min|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|round|setattr|slice|staticmethod|sum|super|str|tuple|type|unichr|unicode|vars|xrange|zip)$/,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
reserved:
|
|
169
|
+
/^(and|del|for|is|raise|assert|elif|from|lambda|return|break|else|global|not|try|class|except|if|or|while|continue|exec|import|pass|yield|def|finally|in|print|False|True|None|NotImplemented|Ellipsis|Exception|SystemExit|StopIteration|StandardError|KeyboardInterrupt|ImportError|EnvironmentError|IOError|OSError|WindowsError|EOFError|RuntimeError|NotImplementedError|NameError|UnboundLocalError|AttributeError|SyntaxError|IndentationError|TabError|TypeError|AssertionError|LookupError|IndexError|KeyError|ArithmeticError|OverflowError|ZeroDivisionError|FloatingPointError|ValueError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ReferenceError|SystemError|MemoryError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|OverflowWarning|RuntimeWarning|FutureWarning)$/,
|
|
170
|
+
},
|
|
171
|
+
{},
|
|
172
|
+
{},
|
|
173
|
+
{},
|
|
174
|
+
{},
|
|
175
|
+
{},
|
|
176
|
+
{},
|
|
177
|
+
{},
|
|
178
|
+
],
|
|
179
|
+
0: [],
|
|
180
|
+
1: [{}],
|
|
181
|
+
2: [{}],
|
|
182
|
+
3: [{}],
|
|
183
|
+
4: [
|
|
184
|
+
-1,
|
|
185
|
+
-1,
|
|
186
|
+
-1,
|
|
187
|
+
-1,
|
|
188
|
+
-1,
|
|
189
|
+
-1,
|
|
190
|
+
{
|
|
191
|
+
builtin:
|
|
192
|
+
/^(__import__|abs|apply|basestring|bool|buffer|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|min|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|round|setattr|slice|staticmethod|sum|super|str|tuple|type|unichr|unicode|vars|xrange|zip)$/,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
reserved:
|
|
196
|
+
/^(and|del|for|is|raise|assert|elif|from|lambda|return|break|else|global|not|try|class|except|if|or|while|continue|exec|import|pass|yield|def|finally|in|print|False|True|None|NotImplemented|Ellipsis|Exception|SystemExit|StopIteration|StandardError|KeyboardInterrupt|ImportError|EnvironmentError|IOError|OSError|WindowsError|EOFError|RuntimeError|NotImplementedError|NameError|UnboundLocalError|AttributeError|SyntaxError|IndentationError|TabError|TypeError|AssertionError|LookupError|IndexError|KeyError|ArithmeticError|OverflowError|ZeroDivisionError|FloatingPointError|ValueError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ReferenceError|SystemError|MemoryError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|OverflowWarning|RuntimeWarning|FutureWarning)$/,
|
|
197
|
+
},
|
|
198
|
+
{},
|
|
199
|
+
{},
|
|
200
|
+
{},
|
|
201
|
+
{},
|
|
202
|
+
{},
|
|
203
|
+
{},
|
|
204
|
+
{},
|
|
205
|
+
],
|
|
206
|
+
5: [
|
|
207
|
+
-1,
|
|
208
|
+
-1,
|
|
209
|
+
-1,
|
|
210
|
+
-1,
|
|
211
|
+
-1,
|
|
212
|
+
-1,
|
|
213
|
+
{
|
|
214
|
+
builtin:
|
|
215
|
+
/^(__import__|abs|apply|basestring|bool|buffer|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|min|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|round|setattr|slice|staticmethod|sum|super|str|tuple|type|unichr|unicode|vars|xrange|zip)$/,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
reserved:
|
|
219
|
+
/^(and|del|for|is|raise|assert|elif|from|lambda|return|break|else|global|not|try|class|except|if|or|while|continue|exec|import|pass|yield|def|finally|in|print|False|True|None|NotImplemented|Ellipsis|Exception|SystemExit|StopIteration|StandardError|KeyboardInterrupt|ImportError|EnvironmentError|IOError|OSError|WindowsError|EOFError|RuntimeError|NotImplementedError|NameError|UnboundLocalError|AttributeError|SyntaxError|IndentationError|TabError|TypeError|AssertionError|LookupError|IndexError|KeyError|ArithmeticError|OverflowError|ZeroDivisionError|FloatingPointError|ValueError|UnicodeError|UnicodeEncodeError|UnicodeDecodeError|UnicodeTranslateError|ReferenceError|SystemError|MemoryError|Warning|UserWarning|DeprecationWarning|PendingDeprecationWarning|SyntaxWarning|OverflowWarning|RuntimeWarning|FutureWarning)$/,
|
|
220
|
+
},
|
|
221
|
+
{},
|
|
222
|
+
{},
|
|
223
|
+
{},
|
|
224
|
+
{},
|
|
225
|
+
{},
|
|
226
|
+
{},
|
|
227
|
+
{},
|
|
228
|
+
],
|
|
229
|
+
6: [],
|
|
230
|
+
7: [],
|
|
231
|
+
8: [],
|
|
232
|
+
9: [],
|
|
233
|
+
10: [],
|
|
234
|
+
11: [],
|
|
235
|
+
12: [],
|
|
236
|
+
13: [],
|
|
237
|
+
14: [],
|
|
238
|
+
},
|
|
239
|
+
kwmap: {
|
|
240
|
+
builtin: "builtin",
|
|
241
|
+
reserved: "reserved",
|
|
242
|
+
},
|
|
243
|
+
parts: {
|
|
244
|
+
0: [null],
|
|
245
|
+
1: [null],
|
|
246
|
+
2: [null],
|
|
247
|
+
3: [null],
|
|
248
|
+
4: [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null],
|
|
249
|
+
5: [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null],
|
|
250
|
+
},
|
|
251
|
+
subst: {
|
|
252
|
+
[-1]: [
|
|
253
|
+
false,
|
|
254
|
+
false,
|
|
255
|
+
false,
|
|
256
|
+
false,
|
|
257
|
+
false,
|
|
258
|
+
false,
|
|
259
|
+
false,
|
|
260
|
+
false,
|
|
261
|
+
false,
|
|
262
|
+
false,
|
|
263
|
+
false,
|
|
264
|
+
false,
|
|
265
|
+
false,
|
|
266
|
+
false,
|
|
267
|
+
false,
|
|
268
|
+
],
|
|
269
|
+
0: [false],
|
|
270
|
+
1: [false],
|
|
271
|
+
2: [false],
|
|
272
|
+
3: [false],
|
|
273
|
+
4: [
|
|
274
|
+
false,
|
|
275
|
+
false,
|
|
276
|
+
false,
|
|
277
|
+
false,
|
|
278
|
+
false,
|
|
279
|
+
false,
|
|
280
|
+
false,
|
|
281
|
+
false,
|
|
282
|
+
false,
|
|
283
|
+
false,
|
|
284
|
+
false,
|
|
285
|
+
false,
|
|
286
|
+
false,
|
|
287
|
+
false,
|
|
288
|
+
false,
|
|
289
|
+
],
|
|
290
|
+
5: [
|
|
291
|
+
false,
|
|
292
|
+
false,
|
|
293
|
+
false,
|
|
294
|
+
false,
|
|
295
|
+
false,
|
|
296
|
+
false,
|
|
297
|
+
false,
|
|
298
|
+
false,
|
|
299
|
+
false,
|
|
300
|
+
false,
|
|
301
|
+
false,
|
|
302
|
+
false,
|
|
303
|
+
false,
|
|
304
|
+
false,
|
|
305
|
+
false,
|
|
306
|
+
],
|
|
307
|
+
},
|
|
308
|
+
};
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import type { LanguageDefinition } from "../types";
|
|
2
|
+
|
|
3
|
+
export const rubyLang: LanguageDefinition = {
|
|
4
|
+
language: "ruby",
|
|
5
|
+
defClass: "code",
|
|
6
|
+
regs: {
|
|
7
|
+
[-1]: /(^__END__$)|(")|(%[Qx]([!"#$%&'+\-*./:;=?@^`|~{<[(]))|(')|(%[wq]([!"#$%&'+\-*./:;=?@^`|~{<[(]))|(\$(\W|\w+))|(@@?[_a-z][\d_a-z]*)|(\()|(\[)|([a-z_]\w*)|(((\d+|((\d*\.\d+)|(\d+\.\d*)))[eE][+-]?\d+))|((\d*\.\d+)|(\d+\.\d*))|(0[xX][\da-f]+l?)|(\d+l?|\b0l?\b)|(0[0-7]+l?)|(^=begin$)|(#)|(\s*\/)/gim,
|
|
8
|
+
0: null,
|
|
9
|
+
1: /(\\.)/gi,
|
|
10
|
+
2: /(\\.)/gi,
|
|
11
|
+
3: /(\\.)/gi,
|
|
12
|
+
4: /(\\.)/gi,
|
|
13
|
+
5: /(^__END__$)|(")|(%[Qx]([!"#$%&'+\-*./:;=?@^`|~{<[(]))|(')|(%[wq]([!"#$%&'+\-*./:;=?@^`|~{<[(]))|(\$(\W|\w+))|(@@?[_a-z][\d_a-z]*)|(\()|(\[)|([a-z_]\w*)|(((\d+|((\d*\.\d+)|(\d+\.\d*)))[eE][+-]?\d+))|((\d*\.\d+)|(\d+\.\d*))|(0[xX][\da-f]+l?)|(\d+l?|\b0l?\b)|(0[0-7]+l?)|(^=begin$)|(#)|(\s*\/)/gim,
|
|
14
|
+
6: /(^__END__$)|(")|(%[Qx]([!"#$%&'+\-*./:;=?@^`|~{<[(]))|(')|(%[wq]([!"#$%&'+\-*./:;=?@^`|~{<[(]))|(\$(\W|\w+))|(@@?[_a-z][\d_a-z]*)|(\()|(\[)|([a-z_]\w*)|(((\d+|((\d*\.\d+)|(\d+\.\d*)))[eE][+-]?\d+))|((\d*\.\d+)|(\d+\.\d*))|(0[xX][\da-f]+l?)|(\d+l?|\b0l?\b)|(0[0-7]+l?)|(^=begin$)|(#)|(\s*\/)/gim,
|
|
15
|
+
7: /(\$\w+\s*:.+\$)/gi,
|
|
16
|
+
8: /(\$\w+\s*:.+\$)/gi,
|
|
17
|
+
9: /(\\.)/gi,
|
|
18
|
+
},
|
|
19
|
+
counts: {
|
|
20
|
+
[-1]: [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0],
|
|
21
|
+
0: [],
|
|
22
|
+
1: [0],
|
|
23
|
+
2: [0],
|
|
24
|
+
3: [0],
|
|
25
|
+
4: [0],
|
|
26
|
+
5: [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0],
|
|
27
|
+
6: [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0],
|
|
28
|
+
7: [0],
|
|
29
|
+
8: [0],
|
|
30
|
+
9: [0],
|
|
31
|
+
},
|
|
32
|
+
delim: {
|
|
33
|
+
[-1]: [
|
|
34
|
+
"reserved",
|
|
35
|
+
"quotes",
|
|
36
|
+
"quotes",
|
|
37
|
+
"quotes",
|
|
38
|
+
"quotes",
|
|
39
|
+
"",
|
|
40
|
+
"",
|
|
41
|
+
"brackets",
|
|
42
|
+
"brackets",
|
|
43
|
+
"",
|
|
44
|
+
"",
|
|
45
|
+
"",
|
|
46
|
+
"",
|
|
47
|
+
"",
|
|
48
|
+
"",
|
|
49
|
+
"comment",
|
|
50
|
+
"comment",
|
|
51
|
+
"quotes",
|
|
52
|
+
],
|
|
53
|
+
0: [],
|
|
54
|
+
1: [""],
|
|
55
|
+
2: [""],
|
|
56
|
+
3: [""],
|
|
57
|
+
4: [""],
|
|
58
|
+
5: [
|
|
59
|
+
"reserved",
|
|
60
|
+
"quotes",
|
|
61
|
+
"quotes",
|
|
62
|
+
"quotes",
|
|
63
|
+
"quotes",
|
|
64
|
+
"",
|
|
65
|
+
"",
|
|
66
|
+
"brackets",
|
|
67
|
+
"brackets",
|
|
68
|
+
"",
|
|
69
|
+
"",
|
|
70
|
+
"",
|
|
71
|
+
"",
|
|
72
|
+
"",
|
|
73
|
+
"",
|
|
74
|
+
"comment",
|
|
75
|
+
"comment",
|
|
76
|
+
"quotes",
|
|
77
|
+
],
|
|
78
|
+
6: [
|
|
79
|
+
"reserved",
|
|
80
|
+
"quotes",
|
|
81
|
+
"quotes",
|
|
82
|
+
"quotes",
|
|
83
|
+
"quotes",
|
|
84
|
+
"",
|
|
85
|
+
"",
|
|
86
|
+
"brackets",
|
|
87
|
+
"brackets",
|
|
88
|
+
"",
|
|
89
|
+
"",
|
|
90
|
+
"",
|
|
91
|
+
"",
|
|
92
|
+
"",
|
|
93
|
+
"",
|
|
94
|
+
"comment",
|
|
95
|
+
"comment",
|
|
96
|
+
"quotes",
|
|
97
|
+
],
|
|
98
|
+
7: [""],
|
|
99
|
+
8: [""],
|
|
100
|
+
9: [""],
|
|
101
|
+
},
|
|
102
|
+
inner: {
|
|
103
|
+
[-1]: [
|
|
104
|
+
"comment",
|
|
105
|
+
"string",
|
|
106
|
+
"string",
|
|
107
|
+
"string",
|
|
108
|
+
"string",
|
|
109
|
+
"var",
|
|
110
|
+
"var",
|
|
111
|
+
"code",
|
|
112
|
+
"code",
|
|
113
|
+
"identifier",
|
|
114
|
+
"number",
|
|
115
|
+
"number",
|
|
116
|
+
"number",
|
|
117
|
+
"number",
|
|
118
|
+
"number",
|
|
119
|
+
"comment",
|
|
120
|
+
"comment",
|
|
121
|
+
"string",
|
|
122
|
+
],
|
|
123
|
+
0: [],
|
|
124
|
+
1: ["special"],
|
|
125
|
+
2: ["special"],
|
|
126
|
+
3: ["special"],
|
|
127
|
+
4: ["special"],
|
|
128
|
+
5: [
|
|
129
|
+
"comment",
|
|
130
|
+
"string",
|
|
131
|
+
"string",
|
|
132
|
+
"string",
|
|
133
|
+
"string",
|
|
134
|
+
"var",
|
|
135
|
+
"var",
|
|
136
|
+
"code",
|
|
137
|
+
"code",
|
|
138
|
+
"identifier",
|
|
139
|
+
"number",
|
|
140
|
+
"number",
|
|
141
|
+
"number",
|
|
142
|
+
"number",
|
|
143
|
+
"number",
|
|
144
|
+
"comment",
|
|
145
|
+
"comment",
|
|
146
|
+
"string",
|
|
147
|
+
],
|
|
148
|
+
6: [
|
|
149
|
+
"comment",
|
|
150
|
+
"string",
|
|
151
|
+
"string",
|
|
152
|
+
"string",
|
|
153
|
+
"string",
|
|
154
|
+
"var",
|
|
155
|
+
"var",
|
|
156
|
+
"code",
|
|
157
|
+
"code",
|
|
158
|
+
"identifier",
|
|
159
|
+
"number",
|
|
160
|
+
"number",
|
|
161
|
+
"number",
|
|
162
|
+
"number",
|
|
163
|
+
"number",
|
|
164
|
+
"comment",
|
|
165
|
+
"comment",
|
|
166
|
+
"string",
|
|
167
|
+
],
|
|
168
|
+
7: ["inlinedoc"],
|
|
169
|
+
8: ["inlinedoc"],
|
|
170
|
+
9: ["special"],
|
|
171
|
+
},
|
|
172
|
+
end: {
|
|
173
|
+
0: /$/gim,
|
|
174
|
+
1: /"/gi,
|
|
175
|
+
2: /%b1%/gi,
|
|
176
|
+
3: /'/gi,
|
|
177
|
+
4: /%b1%/gi,
|
|
178
|
+
5: /\)/gi,
|
|
179
|
+
6: /\]/gi,
|
|
180
|
+
7: /^=end$/gim,
|
|
181
|
+
8: /$/gim,
|
|
182
|
+
9: /\/[iomx]*/gi,
|
|
183
|
+
},
|
|
184
|
+
states: {
|
|
185
|
+
[-1]: [0, 1, 2, 3, 4, -1, -1, 5, 6, -1, -1, -1, -1, -1, -1, 7, 8, 9],
|
|
186
|
+
0: [],
|
|
187
|
+
1: [-1],
|
|
188
|
+
2: [-1],
|
|
189
|
+
3: [-1],
|
|
190
|
+
4: [-1],
|
|
191
|
+
5: [0, 1, 2, 3, 4, -1, -1, 5, 6, -1, -1, -1, -1, -1, -1, 7, 8, 9],
|
|
192
|
+
6: [0, 1, 2, 3, 4, -1, -1, 5, 6, -1, -1, -1, -1, -1, -1, 7, 8, 9],
|
|
193
|
+
7: [-1],
|
|
194
|
+
8: [-1],
|
|
195
|
+
9: [-1],
|
|
196
|
+
},
|
|
197
|
+
keywords: {
|
|
198
|
+
[-1]: [
|
|
199
|
+
-1,
|
|
200
|
+
-1,
|
|
201
|
+
-1,
|
|
202
|
+
-1,
|
|
203
|
+
-1,
|
|
204
|
+
{},
|
|
205
|
+
{},
|
|
206
|
+
-1,
|
|
207
|
+
-1,
|
|
208
|
+
{
|
|
209
|
+
reserved:
|
|
210
|
+
/^(__FILE__|require|and|def|end|in|or|self|unless|__LINE__|begin|defined?|ensure|module|redo|super|until|BEGIN|break|do|false|next|rescue|then|when|END|case|else|for|nil|retry|true|while|alias|module_function|private|public|protected|attr_reader|attr_writer|attr_accessor|class|elsif|if|not|return|undef|yield)$/,
|
|
211
|
+
},
|
|
212
|
+
{},
|
|
213
|
+
{},
|
|
214
|
+
{},
|
|
215
|
+
{},
|
|
216
|
+
{},
|
|
217
|
+
-1,
|
|
218
|
+
-1,
|
|
219
|
+
-1,
|
|
220
|
+
],
|
|
221
|
+
0: [],
|
|
222
|
+
1: [{}],
|
|
223
|
+
2: [{}],
|
|
224
|
+
3: [{}],
|
|
225
|
+
4: [{}],
|
|
226
|
+
5: [],
|
|
227
|
+
6: [],
|
|
228
|
+
7: [{}],
|
|
229
|
+
8: [{}],
|
|
230
|
+
9: [{}],
|
|
231
|
+
10: [],
|
|
232
|
+
11: [],
|
|
233
|
+
12: [],
|
|
234
|
+
13: [],
|
|
235
|
+
14: [],
|
|
236
|
+
},
|
|
237
|
+
kwmap: {
|
|
238
|
+
reserved: "reserved",
|
|
239
|
+
},
|
|
240
|
+
parts: {
|
|
241
|
+
0: [],
|
|
242
|
+
1: [null],
|
|
243
|
+
2: [null],
|
|
244
|
+
3: [null],
|
|
245
|
+
4: [null],
|
|
246
|
+
5: [
|
|
247
|
+
null,
|
|
248
|
+
null,
|
|
249
|
+
null,
|
|
250
|
+
null,
|
|
251
|
+
null,
|
|
252
|
+
null,
|
|
253
|
+
null,
|
|
254
|
+
null,
|
|
255
|
+
null,
|
|
256
|
+
null,
|
|
257
|
+
null,
|
|
258
|
+
null,
|
|
259
|
+
null,
|
|
260
|
+
null,
|
|
261
|
+
null,
|
|
262
|
+
null,
|
|
263
|
+
null,
|
|
264
|
+
null,
|
|
265
|
+
],
|
|
266
|
+
6: [
|
|
267
|
+
null,
|
|
268
|
+
null,
|
|
269
|
+
null,
|
|
270
|
+
null,
|
|
271
|
+
null,
|
|
272
|
+
null,
|
|
273
|
+
null,
|
|
274
|
+
null,
|
|
275
|
+
null,
|
|
276
|
+
null,
|
|
277
|
+
null,
|
|
278
|
+
null,
|
|
279
|
+
null,
|
|
280
|
+
null,
|
|
281
|
+
null,
|
|
282
|
+
null,
|
|
283
|
+
null,
|
|
284
|
+
null,
|
|
285
|
+
],
|
|
286
|
+
7: [null],
|
|
287
|
+
8: [null],
|
|
288
|
+
9: [null],
|
|
289
|
+
},
|
|
290
|
+
subst: {
|
|
291
|
+
[-1]: [
|
|
292
|
+
false,
|
|
293
|
+
false,
|
|
294
|
+
true,
|
|
295
|
+
false,
|
|
296
|
+
true,
|
|
297
|
+
false,
|
|
298
|
+
false,
|
|
299
|
+
false,
|
|
300
|
+
false,
|
|
301
|
+
false,
|
|
302
|
+
false,
|
|
303
|
+
false,
|
|
304
|
+
false,
|
|
305
|
+
false,
|
|
306
|
+
false,
|
|
307
|
+
false,
|
|
308
|
+
false,
|
|
309
|
+
false,
|
|
310
|
+
],
|
|
311
|
+
0: [],
|
|
312
|
+
1: [false],
|
|
313
|
+
2: [false],
|
|
314
|
+
3: [false],
|
|
315
|
+
4: [false],
|
|
316
|
+
5: [
|
|
317
|
+
false,
|
|
318
|
+
false,
|
|
319
|
+
true,
|
|
320
|
+
false,
|
|
321
|
+
true,
|
|
322
|
+
false,
|
|
323
|
+
false,
|
|
324
|
+
false,
|
|
325
|
+
false,
|
|
326
|
+
false,
|
|
327
|
+
false,
|
|
328
|
+
false,
|
|
329
|
+
false,
|
|
330
|
+
false,
|
|
331
|
+
false,
|
|
332
|
+
false,
|
|
333
|
+
false,
|
|
334
|
+
false,
|
|
335
|
+
],
|
|
336
|
+
6: [
|
|
337
|
+
false,
|
|
338
|
+
false,
|
|
339
|
+
true,
|
|
340
|
+
false,
|
|
341
|
+
true,
|
|
342
|
+
false,
|
|
343
|
+
false,
|
|
344
|
+
false,
|
|
345
|
+
false,
|
|
346
|
+
false,
|
|
347
|
+
false,
|
|
348
|
+
false,
|
|
349
|
+
false,
|
|
350
|
+
false,
|
|
351
|
+
false,
|
|
352
|
+
false,
|
|
353
|
+
false,
|
|
354
|
+
false,
|
|
355
|
+
],
|
|
356
|
+
7: [false],
|
|
357
|
+
8: [false],
|
|
358
|
+
9: [false],
|
|
359
|
+
},
|
|
360
|
+
};
|