@markuplint/astro-parser 4.0.0-alpha.3 → 4.0.0-alpha.5
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/LICENSE +1 -1
- package/lib/parse.js +7 -7
- package/package.json +6 -7
package/LICENSE
CHANGED
package/lib/parse.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { flattenNodes, detectElementType, getEndCol, getEndLine, sliceFragment, uuid } from '@markuplint/parser-utils';
|
|
1
|
+
import { parse as htmlParse } from '@markuplint/html-parser';
|
|
2
|
+
import { flattenNodes, detectElementType, getEndCol, getEndLine, sliceFragment, uuid, tagParser, } from '@markuplint/parser-utils';
|
|
3
3
|
import { astroParse } from './astro-parser.js';
|
|
4
4
|
import { attrTokenizer } from './attr-tokenizer.js';
|
|
5
5
|
export const parse = (rawCode, options = {}) => {
|
|
@@ -108,7 +108,7 @@ parentNode, scopeNS, rawHtml, offset = 0, options, inExpression) {
|
|
|
108
108
|
let _raw = raw;
|
|
109
109
|
let closeExpression = null;
|
|
110
110
|
const firstChild = originNode.children[0];
|
|
111
|
-
const lastChild = originNode.children
|
|
111
|
+
const lastChild = originNode.children.at(-1);
|
|
112
112
|
if (firstChild && lastChild && firstChild !== lastChild) {
|
|
113
113
|
_endOffset = firstChild.position?.end?.offset ?? endOffset;
|
|
114
114
|
const startLoc = sliceFragment(rawHtml, startOffset, _endOffset);
|
|
@@ -231,7 +231,7 @@ nextNode, offset, options) {
|
|
|
231
231
|
let childrenEnd;
|
|
232
232
|
if (originNode.children[0]) {
|
|
233
233
|
childrenStart = (originNode.children[0].position?.start?.offset ?? 0) + offset;
|
|
234
|
-
childrenEnd = (originNode.children
|
|
234
|
+
childrenEnd = (originNode.children.at(-1)?.position?.end?.offset ?? 0) + offset;
|
|
235
235
|
const startTagStartOffset = originNode.position.start.offset + offset;
|
|
236
236
|
const startTagEndOffset = childrenStart;
|
|
237
237
|
startTagRaw = rawHtml.slice(startTagStartOffset, startTagEndOffset);
|
|
@@ -269,12 +269,12 @@ nextNode, offset, options) {
|
|
|
269
269
|
// childrenEnd,
|
|
270
270
|
// });
|
|
271
271
|
}
|
|
272
|
-
const tagTokens =
|
|
272
|
+
const tagTokens = tagParser(startTagRaw, startLine, startCol, startOffset);
|
|
273
273
|
const tagName = tagTokens.tagName;
|
|
274
274
|
let endTag = null;
|
|
275
275
|
if (childrenEnd < (originNode.position.end?.offset ?? 0) + offset) {
|
|
276
276
|
const endTagLoc = sliceFragment(rawHtml, childrenEnd, (originNode.position.end?.offset ?? 0) + offset);
|
|
277
|
-
const endTagTokens =
|
|
277
|
+
const endTagTokens = tagParser(endTagLoc.raw, endTagLoc.startLine, endTagLoc.startCol, endTagLoc.startOffset);
|
|
278
278
|
const endTagName = endTagTokens.tagName;
|
|
279
279
|
endTag = {
|
|
280
280
|
uuid: uuid(),
|
|
@@ -321,7 +321,7 @@ nextNode, offset, options) {
|
|
|
321
321
|
nextNode,
|
|
322
322
|
pearNode: endTag,
|
|
323
323
|
selfClosingSolidus: tagTokens.selfClosingSolidus,
|
|
324
|
-
endSpace: tagTokens.
|
|
324
|
+
endSpace: tagTokens.afterAttrSpaces,
|
|
325
325
|
isFragment: false,
|
|
326
326
|
isGhost: false,
|
|
327
327
|
tagOpenChar: '<',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/astro-parser",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "astro parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -22,11 +22,10 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@astrojs/parser": "0.22.2",
|
|
25
|
-
"@markuplint/html-parser": "4.0.0-alpha.
|
|
26
|
-
"@markuplint/ml-ast": "4.0.0-alpha.
|
|
27
|
-
"@markuplint/parser-utils": "4.0.0-alpha.
|
|
28
|
-
"astro-eslint-parser": "^0.16.0"
|
|
29
|
-
"tslib": "^2.6.2"
|
|
25
|
+
"@markuplint/html-parser": "4.0.0-alpha.5",
|
|
26
|
+
"@markuplint/ml-ast": "4.0.0-alpha.5",
|
|
27
|
+
"@markuplint/parser-utils": "4.0.0-alpha.5",
|
|
28
|
+
"astro-eslint-parser": "^0.16.0"
|
|
30
29
|
},
|
|
31
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "0c3e4690662edf1765bcc4b6411ec5507c1e2ea3"
|
|
32
31
|
}
|