htmljs-parser 5.5.4 → 5.6.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/core/Parser.d.ts +2 -2
- package/dist/index.js +9 -8
- package/dist/index.mjs +9 -8
- package/dist/states/EXPRESSION.d.ts +1 -0
- package/dist/util/util.d.ts +6 -5
- package/package.json +1 -1
package/dist/core/Parser.d.ts
CHANGED
|
@@ -32,8 +32,8 @@ export declare class Parser {
|
|
|
32
32
|
lines: undefined | number[];
|
|
33
33
|
constructor(options: Options);
|
|
34
34
|
read(range: Range): string;
|
|
35
|
-
positionAt(offset: number): import("
|
|
36
|
-
locationAt(range: Range): import("
|
|
35
|
+
positionAt(offset: number): import("..").Position;
|
|
36
|
+
locationAt(range: Range): import("..").Location;
|
|
37
37
|
enterState<P extends Meta>(state: StateDefinition<P>): P;
|
|
38
38
|
exitState(): void;
|
|
39
39
|
/**
|
package/dist/index.js
CHANGED
|
@@ -74,6 +74,9 @@ var TagType = /* @__PURE__ */ ((TagType2) => {
|
|
|
74
74
|
function isWhitespaceCode(code) {
|
|
75
75
|
return code <= 32 /* SPACE */;
|
|
76
76
|
}
|
|
77
|
+
function isIndentCode(code) {
|
|
78
|
+
return code === 9 /* TAB */ || code === 32 /* SPACE */;
|
|
79
|
+
}
|
|
77
80
|
function getLocation(lines, startOffset, endOffset) {
|
|
78
81
|
const start = getPosition(lines, startOffset);
|
|
79
82
|
const end = startOffset === endOffset ? start : getPosAfterLine(lines, start.line, endOffset);
|
|
@@ -558,8 +561,7 @@ var OPEN_TAG = {
|
|
|
558
561
|
;
|
|
559
562
|
const indentStart = ++curPos;
|
|
560
563
|
while (curPos < maxPos) {
|
|
561
|
-
|
|
562
|
-
if (nextCode === 32 /* SPACE */ || nextCode === 9 /* TAB */) {
|
|
564
|
+
if (isIndentCode(this.data.charCodeAt(curPos))) {
|
|
563
565
|
curPos++;
|
|
564
566
|
} else {
|
|
565
567
|
break;
|
|
@@ -1646,7 +1648,8 @@ var EXPRESSION = {
|
|
|
1646
1648
|
operators: false,
|
|
1647
1649
|
wasComment: false,
|
|
1648
1650
|
terminatedByEOL: false,
|
|
1649
|
-
terminatedByWhitespace: false
|
|
1651
|
+
terminatedByWhitespace: false,
|
|
1652
|
+
consumeIndentedContent: false
|
|
1650
1653
|
};
|
|
1651
1654
|
},
|
|
1652
1655
|
exit() {
|
|
@@ -1740,8 +1743,8 @@ var EXPRESSION = {
|
|
|
1740
1743
|
}
|
|
1741
1744
|
}
|
|
1742
1745
|
},
|
|
1743
|
-
eol(
|
|
1744
|
-
if (!expression.groupStack.length && (expression.terminatedByEOL || expression.terminatedByWhitespace) && (expression.wasComment || !checkForOperators(this, expression, true))) {
|
|
1746
|
+
eol(len, expression) {
|
|
1747
|
+
if (!expression.groupStack.length && (expression.terminatedByEOL || expression.terminatedByWhitespace) && (expression.wasComment || !checkForOperators(this, expression, true)) && !(expression.consumeIndentedContent && isIndentCode(this.lookAtCharCodeAhead(len + 1)))) {
|
|
1745
1748
|
this.exitState();
|
|
1746
1749
|
}
|
|
1747
1750
|
expression.wasComment = false;
|
|
@@ -1946,9 +1949,6 @@ function canFollowDivision(code) {
|
|
|
1946
1949
|
function isWordCode(code) {
|
|
1947
1950
|
return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code == 36 /* DOLLAR */ || code === 95 /* UNDERSCORE */;
|
|
1948
1951
|
}
|
|
1949
|
-
function isIndentCode(code) {
|
|
1950
|
-
return code === 9 /* TAB */ || code === 32 /* SPACE */;
|
|
1951
|
-
}
|
|
1952
1952
|
function lookAheadWhile(match, data, pos) {
|
|
1953
1953
|
const max = data.length;
|
|
1954
1954
|
for (let i = pos; i < max; i++) {
|
|
@@ -2599,6 +2599,7 @@ var TAG_NAME = {
|
|
|
2599
2599
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
2600
2600
|
expr.operators = true;
|
|
2601
2601
|
expr.terminatedByEOL = true;
|
|
2602
|
+
expr.consumeIndentedContent = true;
|
|
2602
2603
|
}
|
|
2603
2604
|
}
|
|
2604
2605
|
break;
|
package/dist/index.mjs
CHANGED
|
@@ -49,6 +49,9 @@ var TagType = /* @__PURE__ */ ((TagType2) => {
|
|
|
49
49
|
function isWhitespaceCode(code) {
|
|
50
50
|
return code <= 32 /* SPACE */;
|
|
51
51
|
}
|
|
52
|
+
function isIndentCode(code) {
|
|
53
|
+
return code === 9 /* TAB */ || code === 32 /* SPACE */;
|
|
54
|
+
}
|
|
52
55
|
function getLocation(lines, startOffset, endOffset) {
|
|
53
56
|
const start = getPosition(lines, startOffset);
|
|
54
57
|
const end = startOffset === endOffset ? start : getPosAfterLine(lines, start.line, endOffset);
|
|
@@ -533,8 +536,7 @@ var OPEN_TAG = {
|
|
|
533
536
|
;
|
|
534
537
|
const indentStart = ++curPos;
|
|
535
538
|
while (curPos < maxPos) {
|
|
536
|
-
|
|
537
|
-
if (nextCode === 32 /* SPACE */ || nextCode === 9 /* TAB */) {
|
|
539
|
+
if (isIndentCode(this.data.charCodeAt(curPos))) {
|
|
538
540
|
curPos++;
|
|
539
541
|
} else {
|
|
540
542
|
break;
|
|
@@ -1621,7 +1623,8 @@ var EXPRESSION = {
|
|
|
1621
1623
|
operators: false,
|
|
1622
1624
|
wasComment: false,
|
|
1623
1625
|
terminatedByEOL: false,
|
|
1624
|
-
terminatedByWhitespace: false
|
|
1626
|
+
terminatedByWhitespace: false,
|
|
1627
|
+
consumeIndentedContent: false
|
|
1625
1628
|
};
|
|
1626
1629
|
},
|
|
1627
1630
|
exit() {
|
|
@@ -1715,8 +1718,8 @@ var EXPRESSION = {
|
|
|
1715
1718
|
}
|
|
1716
1719
|
}
|
|
1717
1720
|
},
|
|
1718
|
-
eol(
|
|
1719
|
-
if (!expression.groupStack.length && (expression.terminatedByEOL || expression.terminatedByWhitespace) && (expression.wasComment || !checkForOperators(this, expression, true))) {
|
|
1721
|
+
eol(len, expression) {
|
|
1722
|
+
if (!expression.groupStack.length && (expression.terminatedByEOL || expression.terminatedByWhitespace) && (expression.wasComment || !checkForOperators(this, expression, true)) && !(expression.consumeIndentedContent && isIndentCode(this.lookAtCharCodeAhead(len + 1)))) {
|
|
1720
1723
|
this.exitState();
|
|
1721
1724
|
}
|
|
1722
1725
|
expression.wasComment = false;
|
|
@@ -1921,9 +1924,6 @@ function canFollowDivision(code) {
|
|
|
1921
1924
|
function isWordCode(code) {
|
|
1922
1925
|
return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code == 36 /* DOLLAR */ || code === 95 /* UNDERSCORE */;
|
|
1923
1926
|
}
|
|
1924
|
-
function isIndentCode(code) {
|
|
1925
|
-
return code === 9 /* TAB */ || code === 32 /* SPACE */;
|
|
1926
|
-
}
|
|
1927
1927
|
function lookAheadWhile(match, data, pos) {
|
|
1928
1928
|
const max = data.length;
|
|
1929
1929
|
for (let i = pos; i < max; i++) {
|
|
@@ -2574,6 +2574,7 @@ var TAG_NAME = {
|
|
|
2574
2574
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
2575
2575
|
expr.operators = true;
|
|
2576
2576
|
expr.terminatedByEOL = true;
|
|
2577
|
+
expr.consumeIndentedContent = true;
|
|
2577
2578
|
}
|
|
2578
2579
|
}
|
|
2579
2580
|
break;
|
|
@@ -5,6 +5,7 @@ export interface ExpressionMeta extends Meta {
|
|
|
5
5
|
wasComment: boolean;
|
|
6
6
|
terminatedByEOL: boolean;
|
|
7
7
|
terminatedByWhitespace: boolean;
|
|
8
|
+
consumeIndentedContent: boolean;
|
|
8
9
|
shouldTerminate(code: number, data: string, pos: number): boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const EXPRESSION: StateDefinition<ExpressionMeta>;
|
package/dist/util/util.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type Parser } from "../internal";
|
|
1
|
+
import { CODE, type Parser } from "../internal";
|
|
2
2
|
import { type Location, type Position } from "./constants";
|
|
3
3
|
export declare function isWhitespaceCode(code: number): boolean;
|
|
4
|
+
export declare function isIndentCode(code: number): code is CODE.SPACE | CODE.TAB;
|
|
4
5
|
/**
|
|
5
6
|
* 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.
|
|
6
7
|
*/
|
|
@@ -15,7 +16,7 @@ export declare function getPosition(lines: number[], offset: number): Position;
|
|
|
15
16
|
*/
|
|
16
17
|
export declare function getLines(src: string): number[];
|
|
17
18
|
export declare function htmlEOF(this: Parser): void;
|
|
18
|
-
export declare function matchesCloseAngleBracket(code: number):
|
|
19
|
-
export declare function matchesCloseParen(code: number):
|
|
20
|
-
export declare function matchesCloseCurlyBrace(code: number):
|
|
21
|
-
export declare function matchesPipe(code: number):
|
|
19
|
+
export declare function matchesCloseAngleBracket(code: number): code is CODE.CLOSE_ANGLE_BRACKET;
|
|
20
|
+
export declare function matchesCloseParen(code: number): code is CODE.CLOSE_PAREN;
|
|
21
|
+
export declare function matchesCloseCurlyBrace(code: number): code is CODE.CLOSE_CURLY_BRACE;
|
|
22
|
+
export declare function matchesPipe(code: number): code is CODE.PIPE;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
4
|
+
"version": "5.6.0",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@changesets/changelog-github": "^0.5.0",
|
|
7
7
|
"@changesets/cli": "^2.27.1",
|