parse5 6.0.1 → 7.3.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/README.md +2 -2
- package/dist/cjs/common/doctype.d.ts +4 -0
- package/dist/cjs/common/doctype.js +118 -0
- package/dist/cjs/common/error-codes.d.ts +67 -0
- package/dist/cjs/common/error-codes.js +66 -0
- package/dist/cjs/common/foreign-content.d.ts +9 -0
- package/dist/cjs/common/foreign-content.js +237 -0
- package/dist/cjs/common/html.d.ts +289 -0
- package/dist/cjs/common/html.js +528 -0
- package/dist/cjs/common/token.d.ts +84 -0
- package/dist/cjs/common/token.js +24 -0
- package/dist/cjs/common/unicode.d.ts +42 -0
- package/dist/cjs/common/unicode.js +70 -0
- package/dist/cjs/index.d.ts +71 -0
- package/dist/cjs/index.js +54 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/parser/formatting-element-list.d.ts +36 -0
- package/dist/cjs/parser/formatting-element-list.js +114 -0
- package/dist/cjs/parser/index.d.ts +221 -0
- package/dist/cjs/parser/index.js +3240 -0
- package/dist/cjs/parser/open-element-stack.d.ts +53 -0
- package/dist/cjs/parser/open-element-stack.js +328 -0
- package/dist/cjs/serializer/index.d.ts +60 -0
- package/dist/cjs/serializer/index.js +172 -0
- package/dist/cjs/tokenizer/index.d.ts +247 -0
- package/dist/cjs/tokenizer/index.js +2714 -0
- package/dist/cjs/tokenizer/preprocessor.d.ts +36 -0
- package/dist/cjs/tokenizer/preprocessor.js +200 -0
- package/dist/cjs/tree-adapters/default.d.ts +84 -0
- package/dist/cjs/tree-adapters/default.js +176 -0
- package/dist/cjs/tree-adapters/interface.d.ts +255 -0
- package/dist/cjs/tree-adapters/interface.js +2 -0
- package/dist/common/doctype.d.ts +4 -0
- package/{lib → dist}/common/doctype.js +24 -72
- package/dist/common/error-codes.d.ts +67 -0
- package/dist/common/error-codes.js +63 -0
- package/dist/common/foreign-content.d.ts +9 -0
- package/dist/common/foreign-content.js +228 -0
- package/dist/common/html.d.ts +289 -0
- package/dist/common/html.js +523 -0
- package/dist/common/token.d.ts +84 -0
- package/dist/common/token.js +20 -0
- package/dist/common/unicode.d.ts +42 -0
- package/dist/common/unicode.js +62 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +42 -0
- package/dist/parser/formatting-element-list.d.ts +36 -0
- package/dist/parser/formatting-element-list.js +110 -0
- package/dist/parser/index.d.ts +221 -0
- package/dist/parser/index.js +3245 -0
- package/dist/parser/open-element-stack.d.ts +53 -0
- package/dist/parser/open-element-stack.js +324 -0
- package/dist/serializer/index.d.ts +60 -0
- package/dist/serializer/index.js +168 -0
- package/dist/tokenizer/index.d.ts +247 -0
- package/dist/tokenizer/index.js +2710 -0
- package/dist/tokenizer/preprocessor.d.ts +36 -0
- package/dist/tokenizer/preprocessor.js +196 -0
- package/dist/tree-adapters/default.d.ts +84 -0
- package/dist/tree-adapters/default.js +173 -0
- package/dist/tree-adapters/interface.d.ts +255 -0
- package/dist/tree-adapters/interface.js +1 -0
- package/package.json +21 -6
- package/lib/common/error-codes.js +0 -65
- package/lib/common/foreign-content.js +0 -265
- package/lib/common/html.js +0 -272
- package/lib/common/unicode.js +0 -109
- package/lib/extensions/error-reporting/mixin-base.js +0 -43
- package/lib/extensions/error-reporting/parser-mixin.js +0 -52
- package/lib/extensions/error-reporting/preprocessor-mixin.js +0 -24
- package/lib/extensions/error-reporting/tokenizer-mixin.js +0 -17
- package/lib/extensions/location-info/open-element-stack-mixin.js +0 -35
- package/lib/extensions/location-info/parser-mixin.js +0 -223
- package/lib/extensions/location-info/tokenizer-mixin.js +0 -146
- package/lib/extensions/position-tracking/preprocessor-mixin.js +0 -64
- package/lib/index.js +0 -29
- package/lib/parser/formatting-element-list.js +0 -181
- package/lib/parser/index.js +0 -2956
- package/lib/parser/open-element-stack.js +0 -482
- package/lib/serializer/index.js +0 -176
- package/lib/tokenizer/index.js +0 -2196
- package/lib/tokenizer/named-entity-data.js +0 -5
- package/lib/tokenizer/preprocessor.js +0 -159
- package/lib/tree-adapters/default.js +0 -221
- package/lib/utils/merge-options.js +0 -13
- package/lib/utils/mixin.js +0 -39
package/lib/common/html.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const NS = (exports.NAMESPACES = {
|
|
4
|
-
HTML: 'http://www.w3.org/1999/xhtml',
|
|
5
|
-
MATHML: 'http://www.w3.org/1998/Math/MathML',
|
|
6
|
-
SVG: 'http://www.w3.org/2000/svg',
|
|
7
|
-
XLINK: 'http://www.w3.org/1999/xlink',
|
|
8
|
-
XML: 'http://www.w3.org/XML/1998/namespace',
|
|
9
|
-
XMLNS: 'http://www.w3.org/2000/xmlns/'
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
exports.ATTRS = {
|
|
13
|
-
TYPE: 'type',
|
|
14
|
-
ACTION: 'action',
|
|
15
|
-
ENCODING: 'encoding',
|
|
16
|
-
PROMPT: 'prompt',
|
|
17
|
-
NAME: 'name',
|
|
18
|
-
COLOR: 'color',
|
|
19
|
-
FACE: 'face',
|
|
20
|
-
SIZE: 'size'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.DOCUMENT_MODE = {
|
|
24
|
-
NO_QUIRKS: 'no-quirks',
|
|
25
|
-
QUIRKS: 'quirks',
|
|
26
|
-
LIMITED_QUIRKS: 'limited-quirks'
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const $ = (exports.TAG_NAMES = {
|
|
30
|
-
A: 'a',
|
|
31
|
-
ADDRESS: 'address',
|
|
32
|
-
ANNOTATION_XML: 'annotation-xml',
|
|
33
|
-
APPLET: 'applet',
|
|
34
|
-
AREA: 'area',
|
|
35
|
-
ARTICLE: 'article',
|
|
36
|
-
ASIDE: 'aside',
|
|
37
|
-
|
|
38
|
-
B: 'b',
|
|
39
|
-
BASE: 'base',
|
|
40
|
-
BASEFONT: 'basefont',
|
|
41
|
-
BGSOUND: 'bgsound',
|
|
42
|
-
BIG: 'big',
|
|
43
|
-
BLOCKQUOTE: 'blockquote',
|
|
44
|
-
BODY: 'body',
|
|
45
|
-
BR: 'br',
|
|
46
|
-
BUTTON: 'button',
|
|
47
|
-
|
|
48
|
-
CAPTION: 'caption',
|
|
49
|
-
CENTER: 'center',
|
|
50
|
-
CODE: 'code',
|
|
51
|
-
COL: 'col',
|
|
52
|
-
COLGROUP: 'colgroup',
|
|
53
|
-
|
|
54
|
-
DD: 'dd',
|
|
55
|
-
DESC: 'desc',
|
|
56
|
-
DETAILS: 'details',
|
|
57
|
-
DIALOG: 'dialog',
|
|
58
|
-
DIR: 'dir',
|
|
59
|
-
DIV: 'div',
|
|
60
|
-
DL: 'dl',
|
|
61
|
-
DT: 'dt',
|
|
62
|
-
|
|
63
|
-
EM: 'em',
|
|
64
|
-
EMBED: 'embed',
|
|
65
|
-
|
|
66
|
-
FIELDSET: 'fieldset',
|
|
67
|
-
FIGCAPTION: 'figcaption',
|
|
68
|
-
FIGURE: 'figure',
|
|
69
|
-
FONT: 'font',
|
|
70
|
-
FOOTER: 'footer',
|
|
71
|
-
FOREIGN_OBJECT: 'foreignObject',
|
|
72
|
-
FORM: 'form',
|
|
73
|
-
FRAME: 'frame',
|
|
74
|
-
FRAMESET: 'frameset',
|
|
75
|
-
|
|
76
|
-
H1: 'h1',
|
|
77
|
-
H2: 'h2',
|
|
78
|
-
H3: 'h3',
|
|
79
|
-
H4: 'h4',
|
|
80
|
-
H5: 'h5',
|
|
81
|
-
H6: 'h6',
|
|
82
|
-
HEAD: 'head',
|
|
83
|
-
HEADER: 'header',
|
|
84
|
-
HGROUP: 'hgroup',
|
|
85
|
-
HR: 'hr',
|
|
86
|
-
HTML: 'html',
|
|
87
|
-
|
|
88
|
-
I: 'i',
|
|
89
|
-
IMG: 'img',
|
|
90
|
-
IMAGE: 'image',
|
|
91
|
-
INPUT: 'input',
|
|
92
|
-
IFRAME: 'iframe',
|
|
93
|
-
|
|
94
|
-
KEYGEN: 'keygen',
|
|
95
|
-
|
|
96
|
-
LABEL: 'label',
|
|
97
|
-
LI: 'li',
|
|
98
|
-
LINK: 'link',
|
|
99
|
-
LISTING: 'listing',
|
|
100
|
-
|
|
101
|
-
MAIN: 'main',
|
|
102
|
-
MALIGNMARK: 'malignmark',
|
|
103
|
-
MARQUEE: 'marquee',
|
|
104
|
-
MATH: 'math',
|
|
105
|
-
MENU: 'menu',
|
|
106
|
-
META: 'meta',
|
|
107
|
-
MGLYPH: 'mglyph',
|
|
108
|
-
MI: 'mi',
|
|
109
|
-
MO: 'mo',
|
|
110
|
-
MN: 'mn',
|
|
111
|
-
MS: 'ms',
|
|
112
|
-
MTEXT: 'mtext',
|
|
113
|
-
|
|
114
|
-
NAV: 'nav',
|
|
115
|
-
NOBR: 'nobr',
|
|
116
|
-
NOFRAMES: 'noframes',
|
|
117
|
-
NOEMBED: 'noembed',
|
|
118
|
-
NOSCRIPT: 'noscript',
|
|
119
|
-
|
|
120
|
-
OBJECT: 'object',
|
|
121
|
-
OL: 'ol',
|
|
122
|
-
OPTGROUP: 'optgroup',
|
|
123
|
-
OPTION: 'option',
|
|
124
|
-
|
|
125
|
-
P: 'p',
|
|
126
|
-
PARAM: 'param',
|
|
127
|
-
PLAINTEXT: 'plaintext',
|
|
128
|
-
PRE: 'pre',
|
|
129
|
-
|
|
130
|
-
RB: 'rb',
|
|
131
|
-
RP: 'rp',
|
|
132
|
-
RT: 'rt',
|
|
133
|
-
RTC: 'rtc',
|
|
134
|
-
RUBY: 'ruby',
|
|
135
|
-
|
|
136
|
-
S: 's',
|
|
137
|
-
SCRIPT: 'script',
|
|
138
|
-
SECTION: 'section',
|
|
139
|
-
SELECT: 'select',
|
|
140
|
-
SOURCE: 'source',
|
|
141
|
-
SMALL: 'small',
|
|
142
|
-
SPAN: 'span',
|
|
143
|
-
STRIKE: 'strike',
|
|
144
|
-
STRONG: 'strong',
|
|
145
|
-
STYLE: 'style',
|
|
146
|
-
SUB: 'sub',
|
|
147
|
-
SUMMARY: 'summary',
|
|
148
|
-
SUP: 'sup',
|
|
149
|
-
|
|
150
|
-
TABLE: 'table',
|
|
151
|
-
TBODY: 'tbody',
|
|
152
|
-
TEMPLATE: 'template',
|
|
153
|
-
TEXTAREA: 'textarea',
|
|
154
|
-
TFOOT: 'tfoot',
|
|
155
|
-
TD: 'td',
|
|
156
|
-
TH: 'th',
|
|
157
|
-
THEAD: 'thead',
|
|
158
|
-
TITLE: 'title',
|
|
159
|
-
TR: 'tr',
|
|
160
|
-
TRACK: 'track',
|
|
161
|
-
TT: 'tt',
|
|
162
|
-
|
|
163
|
-
U: 'u',
|
|
164
|
-
UL: 'ul',
|
|
165
|
-
|
|
166
|
-
SVG: 'svg',
|
|
167
|
-
|
|
168
|
-
VAR: 'var',
|
|
169
|
-
|
|
170
|
-
WBR: 'wbr',
|
|
171
|
-
|
|
172
|
-
XMP: 'xmp'
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
exports.SPECIAL_ELEMENTS = {
|
|
176
|
-
[NS.HTML]: {
|
|
177
|
-
[$.ADDRESS]: true,
|
|
178
|
-
[$.APPLET]: true,
|
|
179
|
-
[$.AREA]: true,
|
|
180
|
-
[$.ARTICLE]: true,
|
|
181
|
-
[$.ASIDE]: true,
|
|
182
|
-
[$.BASE]: true,
|
|
183
|
-
[$.BASEFONT]: true,
|
|
184
|
-
[$.BGSOUND]: true,
|
|
185
|
-
[$.BLOCKQUOTE]: true,
|
|
186
|
-
[$.BODY]: true,
|
|
187
|
-
[$.BR]: true,
|
|
188
|
-
[$.BUTTON]: true,
|
|
189
|
-
[$.CAPTION]: true,
|
|
190
|
-
[$.CENTER]: true,
|
|
191
|
-
[$.COL]: true,
|
|
192
|
-
[$.COLGROUP]: true,
|
|
193
|
-
[$.DD]: true,
|
|
194
|
-
[$.DETAILS]: true,
|
|
195
|
-
[$.DIR]: true,
|
|
196
|
-
[$.DIV]: true,
|
|
197
|
-
[$.DL]: true,
|
|
198
|
-
[$.DT]: true,
|
|
199
|
-
[$.EMBED]: true,
|
|
200
|
-
[$.FIELDSET]: true,
|
|
201
|
-
[$.FIGCAPTION]: true,
|
|
202
|
-
[$.FIGURE]: true,
|
|
203
|
-
[$.FOOTER]: true,
|
|
204
|
-
[$.FORM]: true,
|
|
205
|
-
[$.FRAME]: true,
|
|
206
|
-
[$.FRAMESET]: true,
|
|
207
|
-
[$.H1]: true,
|
|
208
|
-
[$.H2]: true,
|
|
209
|
-
[$.H3]: true,
|
|
210
|
-
[$.H4]: true,
|
|
211
|
-
[$.H5]: true,
|
|
212
|
-
[$.H6]: true,
|
|
213
|
-
[$.HEAD]: true,
|
|
214
|
-
[$.HEADER]: true,
|
|
215
|
-
[$.HGROUP]: true,
|
|
216
|
-
[$.HR]: true,
|
|
217
|
-
[$.HTML]: true,
|
|
218
|
-
[$.IFRAME]: true,
|
|
219
|
-
[$.IMG]: true,
|
|
220
|
-
[$.INPUT]: true,
|
|
221
|
-
[$.LI]: true,
|
|
222
|
-
[$.LINK]: true,
|
|
223
|
-
[$.LISTING]: true,
|
|
224
|
-
[$.MAIN]: true,
|
|
225
|
-
[$.MARQUEE]: true,
|
|
226
|
-
[$.MENU]: true,
|
|
227
|
-
[$.META]: true,
|
|
228
|
-
[$.NAV]: true,
|
|
229
|
-
[$.NOEMBED]: true,
|
|
230
|
-
[$.NOFRAMES]: true,
|
|
231
|
-
[$.NOSCRIPT]: true,
|
|
232
|
-
[$.OBJECT]: true,
|
|
233
|
-
[$.OL]: true,
|
|
234
|
-
[$.P]: true,
|
|
235
|
-
[$.PARAM]: true,
|
|
236
|
-
[$.PLAINTEXT]: true,
|
|
237
|
-
[$.PRE]: true,
|
|
238
|
-
[$.SCRIPT]: true,
|
|
239
|
-
[$.SECTION]: true,
|
|
240
|
-
[$.SELECT]: true,
|
|
241
|
-
[$.SOURCE]: true,
|
|
242
|
-
[$.STYLE]: true,
|
|
243
|
-
[$.SUMMARY]: true,
|
|
244
|
-
[$.TABLE]: true,
|
|
245
|
-
[$.TBODY]: true,
|
|
246
|
-
[$.TD]: true,
|
|
247
|
-
[$.TEMPLATE]: true,
|
|
248
|
-
[$.TEXTAREA]: true,
|
|
249
|
-
[$.TFOOT]: true,
|
|
250
|
-
[$.TH]: true,
|
|
251
|
-
[$.THEAD]: true,
|
|
252
|
-
[$.TITLE]: true,
|
|
253
|
-
[$.TR]: true,
|
|
254
|
-
[$.TRACK]: true,
|
|
255
|
-
[$.UL]: true,
|
|
256
|
-
[$.WBR]: true,
|
|
257
|
-
[$.XMP]: true
|
|
258
|
-
},
|
|
259
|
-
[NS.MATHML]: {
|
|
260
|
-
[$.MI]: true,
|
|
261
|
-
[$.MO]: true,
|
|
262
|
-
[$.MN]: true,
|
|
263
|
-
[$.MS]: true,
|
|
264
|
-
[$.MTEXT]: true,
|
|
265
|
-
[$.ANNOTATION_XML]: true
|
|
266
|
-
},
|
|
267
|
-
[NS.SVG]: {
|
|
268
|
-
[$.TITLE]: true,
|
|
269
|
-
[$.FOREIGN_OBJECT]: true,
|
|
270
|
-
[$.DESC]: true
|
|
271
|
-
}
|
|
272
|
-
};
|
package/lib/common/unicode.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const UNDEFINED_CODE_POINTS = [
|
|
4
|
-
0xfffe,
|
|
5
|
-
0xffff,
|
|
6
|
-
0x1fffe,
|
|
7
|
-
0x1ffff,
|
|
8
|
-
0x2fffe,
|
|
9
|
-
0x2ffff,
|
|
10
|
-
0x3fffe,
|
|
11
|
-
0x3ffff,
|
|
12
|
-
0x4fffe,
|
|
13
|
-
0x4ffff,
|
|
14
|
-
0x5fffe,
|
|
15
|
-
0x5ffff,
|
|
16
|
-
0x6fffe,
|
|
17
|
-
0x6ffff,
|
|
18
|
-
0x7fffe,
|
|
19
|
-
0x7ffff,
|
|
20
|
-
0x8fffe,
|
|
21
|
-
0x8ffff,
|
|
22
|
-
0x9fffe,
|
|
23
|
-
0x9ffff,
|
|
24
|
-
0xafffe,
|
|
25
|
-
0xaffff,
|
|
26
|
-
0xbfffe,
|
|
27
|
-
0xbffff,
|
|
28
|
-
0xcfffe,
|
|
29
|
-
0xcffff,
|
|
30
|
-
0xdfffe,
|
|
31
|
-
0xdffff,
|
|
32
|
-
0xefffe,
|
|
33
|
-
0xeffff,
|
|
34
|
-
0xffffe,
|
|
35
|
-
0xfffff,
|
|
36
|
-
0x10fffe,
|
|
37
|
-
0x10ffff
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
exports.REPLACEMENT_CHARACTER = '\uFFFD';
|
|
41
|
-
|
|
42
|
-
exports.CODE_POINTS = {
|
|
43
|
-
EOF: -1,
|
|
44
|
-
NULL: 0x00,
|
|
45
|
-
TABULATION: 0x09,
|
|
46
|
-
CARRIAGE_RETURN: 0x0d,
|
|
47
|
-
LINE_FEED: 0x0a,
|
|
48
|
-
FORM_FEED: 0x0c,
|
|
49
|
-
SPACE: 0x20,
|
|
50
|
-
EXCLAMATION_MARK: 0x21,
|
|
51
|
-
QUOTATION_MARK: 0x22,
|
|
52
|
-
NUMBER_SIGN: 0x23,
|
|
53
|
-
AMPERSAND: 0x26,
|
|
54
|
-
APOSTROPHE: 0x27,
|
|
55
|
-
HYPHEN_MINUS: 0x2d,
|
|
56
|
-
SOLIDUS: 0x2f,
|
|
57
|
-
DIGIT_0: 0x30,
|
|
58
|
-
DIGIT_9: 0x39,
|
|
59
|
-
SEMICOLON: 0x3b,
|
|
60
|
-
LESS_THAN_SIGN: 0x3c,
|
|
61
|
-
EQUALS_SIGN: 0x3d,
|
|
62
|
-
GREATER_THAN_SIGN: 0x3e,
|
|
63
|
-
QUESTION_MARK: 0x3f,
|
|
64
|
-
LATIN_CAPITAL_A: 0x41,
|
|
65
|
-
LATIN_CAPITAL_F: 0x46,
|
|
66
|
-
LATIN_CAPITAL_X: 0x58,
|
|
67
|
-
LATIN_CAPITAL_Z: 0x5a,
|
|
68
|
-
RIGHT_SQUARE_BRACKET: 0x5d,
|
|
69
|
-
GRAVE_ACCENT: 0x60,
|
|
70
|
-
LATIN_SMALL_A: 0x61,
|
|
71
|
-
LATIN_SMALL_F: 0x66,
|
|
72
|
-
LATIN_SMALL_X: 0x78,
|
|
73
|
-
LATIN_SMALL_Z: 0x7a,
|
|
74
|
-
REPLACEMENT_CHARACTER: 0xfffd
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
exports.CODE_POINT_SEQUENCES = {
|
|
78
|
-
DASH_DASH_STRING: [0x2d, 0x2d], //--
|
|
79
|
-
DOCTYPE_STRING: [0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45], //DOCTYPE
|
|
80
|
-
CDATA_START_STRING: [0x5b, 0x43, 0x44, 0x41, 0x54, 0x41, 0x5b], //[CDATA[
|
|
81
|
-
SCRIPT_STRING: [0x73, 0x63, 0x72, 0x69, 0x70, 0x74], //script
|
|
82
|
-
PUBLIC_STRING: [0x50, 0x55, 0x42, 0x4c, 0x49, 0x43], //PUBLIC
|
|
83
|
-
SYSTEM_STRING: [0x53, 0x59, 0x53, 0x54, 0x45, 0x4d] //SYSTEM
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
//Surrogates
|
|
87
|
-
exports.isSurrogate = function(cp) {
|
|
88
|
-
return cp >= 0xd800 && cp <= 0xdfff;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
exports.isSurrogatePair = function(cp) {
|
|
92
|
-
return cp >= 0xdc00 && cp <= 0xdfff;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
exports.getSurrogatePairCodePoint = function(cp1, cp2) {
|
|
96
|
-
return (cp1 - 0xd800) * 0x400 + 0x2400 + cp2;
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
//NOTE: excluding NULL and ASCII whitespace
|
|
100
|
-
exports.isControlCodePoint = function(cp) {
|
|
101
|
-
return (
|
|
102
|
-
(cp !== 0x20 && cp !== 0x0a && cp !== 0x0d && cp !== 0x09 && cp !== 0x0c && cp >= 0x01 && cp <= 0x1f) ||
|
|
103
|
-
(cp >= 0x7f && cp <= 0x9f)
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
exports.isUndefinedCodePoint = function(cp) {
|
|
108
|
-
return (cp >= 0xfdd0 && cp <= 0xfdef) || UNDEFINED_CODE_POINTS.indexOf(cp) > -1;
|
|
109
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Mixin = require('../../utils/mixin');
|
|
4
|
-
|
|
5
|
-
class ErrorReportingMixinBase extends Mixin {
|
|
6
|
-
constructor(host, opts) {
|
|
7
|
-
super(host);
|
|
8
|
-
|
|
9
|
-
this.posTracker = null;
|
|
10
|
-
this.onParseError = opts.onParseError;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
_setErrorLocation(err) {
|
|
14
|
-
err.startLine = err.endLine = this.posTracker.line;
|
|
15
|
-
err.startCol = err.endCol = this.posTracker.col;
|
|
16
|
-
err.startOffset = err.endOffset = this.posTracker.offset;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
_reportError(code) {
|
|
20
|
-
const err = {
|
|
21
|
-
code: code,
|
|
22
|
-
startLine: -1,
|
|
23
|
-
startCol: -1,
|
|
24
|
-
startOffset: -1,
|
|
25
|
-
endLine: -1,
|
|
26
|
-
endCol: -1,
|
|
27
|
-
endOffset: -1
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
this._setErrorLocation(err);
|
|
31
|
-
this.onParseError(err);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
_getOverriddenMethods(mxn) {
|
|
35
|
-
return {
|
|
36
|
-
_err(code) {
|
|
37
|
-
mxn._reportError(code);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = ErrorReportingMixinBase;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ErrorReportingMixinBase = require('./mixin-base');
|
|
4
|
-
const ErrorReportingTokenizerMixin = require('./tokenizer-mixin');
|
|
5
|
-
const LocationInfoTokenizerMixin = require('../location-info/tokenizer-mixin');
|
|
6
|
-
const Mixin = require('../../utils/mixin');
|
|
7
|
-
|
|
8
|
-
class ErrorReportingParserMixin extends ErrorReportingMixinBase {
|
|
9
|
-
constructor(parser, opts) {
|
|
10
|
-
super(parser, opts);
|
|
11
|
-
|
|
12
|
-
this.opts = opts;
|
|
13
|
-
this.ctLoc = null;
|
|
14
|
-
this.locBeforeToken = false;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
_setErrorLocation(err) {
|
|
18
|
-
if (this.ctLoc) {
|
|
19
|
-
err.startLine = this.ctLoc.startLine;
|
|
20
|
-
err.startCol = this.ctLoc.startCol;
|
|
21
|
-
err.startOffset = this.ctLoc.startOffset;
|
|
22
|
-
|
|
23
|
-
err.endLine = this.locBeforeToken ? this.ctLoc.startLine : this.ctLoc.endLine;
|
|
24
|
-
err.endCol = this.locBeforeToken ? this.ctLoc.startCol : this.ctLoc.endCol;
|
|
25
|
-
err.endOffset = this.locBeforeToken ? this.ctLoc.startOffset : this.ctLoc.endOffset;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
_getOverriddenMethods(mxn, orig) {
|
|
30
|
-
return {
|
|
31
|
-
_bootstrap(document, fragmentContext) {
|
|
32
|
-
orig._bootstrap.call(this, document, fragmentContext);
|
|
33
|
-
|
|
34
|
-
Mixin.install(this.tokenizer, ErrorReportingTokenizerMixin, mxn.opts);
|
|
35
|
-
Mixin.install(this.tokenizer, LocationInfoTokenizerMixin);
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
_processInputToken(token) {
|
|
39
|
-
mxn.ctLoc = token.location;
|
|
40
|
-
|
|
41
|
-
orig._processInputToken.call(this, token);
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
_err(code, options) {
|
|
45
|
-
mxn.locBeforeToken = options && options.beforeToken;
|
|
46
|
-
mxn._reportError(code);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
module.exports = ErrorReportingParserMixin;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ErrorReportingMixinBase = require('./mixin-base');
|
|
4
|
-
const PositionTrackingPreprocessorMixin = require('../position-tracking/preprocessor-mixin');
|
|
5
|
-
const Mixin = require('../../utils/mixin');
|
|
6
|
-
|
|
7
|
-
class ErrorReportingPreprocessorMixin extends ErrorReportingMixinBase {
|
|
8
|
-
constructor(preprocessor, opts) {
|
|
9
|
-
super(preprocessor, opts);
|
|
10
|
-
|
|
11
|
-
this.posTracker = Mixin.install(preprocessor, PositionTrackingPreprocessorMixin);
|
|
12
|
-
this.lastErrOffset = -1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
_reportError(code) {
|
|
16
|
-
//NOTE: avoid reporting error twice on advance/retreat
|
|
17
|
-
if (this.lastErrOffset !== this.posTracker.offset) {
|
|
18
|
-
this.lastErrOffset = this.posTracker.offset;
|
|
19
|
-
super._reportError(code);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = ErrorReportingPreprocessorMixin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const ErrorReportingMixinBase = require('./mixin-base');
|
|
4
|
-
const ErrorReportingPreprocessorMixin = require('./preprocessor-mixin');
|
|
5
|
-
const Mixin = require('../../utils/mixin');
|
|
6
|
-
|
|
7
|
-
class ErrorReportingTokenizerMixin extends ErrorReportingMixinBase {
|
|
8
|
-
constructor(tokenizer, opts) {
|
|
9
|
-
super(tokenizer, opts);
|
|
10
|
-
|
|
11
|
-
const preprocessorMixin = Mixin.install(tokenizer.preprocessor, ErrorReportingPreprocessorMixin, opts);
|
|
12
|
-
|
|
13
|
-
this.posTracker = preprocessorMixin.posTracker;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = ErrorReportingTokenizerMixin;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const Mixin = require('../../utils/mixin');
|
|
4
|
-
|
|
5
|
-
class LocationInfoOpenElementStackMixin extends Mixin {
|
|
6
|
-
constructor(stack, opts) {
|
|
7
|
-
super(stack);
|
|
8
|
-
|
|
9
|
-
this.onItemPop = opts.onItemPop;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
_getOverriddenMethods(mxn, orig) {
|
|
13
|
-
return {
|
|
14
|
-
pop() {
|
|
15
|
-
mxn.onItemPop(this.current);
|
|
16
|
-
orig.pop.call(this);
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
popAllUpToHtmlElement() {
|
|
20
|
-
for (let i = this.stackTop; i > 0; i--) {
|
|
21
|
-
mxn.onItemPop(this.items[i]);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
orig.popAllUpToHtmlElement.call(this);
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
remove(element) {
|
|
28
|
-
mxn.onItemPop(this.current);
|
|
29
|
-
orig.remove.call(this, element);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = LocationInfoOpenElementStackMixin;
|