@markuplint/astro-parser 3.6.0 → 3.6.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/lib/parse.js +21 -7
- package/package.json +4 -4
package/lib/parse.js
CHANGED
|
@@ -233,25 +233,42 @@ nextNode, offset, options) {
|
|
|
233
233
|
if (!originNode.position) {
|
|
234
234
|
throw new TypeError("Node doesn't have position");
|
|
235
235
|
}
|
|
236
|
+
let startTagRaw;
|
|
236
237
|
let childrenStart;
|
|
237
238
|
let childrenEnd;
|
|
238
239
|
if (originNode.children[0]) {
|
|
239
240
|
childrenStart = ((_c = (_b = (_a = originNode.children[0].position) === null || _a === void 0 ? void 0 : _a.start) === null || _b === void 0 ? void 0 : _b.offset) !== null && _c !== void 0 ? _c : 0) + offset;
|
|
240
241
|
childrenEnd = ((_g = (_f = (_e = (_d = originNode.children[originNode.children.length - 1]) === null || _d === void 0 ? void 0 : _d.position) === null || _e === void 0 ? void 0 : _e.end) === null || _f === void 0 ? void 0 : _f.offset) !== null && _g !== void 0 ? _g : 0) + offset;
|
|
242
|
+
const startTagStartOffset = originNode.position.start.offset + offset;
|
|
243
|
+
const startTagEndOffset = childrenStart;
|
|
244
|
+
startTagRaw = rawHtml.slice(startTagStartOffset, startTagEndOffset);
|
|
241
245
|
}
|
|
242
246
|
else {
|
|
243
247
|
childrenStart = offset + ((_k = (_j = (_h = originNode.position.end) === null || _h === void 0 ? void 0 : _h.offset) !== null && _j !== void 0 ? _j : nextNode === null || nextNode === void 0 ? void 0 : nextNode.endOffset) !== null && _k !== void 0 ? _k : rawHtml.length - offset);
|
|
244
248
|
childrenEnd = childrenStart;
|
|
245
249
|
const startTagStartOffset = originNode.position.start.offset + offset;
|
|
246
|
-
|
|
247
|
-
|
|
250
|
+
let startTagEndOffset = childrenStart;
|
|
251
|
+
startTagRaw = rawHtml.slice(startTagStartOffset, startTagEndOffset);
|
|
248
252
|
const expectedCloseTag = `</${originNode.name}>`;
|
|
249
|
-
if (
|
|
253
|
+
if (startTagRaw.includes(expectedCloseTag)) {
|
|
250
254
|
childrenStart -= expectedCloseTag.length;
|
|
251
255
|
childrenEnd = childrenStart;
|
|
256
|
+
startTagRaw = startTagRaw.replace(expectedCloseTag, '');
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
let startTagRawMasked = startTagRaw;
|
|
260
|
+
for (const attr of originNode.attributes) {
|
|
261
|
+
startTagRawMasked = startTagRawMasked.replace(attr.value, ' '.repeat(attr.value.length));
|
|
262
|
+
}
|
|
263
|
+
const closeChars = '>';
|
|
264
|
+
const closeOffset = startTagRawMasked.indexOf(closeChars) + closeChars.length;
|
|
265
|
+
startTagEndOffset = startTagStartOffset + closeOffset;
|
|
266
|
+
startTagRaw = rawHtml.slice(startTagStartOffset, startTagEndOffset);
|
|
252
267
|
}
|
|
253
268
|
// console.log({
|
|
254
|
-
//
|
|
269
|
+
// originNode,
|
|
270
|
+
// attrs: originNode.attributes,
|
|
271
|
+
// startTagRaw,
|
|
255
272
|
// startTagStartOffset,
|
|
256
273
|
// startTagEndOffset,
|
|
257
274
|
// expectedCloseTag,
|
|
@@ -259,9 +276,6 @@ nextNode, offset, options) {
|
|
|
259
276
|
// childrenEnd,
|
|
260
277
|
// });
|
|
261
278
|
}
|
|
262
|
-
const startTagStartOffset = originNode.position.start.offset + offset;
|
|
263
|
-
const startTagEndOffset = childrenStart;
|
|
264
|
-
const startTagRaw = rawHtml.slice(startTagStartOffset, startTagEndOffset);
|
|
265
279
|
const tagTokens = (0, html_parser_1.parseRawTag)(startTagRaw, startLine, startCol, startOffset);
|
|
266
280
|
const tagName = tagTokens.tagName;
|
|
267
281
|
let endTag = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/astro-parser",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "astro parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@astrojs/parser": "0.20",
|
|
23
|
-
"@markuplint/html-parser": "3.6.
|
|
23
|
+
"@markuplint/html-parser": "3.6.1",
|
|
24
24
|
"@markuplint/ml-ast": "3.1.0",
|
|
25
|
-
"@markuplint/parser-utils": "3.6.
|
|
25
|
+
"@markuplint/parser-utils": "3.6.1",
|
|
26
26
|
"astro-eslint-parser": "^0.13.2",
|
|
27
27
|
"tslib": "^2.4.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "884e8dbf60ec2a350761d5cda3cdc0725881b9dc"
|
|
30
30
|
}
|