htmljs-parser 5.5.1 → 5.5.2
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/core/Parser.d.ts +1 -1
- package/dist/index.js +52 -6
- package/dist/index.mjs +52 -6
- package/dist/states/ATTRIBUTE.d.ts +1 -1
- package/dist/states/BEGIN_DELIMITED_HTML_BLOCK.d.ts +1 -1
- package/dist/states/CDATA.d.ts +1 -1
- package/dist/states/CLOSE_TAG.d.ts +1 -1
- package/dist/states/CONCISE_HTML_CONTENT.d.ts +1 -1
- package/dist/states/DECLARATION.d.ts +1 -1
- package/dist/states/DTD.d.ts +1 -1
- package/dist/states/EXPRESSION.d.ts +1 -1
- package/dist/states/HTML_COMMENT.d.ts +1 -1
- package/dist/states/HTML_CONTENT.d.ts +1 -1
- package/dist/states/INLINE_SCRIPT.d.ts +1 -1
- package/dist/states/JS_COMMENT_BLOCK.d.ts +1 -1
- package/dist/states/JS_COMMENT_LINE.d.ts +1 -1
- package/dist/states/OPEN_TAG.d.ts +1 -1
- package/dist/states/PARSED_STRING.d.ts +1 -1
- package/dist/states/PARSED_TEXT_CONTENT.d.ts +1 -1
- package/dist/states/PLACEHOLDER.d.ts +1 -1
- package/dist/states/REGULAR_EXPRESSION.d.ts +1 -1
- package/dist/states/STRING.d.ts +1 -1
- package/dist/states/TAG_NAME.d.ts +1 -1
- package/dist/states/TEMPLATE_STRING.d.ts +1 -1
- package/dist/util/constants.d.ts +0 -1
- package/dist/util/util.d.ts +1 -1
- package/package.json +21 -19
package/dist/core/Parser.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -136,6 +136,7 @@ function getPosAfterLine(lines, startLine, index) {
|
|
|
136
136
|
|
|
137
137
|
// src/core/Parser.ts
|
|
138
138
|
var Parser = class {
|
|
139
|
+
// Keeps track of line indexes to provide line/column info.
|
|
139
140
|
constructor(options) {
|
|
140
141
|
this.options = options;
|
|
141
142
|
}
|
|
@@ -172,6 +173,9 @@ var Parser = class {
|
|
|
172
173
|
activeState.exit.call(this, activeRange);
|
|
173
174
|
this.activeState.return.call(this, activeRange, parent);
|
|
174
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Compare a position in the source to either another position, or a string.
|
|
178
|
+
*/
|
|
175
179
|
matchAtPos(a, b) {
|
|
176
180
|
const aPos = a.start;
|
|
177
181
|
const aLen = a.end - aPos;
|
|
@@ -201,6 +205,10 @@ var Parser = class {
|
|
|
201
205
|
}
|
|
202
206
|
return false;
|
|
203
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Look ahead to see if the given str matches the substring sequence
|
|
210
|
+
* beyond
|
|
211
|
+
*/
|
|
204
212
|
lookAheadFor(str, startPos = this.pos + 1) {
|
|
205
213
|
let i = str.length;
|
|
206
214
|
if (startPos + i <= this.maxPos) {
|
|
@@ -229,6 +237,12 @@ var Parser = class {
|
|
|
229
237
|
this.textPos = -1;
|
|
230
238
|
}
|
|
231
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* This is used to enter into "HTML" parsing mode instead
|
|
242
|
+
* of concise HTML. We push a block on to the stack so that we know when
|
|
243
|
+
* return back to the previous parsing mode and to ensure that all
|
|
244
|
+
* tags within a block are properly closed.
|
|
245
|
+
*/
|
|
232
246
|
beginHtmlBlock(delimiter, singleLine) {
|
|
233
247
|
var _a;
|
|
234
248
|
const content = this.enterState(
|
|
@@ -265,6 +279,7 @@ var Parser = class {
|
|
|
265
279
|
(_b = (_a = this.options).onCloseTagName) == null ? void 0 : _b.call(_a, name);
|
|
266
280
|
(_d = (_c = this.options).onCloseTagEnd) == null ? void 0 : _d.call(_c, { start, end });
|
|
267
281
|
}
|
|
282
|
+
// --------------------------
|
|
268
283
|
consumeWhitespaceIfBefore(str, start = 0) {
|
|
269
284
|
const { pos, data } = this;
|
|
270
285
|
let cur = pos + start;
|
|
@@ -519,8 +534,8 @@ var OPEN_TAG = {
|
|
|
519
534
|
}
|
|
520
535
|
return;
|
|
521
536
|
}
|
|
522
|
-
if (code === 45 /*
|
|
523
|
-
if (this.lookAtCharCodeAhead(1) !== 45 /*
|
|
537
|
+
if (code === 45 /* HYPHEN */) {
|
|
538
|
+
if (this.lookAtCharCodeAhead(1) !== 45 /* HYPHEN */) {
|
|
524
539
|
this.emitError(
|
|
525
540
|
tag,
|
|
526
541
|
19 /* MALFORMED_OPEN_TAG */,
|
|
@@ -685,6 +700,7 @@ var OPEN_TAG = {
|
|
|
685
700
|
}
|
|
686
701
|
(_b = (_a = this.options).onTagVar) == null ? void 0 : _b.call(_a, {
|
|
687
702
|
start: child.start - 1,
|
|
703
|
+
// include /,
|
|
688
704
|
end: child.end,
|
|
689
705
|
value: {
|
|
690
706
|
start: child.start,
|
|
@@ -734,6 +750,7 @@ var OPEN_TAG = {
|
|
|
734
750
|
const end = ++this.pos;
|
|
735
751
|
const types = {
|
|
736
752
|
start: child.start - 1,
|
|
753
|
+
// include <
|
|
737
754
|
end,
|
|
738
755
|
value: {
|
|
739
756
|
start: child.start,
|
|
@@ -964,6 +981,7 @@ var ATTRIBUTE = {
|
|
|
964
981
|
typeParams,
|
|
965
982
|
body: {
|
|
966
983
|
start: child.start - 1,
|
|
984
|
+
// include {
|
|
967
985
|
end,
|
|
968
986
|
value: {
|
|
969
987
|
start: child.start,
|
|
@@ -1132,7 +1150,7 @@ var BEGIN_DELIMITED_HTML_BLOCK = {
|
|
|
1132
1150
|
exit() {
|
|
1133
1151
|
},
|
|
1134
1152
|
char(code, block) {
|
|
1135
|
-
if (code === 45 /*
|
|
1153
|
+
if (code === 45 /* HYPHEN */) {
|
|
1136
1154
|
block.delimiter += "-";
|
|
1137
1155
|
} else {
|
|
1138
1156
|
const startPos = this.pos;
|
|
@@ -1215,7 +1233,9 @@ var CDATA = {
|
|
|
1215
1233
|
end: cdata.end,
|
|
1216
1234
|
value: {
|
|
1217
1235
|
start: cdata.start + 9,
|
|
1236
|
+
// strip <![CDATA[
|
|
1218
1237
|
end: cdata.end - 3
|
|
1238
|
+
// strip ]]>
|
|
1219
1239
|
}
|
|
1220
1240
|
});
|
|
1221
1241
|
},
|
|
@@ -1388,7 +1408,7 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1388
1408
|
}
|
|
1389
1409
|
}
|
|
1390
1410
|
if (parentTag) {
|
|
1391
|
-
if (parentTag.type === 1 /* text */ && code !== 45 /*
|
|
1411
|
+
if (parentTag.type === 1 /* text */ && code !== 45 /* HYPHEN */) {
|
|
1392
1412
|
this.emitError(
|
|
1393
1413
|
this.pos,
|
|
1394
1414
|
8 /* INVALID_LINE_START */,
|
|
@@ -1420,8 +1440,8 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1420
1440
|
return;
|
|
1421
1441
|
}
|
|
1422
1442
|
break;
|
|
1423
|
-
case 45 /*
|
|
1424
|
-
if (this.lookAtCharCodeAhead(1) === 45 /*
|
|
1443
|
+
case 45 /* HYPHEN */:
|
|
1444
|
+
if (this.lookAtCharCodeAhead(1) === 45 /* HYPHEN */) {
|
|
1425
1445
|
this.enterState(states_exports.BEGIN_DELIMITED_HTML_BLOCK);
|
|
1426
1446
|
this.pos--;
|
|
1427
1447
|
} else {
|
|
@@ -1470,6 +1490,7 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1470
1490
|
end: child.end,
|
|
1471
1491
|
value: {
|
|
1472
1492
|
start: child.start + 2,
|
|
1493
|
+
// strip //
|
|
1473
1494
|
end: child.end
|
|
1474
1495
|
}
|
|
1475
1496
|
});
|
|
@@ -1480,7 +1501,9 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1480
1501
|
end: child.end,
|
|
1481
1502
|
value: {
|
|
1482
1503
|
start: child.start + 2,
|
|
1504
|
+
// strip /*
|
|
1483
1505
|
end: child.end - 2
|
|
1506
|
+
// strip */,
|
|
1484
1507
|
}
|
|
1485
1508
|
});
|
|
1486
1509
|
if (!this.consumeWhitespaceOnLine(0)) {
|
|
@@ -1540,7 +1563,9 @@ function exitDeclaration(parser, declaration, closeOffset) {
|
|
|
1540
1563
|
end: declaration.end,
|
|
1541
1564
|
value: {
|
|
1542
1565
|
start: declaration.start + 2,
|
|
1566
|
+
// strip <?
|
|
1543
1567
|
end: declaration.end - closeOffset
|
|
1568
|
+
// > or ?>
|
|
1544
1569
|
}
|
|
1545
1570
|
});
|
|
1546
1571
|
}
|
|
@@ -1564,7 +1589,9 @@ var DTD = {
|
|
|
1564
1589
|
end: documentType.end,
|
|
1565
1590
|
value: {
|
|
1566
1591
|
start: documentType.start + 2,
|
|
1592
|
+
// strip <!
|
|
1567
1593
|
end: documentType.end - 1
|
|
1594
|
+
// strip >
|
|
1568
1595
|
}
|
|
1569
1596
|
});
|
|
1570
1597
|
},
|
|
@@ -1972,7 +1999,9 @@ var HTML_COMMENT = {
|
|
|
1972
1999
|
end: comment.end,
|
|
1973
2000
|
value: {
|
|
1974
2001
|
start: comment.start + 4,
|
|
2002
|
+
// strip <!--
|
|
1975
2003
|
end: comment.end - 3
|
|
2004
|
+
// strip -->
|
|
1976
2005
|
}
|
|
1977
2006
|
});
|
|
1978
2007
|
},
|
|
@@ -2098,6 +2127,7 @@ var HTML_CONTENT = {
|
|
|
2098
2127
|
end: child.end,
|
|
2099
2128
|
value: {
|
|
2100
2129
|
start: child.start + 2,
|
|
2130
|
+
// strip //
|
|
2101
2131
|
end: child.end
|
|
2102
2132
|
}
|
|
2103
2133
|
});
|
|
@@ -2108,7 +2138,9 @@ var HTML_CONTENT = {
|
|
|
2108
2138
|
end: child.end,
|
|
2109
2139
|
value: {
|
|
2110
2140
|
start: child.start + 2,
|
|
2141
|
+
// strip /*
|
|
2111
2142
|
end: child.end - 2
|
|
2143
|
+
// strip */,
|
|
2112
2144
|
}
|
|
2113
2145
|
});
|
|
2114
2146
|
break;
|
|
@@ -2331,7 +2363,9 @@ var PLACEHOLDER = {
|
|
|
2331
2363
|
escape: placeholder.escape,
|
|
2332
2364
|
value: {
|
|
2333
2365
|
start: placeholder.start + (placeholder.escape ? 2 : 3),
|
|
2366
|
+
// ignore ${ or $!{
|
|
2334
2367
|
end: placeholder.end - 1
|
|
2368
|
+
// ignore }
|
|
2335
2369
|
}
|
|
2336
2370
|
});
|
|
2337
2371
|
},
|
|
@@ -2700,15 +2734,27 @@ var PARSED_STRING = {
|
|
|
2700
2734
|
function createParser(handlers) {
|
|
2701
2735
|
const parser = new Parser(handlers);
|
|
2702
2736
|
return {
|
|
2737
|
+
/**
|
|
2738
|
+
* Parses code and calls the provided handlers.
|
|
2739
|
+
*/
|
|
2703
2740
|
parse(code) {
|
|
2704
2741
|
return parser.parse(code);
|
|
2705
2742
|
},
|
|
2743
|
+
/**
|
|
2744
|
+
* Given an offset range in the current source code, reads and returns the substring in the input code.
|
|
2745
|
+
*/
|
|
2706
2746
|
read(range) {
|
|
2707
2747
|
return parser.read(range);
|
|
2708
2748
|
},
|
|
2749
|
+
/**
|
|
2750
|
+
* Given a offset in the current source code, returns a Position object with line & character information.
|
|
2751
|
+
*/
|
|
2709
2752
|
positionAt(offset) {
|
|
2710
2753
|
return parser.positionAt(offset);
|
|
2711
2754
|
},
|
|
2755
|
+
/**
|
|
2756
|
+
* Given a offset range in the current source code, returns a Location object with a start & end position information.
|
|
2757
|
+
*/
|
|
2712
2758
|
locationAt(range) {
|
|
2713
2759
|
return parser.locationAt(range);
|
|
2714
2760
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -111,6 +111,7 @@ function getPosAfterLine(lines, startLine, index) {
|
|
|
111
111
|
|
|
112
112
|
// src/core/Parser.ts
|
|
113
113
|
var Parser = class {
|
|
114
|
+
// Keeps track of line indexes to provide line/column info.
|
|
114
115
|
constructor(options) {
|
|
115
116
|
this.options = options;
|
|
116
117
|
}
|
|
@@ -147,6 +148,9 @@ var Parser = class {
|
|
|
147
148
|
activeState.exit.call(this, activeRange);
|
|
148
149
|
this.activeState.return.call(this, activeRange, parent);
|
|
149
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Compare a position in the source to either another position, or a string.
|
|
153
|
+
*/
|
|
150
154
|
matchAtPos(a, b) {
|
|
151
155
|
const aPos = a.start;
|
|
152
156
|
const aLen = a.end - aPos;
|
|
@@ -176,6 +180,10 @@ var Parser = class {
|
|
|
176
180
|
}
|
|
177
181
|
return false;
|
|
178
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Look ahead to see if the given str matches the substring sequence
|
|
185
|
+
* beyond
|
|
186
|
+
*/
|
|
179
187
|
lookAheadFor(str, startPos = this.pos + 1) {
|
|
180
188
|
let i = str.length;
|
|
181
189
|
if (startPos + i <= this.maxPos) {
|
|
@@ -204,6 +212,12 @@ var Parser = class {
|
|
|
204
212
|
this.textPos = -1;
|
|
205
213
|
}
|
|
206
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* This is used to enter into "HTML" parsing mode instead
|
|
217
|
+
* of concise HTML. We push a block on to the stack so that we know when
|
|
218
|
+
* return back to the previous parsing mode and to ensure that all
|
|
219
|
+
* tags within a block are properly closed.
|
|
220
|
+
*/
|
|
207
221
|
beginHtmlBlock(delimiter, singleLine) {
|
|
208
222
|
var _a;
|
|
209
223
|
const content = this.enterState(
|
|
@@ -240,6 +254,7 @@ var Parser = class {
|
|
|
240
254
|
(_b = (_a = this.options).onCloseTagName) == null ? void 0 : _b.call(_a, name);
|
|
241
255
|
(_d = (_c = this.options).onCloseTagEnd) == null ? void 0 : _d.call(_c, { start, end });
|
|
242
256
|
}
|
|
257
|
+
// --------------------------
|
|
243
258
|
consumeWhitespaceIfBefore(str, start = 0) {
|
|
244
259
|
const { pos, data } = this;
|
|
245
260
|
let cur = pos + start;
|
|
@@ -494,8 +509,8 @@ var OPEN_TAG = {
|
|
|
494
509
|
}
|
|
495
510
|
return;
|
|
496
511
|
}
|
|
497
|
-
if (code === 45 /*
|
|
498
|
-
if (this.lookAtCharCodeAhead(1) !== 45 /*
|
|
512
|
+
if (code === 45 /* HYPHEN */) {
|
|
513
|
+
if (this.lookAtCharCodeAhead(1) !== 45 /* HYPHEN */) {
|
|
499
514
|
this.emitError(
|
|
500
515
|
tag,
|
|
501
516
|
19 /* MALFORMED_OPEN_TAG */,
|
|
@@ -660,6 +675,7 @@ var OPEN_TAG = {
|
|
|
660
675
|
}
|
|
661
676
|
(_b = (_a = this.options).onTagVar) == null ? void 0 : _b.call(_a, {
|
|
662
677
|
start: child.start - 1,
|
|
678
|
+
// include /,
|
|
663
679
|
end: child.end,
|
|
664
680
|
value: {
|
|
665
681
|
start: child.start,
|
|
@@ -709,6 +725,7 @@ var OPEN_TAG = {
|
|
|
709
725
|
const end = ++this.pos;
|
|
710
726
|
const types = {
|
|
711
727
|
start: child.start - 1,
|
|
728
|
+
// include <
|
|
712
729
|
end,
|
|
713
730
|
value: {
|
|
714
731
|
start: child.start,
|
|
@@ -939,6 +956,7 @@ var ATTRIBUTE = {
|
|
|
939
956
|
typeParams,
|
|
940
957
|
body: {
|
|
941
958
|
start: child.start - 1,
|
|
959
|
+
// include {
|
|
942
960
|
end,
|
|
943
961
|
value: {
|
|
944
962
|
start: child.start,
|
|
@@ -1107,7 +1125,7 @@ var BEGIN_DELIMITED_HTML_BLOCK = {
|
|
|
1107
1125
|
exit() {
|
|
1108
1126
|
},
|
|
1109
1127
|
char(code, block) {
|
|
1110
|
-
if (code === 45 /*
|
|
1128
|
+
if (code === 45 /* HYPHEN */) {
|
|
1111
1129
|
block.delimiter += "-";
|
|
1112
1130
|
} else {
|
|
1113
1131
|
const startPos = this.pos;
|
|
@@ -1190,7 +1208,9 @@ var CDATA = {
|
|
|
1190
1208
|
end: cdata.end,
|
|
1191
1209
|
value: {
|
|
1192
1210
|
start: cdata.start + 9,
|
|
1211
|
+
// strip <![CDATA[
|
|
1193
1212
|
end: cdata.end - 3
|
|
1213
|
+
// strip ]]>
|
|
1194
1214
|
}
|
|
1195
1215
|
});
|
|
1196
1216
|
},
|
|
@@ -1363,7 +1383,7 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1363
1383
|
}
|
|
1364
1384
|
}
|
|
1365
1385
|
if (parentTag) {
|
|
1366
|
-
if (parentTag.type === 1 /* text */ && code !== 45 /*
|
|
1386
|
+
if (parentTag.type === 1 /* text */ && code !== 45 /* HYPHEN */) {
|
|
1367
1387
|
this.emitError(
|
|
1368
1388
|
this.pos,
|
|
1369
1389
|
8 /* INVALID_LINE_START */,
|
|
@@ -1395,8 +1415,8 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1395
1415
|
return;
|
|
1396
1416
|
}
|
|
1397
1417
|
break;
|
|
1398
|
-
case 45 /*
|
|
1399
|
-
if (this.lookAtCharCodeAhead(1) === 45 /*
|
|
1418
|
+
case 45 /* HYPHEN */:
|
|
1419
|
+
if (this.lookAtCharCodeAhead(1) === 45 /* HYPHEN */) {
|
|
1400
1420
|
this.enterState(states_exports.BEGIN_DELIMITED_HTML_BLOCK);
|
|
1401
1421
|
this.pos--;
|
|
1402
1422
|
} else {
|
|
@@ -1445,6 +1465,7 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1445
1465
|
end: child.end,
|
|
1446
1466
|
value: {
|
|
1447
1467
|
start: child.start + 2,
|
|
1468
|
+
// strip //
|
|
1448
1469
|
end: child.end
|
|
1449
1470
|
}
|
|
1450
1471
|
});
|
|
@@ -1455,7 +1476,9 @@ var CONCISE_HTML_CONTENT = {
|
|
|
1455
1476
|
end: child.end,
|
|
1456
1477
|
value: {
|
|
1457
1478
|
start: child.start + 2,
|
|
1479
|
+
// strip /*
|
|
1458
1480
|
end: child.end - 2
|
|
1481
|
+
// strip */,
|
|
1459
1482
|
}
|
|
1460
1483
|
});
|
|
1461
1484
|
if (!this.consumeWhitespaceOnLine(0)) {
|
|
@@ -1515,7 +1538,9 @@ function exitDeclaration(parser, declaration, closeOffset) {
|
|
|
1515
1538
|
end: declaration.end,
|
|
1516
1539
|
value: {
|
|
1517
1540
|
start: declaration.start + 2,
|
|
1541
|
+
// strip <?
|
|
1518
1542
|
end: declaration.end - closeOffset
|
|
1543
|
+
// > or ?>
|
|
1519
1544
|
}
|
|
1520
1545
|
});
|
|
1521
1546
|
}
|
|
@@ -1539,7 +1564,9 @@ var DTD = {
|
|
|
1539
1564
|
end: documentType.end,
|
|
1540
1565
|
value: {
|
|
1541
1566
|
start: documentType.start + 2,
|
|
1567
|
+
// strip <!
|
|
1542
1568
|
end: documentType.end - 1
|
|
1569
|
+
// strip >
|
|
1543
1570
|
}
|
|
1544
1571
|
});
|
|
1545
1572
|
},
|
|
@@ -1947,7 +1974,9 @@ var HTML_COMMENT = {
|
|
|
1947
1974
|
end: comment.end,
|
|
1948
1975
|
value: {
|
|
1949
1976
|
start: comment.start + 4,
|
|
1977
|
+
// strip <!--
|
|
1950
1978
|
end: comment.end - 3
|
|
1979
|
+
// strip -->
|
|
1951
1980
|
}
|
|
1952
1981
|
});
|
|
1953
1982
|
},
|
|
@@ -2073,6 +2102,7 @@ var HTML_CONTENT = {
|
|
|
2073
2102
|
end: child.end,
|
|
2074
2103
|
value: {
|
|
2075
2104
|
start: child.start + 2,
|
|
2105
|
+
// strip //
|
|
2076
2106
|
end: child.end
|
|
2077
2107
|
}
|
|
2078
2108
|
});
|
|
@@ -2083,7 +2113,9 @@ var HTML_CONTENT = {
|
|
|
2083
2113
|
end: child.end,
|
|
2084
2114
|
value: {
|
|
2085
2115
|
start: child.start + 2,
|
|
2116
|
+
// strip /*
|
|
2086
2117
|
end: child.end - 2
|
|
2118
|
+
// strip */,
|
|
2087
2119
|
}
|
|
2088
2120
|
});
|
|
2089
2121
|
break;
|
|
@@ -2306,7 +2338,9 @@ var PLACEHOLDER = {
|
|
|
2306
2338
|
escape: placeholder.escape,
|
|
2307
2339
|
value: {
|
|
2308
2340
|
start: placeholder.start + (placeholder.escape ? 2 : 3),
|
|
2341
|
+
// ignore ${ or $!{
|
|
2309
2342
|
end: placeholder.end - 1
|
|
2343
|
+
// ignore }
|
|
2310
2344
|
}
|
|
2311
2345
|
});
|
|
2312
2346
|
},
|
|
@@ -2675,15 +2709,27 @@ var PARSED_STRING = {
|
|
|
2675
2709
|
function createParser(handlers) {
|
|
2676
2710
|
const parser = new Parser(handlers);
|
|
2677
2711
|
return {
|
|
2712
|
+
/**
|
|
2713
|
+
* Parses code and calls the provided handlers.
|
|
2714
|
+
*/
|
|
2678
2715
|
parse(code) {
|
|
2679
2716
|
return parser.parse(code);
|
|
2680
2717
|
},
|
|
2718
|
+
/**
|
|
2719
|
+
* Given an offset range in the current source code, reads and returns the substring in the input code.
|
|
2720
|
+
*/
|
|
2681
2721
|
read(range) {
|
|
2682
2722
|
return parser.read(range);
|
|
2683
2723
|
},
|
|
2724
|
+
/**
|
|
2725
|
+
* Given a offset in the current source code, returns a Position object with line & character information.
|
|
2726
|
+
*/
|
|
2684
2727
|
positionAt(offset) {
|
|
2685
2728
|
return parser.positionAt(offset);
|
|
2686
2729
|
},
|
|
2730
|
+
/**
|
|
2731
|
+
* Given a offset range in the current source code, returns a Location object with a start & end position information.
|
|
2732
|
+
*/
|
|
2687
2733
|
locationAt(range) {
|
|
2688
2734
|
return parser.locationAt(range);
|
|
2689
2735
|
}
|
package/dist/states/CDATA.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const CONCISE_HTML_CONTENT: StateDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const DECLARATION: StateDefinition;
|
package/dist/states/DTD.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const DTD: StateDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const HTML_COMMENT: StateDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const JS_COMMENT_BLOCK: StateDefinition;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const JS_COMMENT_LINE: StateDefinition;
|
package/dist/states/STRING.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { StateDefinition } from "../internal";
|
|
1
|
+
import { type StateDefinition } from "../internal";
|
|
2
2
|
export declare const TEMPLATE_STRING: StateDefinition;
|
package/dist/util/constants.d.ts
CHANGED
package/dist/util/util.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Parser } from "../internal";
|
|
2
|
-
import { Location, Position } from "./constants";
|
|
2
|
+
import { type Location, type Position } from "./constants";
|
|
3
3
|
export declare function isWhitespaceCode(code: number): boolean;
|
|
4
4
|
/**
|
|
5
5
|
* Given a source code line offsets, a start offset and an end offset, returns a Location object with line & character information for the start and end offsets.
|
package/package.json
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "htmljs-parser",
|
|
3
3
|
"description": "An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values",
|
|
4
|
-
"version": "5.5.
|
|
4
|
+
"version": "5.5.2",
|
|
5
5
|
"devDependencies": {
|
|
6
|
-
"@changesets/changelog-github": "^0.
|
|
7
|
-
"@changesets/cli": "^2.
|
|
8
|
-
"@types/degit": "^2.8.
|
|
9
|
-
"@types/mocha": "^10.0.
|
|
10
|
-
"@types/node": "^
|
|
11
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
12
|
-
"@typescript-eslint/parser": "^
|
|
6
|
+
"@changesets/changelog-github": "^0.5.0",
|
|
7
|
+
"@changesets/cli": "^2.27.1",
|
|
8
|
+
"@types/degit": "^2.8.6",
|
|
9
|
+
"@types/mocha": "^10.0.6",
|
|
10
|
+
"@types/node": "^20.10.6",
|
|
11
|
+
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
12
|
+
"@typescript-eslint/parser": "^6.17.0",
|
|
13
13
|
"cross-env": "^7.0.3",
|
|
14
14
|
"degit": "^2.8.4",
|
|
15
|
-
"esbuild": "0.
|
|
16
|
-
"eslint": "^8.
|
|
17
|
-
"eslint-config-prettier": "^
|
|
18
|
-
"
|
|
15
|
+
"esbuild": "0.19.11",
|
|
16
|
+
"eslint": "^8.56.0",
|
|
17
|
+
"eslint-config-prettier": "^9.1.0",
|
|
18
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
19
|
+
"eslint-plugin-import": "^2.29.1",
|
|
20
|
+
"fast-glob": "^3.3.2",
|
|
19
21
|
"fixpack": "^4.0.0",
|
|
20
|
-
"husky": "^8.0.
|
|
21
|
-
"lint-staged": "^
|
|
22
|
+
"husky": "^8.0.3",
|
|
23
|
+
"lint-staged": "^15.2.0",
|
|
22
24
|
"mitata": "^0.1.6",
|
|
23
|
-
"mocha": "^10.
|
|
24
|
-
"mocha-snap": "^
|
|
25
|
+
"mocha": "^10.2.0",
|
|
26
|
+
"mocha-snap": "^5.0.0",
|
|
25
27
|
"nyc": "^15.1.0",
|
|
26
|
-
"prettier": "^
|
|
27
|
-
"tsx": "^
|
|
28
|
-
"typescript": "^
|
|
28
|
+
"prettier": "^3.1.1",
|
|
29
|
+
"tsx": "^4.7.0",
|
|
30
|
+
"typescript": "^5.3.3"
|
|
29
31
|
},
|
|
30
32
|
"exports": {
|
|
31
33
|
".": {
|