@markuplint/astro-parser 3.3.0 → 3.4.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/lib/astro-parser.d.ts +2 -2
- package/lib/attr-tokenizer.js +9 -9
- package/lib/index.d.ts +1 -1
- package/lib/parse.js +3 -2
- package/package.json +4 -4
package/lib/astro-parser.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type ASTNode = TemplateNode;
|
|
|
5
5
|
export type ASTStyleNode = Style;
|
|
6
6
|
export type ASTAttribute = Attribute;
|
|
7
7
|
export type AstroAST = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
html?: ASTNode;
|
|
9
|
+
style?: ASTStyleNode[];
|
|
10
10
|
};
|
|
11
11
|
export declare function astroParse(code: string): AstroAST | AstroCompileError;
|
package/lib/attr-tokenizer.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.attrTokenizer = void 0;
|
|
4
4
|
const parser_utils_1 = require("@markuplint/parser-utils");
|
|
5
5
|
function attrTokenizer(attr, rawHtml, codeOffset) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
7
7
|
const { raw, startOffset } = (0, parser_utils_1.sliceFragment)(rawHtml, attr.start + codeOffset, attr.end + codeOffset);
|
|
8
8
|
const isDynamicValue = ((_b = (_a = attr.value) === null || _a === void 0 ? void 0 : _a.some) === null || _b === void 0 ? void 0 : _b.call(_a, v => {
|
|
9
9
|
// @ts-ignore
|
|
@@ -28,21 +28,21 @@ function attrTokenizer(attr, rawHtml, codeOffset) {
|
|
|
28
28
|
rawValueStart = name.endOffset;
|
|
29
29
|
}
|
|
30
30
|
else if (isDynamicValue) {
|
|
31
|
-
rawValue = attr.value[0].expression.codeChunks.join('');
|
|
32
|
-
rawValueStart = attr.value[0].expression.start;
|
|
31
|
+
rawValue = (_d = (_c = attr.value[0]) === null || _c === void 0 ? void 0 : _c.expression.codeChunks.join('')) !== null && _d !== void 0 ? _d : '';
|
|
32
|
+
rawValueStart = (_f = (_e = attr.value[0]) === null || _e === void 0 ? void 0 : _e.expression.start) !== null && _f !== void 0 ? _f : name.endOffset;
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
rawValue = attr.value[0].raw;
|
|
36
|
-
rawValueStart = attr.value[0].start;
|
|
35
|
+
rawValue = (_h = (_g = attr.value[0]) === null || _g === void 0 ? void 0 : _g.raw) !== null && _h !== void 0 ? _h : '';
|
|
36
|
+
rawValueStart = (_k = (_j = attr.value[0]) === null || _j === void 0 ? void 0 : _j.start) !== null && _k !== void 0 ? _k : name.endOffset;
|
|
37
37
|
}
|
|
38
38
|
const value = (0, parser_utils_1.createTokenFromRawCode)(rawValue, rawValueStart + codeOffset, rawHtml);
|
|
39
39
|
const eq = (0, parser_utils_1.sliceFragment)(rawHtml, name.endOffset, value.startOffset);
|
|
40
40
|
const eqRegexp = /^(?<bs>\s*)(?<eq>=)(?<as>\s*)(?<squot>"|'|{)?$/g;
|
|
41
41
|
const exp = eqRegexp.exec(eq.raw);
|
|
42
|
-
const bsChar = ((
|
|
43
|
-
const eqChar = ((
|
|
44
|
-
const asChar = ((
|
|
45
|
-
const squotChar = ((
|
|
42
|
+
const bsChar = ((_l = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _l === void 0 ? void 0 : _l.bs) || '';
|
|
43
|
+
const eqChar = ((_m = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _m === void 0 ? void 0 : _m.eq) || '';
|
|
44
|
+
const asChar = ((_o = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _o === void 0 ? void 0 : _o.as) || '';
|
|
45
|
+
const squotChar = ((_p = exp === null || exp === void 0 ? void 0 : exp.groups) === null || _p === void 0 ? void 0 : _p.squot) || '';
|
|
46
46
|
const spacesBeforeEqual = (0, parser_utils_1.createTokenFromRawCode)(bsChar, name.endOffset, rawHtml);
|
|
47
47
|
const equal = (0, parser_utils_1.createTokenFromRawCode)(eqChar, spacesBeforeEqual.endOffset, rawHtml);
|
|
48
48
|
const spacesAfterEqual = (0, parser_utils_1.createTokenFromRawCode)(asChar, equal.endOffset, rawHtml);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { parse } from './parse';
|
|
2
|
-
export declare const endTag =
|
|
2
|
+
export declare const endTag = 'xml';
|
package/lib/parse.js
CHANGED
|
@@ -31,7 +31,7 @@ const parse = (rawCode, options) => {
|
|
|
31
31
|
if (templateEndTagIndex !== -1) {
|
|
32
32
|
const templateEndTag = nodeList[templateEndTagIndex];
|
|
33
33
|
for (const node of nodeList) {
|
|
34
|
-
if (node.nextNode && node.nextNode.uuid === templateEndTag.uuid) {
|
|
34
|
+
if (node.nextNode && node.nextNode.uuid === (templateEndTag === null || templateEndTag === void 0 ? void 0 : templateEndTag.uuid)) {
|
|
35
35
|
node.nextNode = null;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -223,12 +223,13 @@ function nodeize(originNode, prevNode, parentNode, scopeNS, rawHtml, offset = 0,
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
function parseElement(nodeName, originNode, scopeNS, rawHtml, startLine, startCol, startOffset, parentNode, prevNode, nextNode, offset, options) {
|
|
226
|
+
var _a, _b;
|
|
226
227
|
const { raw } = (0, parser_utils_1.sliceFragment)(rawHtml, originNode.start + offset, originNode.end + offset);
|
|
227
228
|
let childrenStart;
|
|
228
229
|
let childrenEnd;
|
|
229
230
|
if (originNode.children && originNode.children[0]) {
|
|
230
231
|
childrenStart = originNode.children[0].start + offset;
|
|
231
|
-
childrenEnd = originNode.children[originNode.children.length - 1].end + offset;
|
|
232
|
+
childrenEnd = ((_b = (_a = originNode.children[originNode.children.length - 1]) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : 0) + offset;
|
|
232
233
|
}
|
|
233
234
|
else if (originNode.content) {
|
|
234
235
|
childrenStart = originNode.content.start + offset;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/astro-parser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "astro parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@astrojs/parser": "0.20",
|
|
20
|
-
"@markuplint/html-parser": "3.
|
|
20
|
+
"@markuplint/html-parser": "3.4.0",
|
|
21
21
|
"@markuplint/ml-ast": "3.0.0",
|
|
22
|
-
"@markuplint/parser-utils": "3.
|
|
22
|
+
"@markuplint/parser-utils": "3.4.0",
|
|
23
23
|
"tslib": "^2.4.1"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
|
|
26
26
|
}
|