@markuplint/svelte-parser 4.7.9 → 4.7.11
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/parser.d.ts +1 -1
- package/lib/parser.js +16 -16
- package/lib/svelte-parser/index.d.ts +1 -3
- package/package.json +7 -8
package/lib/parser.d.ts
CHANGED
|
@@ -12,8 +12,8 @@ export declare class SvelteParser extends Parser<SvelteNode> {
|
|
|
12
12
|
};
|
|
13
13
|
parse(raw: string, options?: ParseOptions): import("@markuplint/ml-ast").MLASTDocument;
|
|
14
14
|
parseError(error: any): ParserError;
|
|
15
|
-
visitText(token: ChildToken): readonly MLASTNodeTreeItem[];
|
|
16
15
|
nodeize(originNode: SvelteNode, parentNode: MLASTParentNode | null, depth: number): readonly MLASTNodeTreeItem[];
|
|
16
|
+
visitText(token: ChildToken): readonly MLASTNodeTreeItem[];
|
|
17
17
|
visitPsBlock(token: ChildToken & {
|
|
18
18
|
readonly nodeName: string;
|
|
19
19
|
readonly isFragment: boolean;
|
package/lib/parser.js
CHANGED
|
@@ -49,22 +49,6 @@ export class SvelteParser extends Parser {
|
|
|
49
49
|
}
|
|
50
50
|
return super.parseError(error);
|
|
51
51
|
}
|
|
52
|
-
visitText(token) {
|
|
53
|
-
const nodes = super.visitText(token, {
|
|
54
|
-
researchTags: false,
|
|
55
|
-
invalidTagAsText: false,
|
|
56
|
-
});
|
|
57
|
-
return nodes.flatMap(node => {
|
|
58
|
-
if (node.nodeName === '#text' && /^<script[\s>]/i.test(node.raw)) {
|
|
59
|
-
return this.visitPsBlock({
|
|
60
|
-
...node,
|
|
61
|
-
nodeName: 'Script',
|
|
62
|
-
isFragment: false,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return node;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
52
|
nodeize(
|
|
69
53
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
70
54
|
originNode, parentNode, depth) {
|
|
@@ -221,6 +205,22 @@ export class SvelteParser extends Parser {
|
|
|
221
205
|
}
|
|
222
206
|
}
|
|
223
207
|
}
|
|
208
|
+
visitText(token) {
|
|
209
|
+
const nodes = super.visitText(token, {
|
|
210
|
+
researchTags: false,
|
|
211
|
+
invalidTagAsText: false,
|
|
212
|
+
});
|
|
213
|
+
return nodes.flatMap(node => {
|
|
214
|
+
if (node.nodeName === '#text' && /^<script[\s>]/i.test(node.raw)) {
|
|
215
|
+
return this.visitPsBlock({
|
|
216
|
+
...node,
|
|
217
|
+
nodeName: 'Script',
|
|
218
|
+
isFragment: false,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
return node;
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
224
|
visitPsBlock(token, childNodes = [], conditionalType = null) {
|
|
225
225
|
const nodes = super.visitPsBlock(token, childNodes, conditionalType);
|
|
226
226
|
const block = nodes.at(0);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { AST } from 'svelte/compiler';
|
|
2
|
-
export type SvelteNode = AST.Text |
|
|
2
|
+
export type SvelteNode = AST.Text | AST.Comment | AST.Tag | AST.ElementLike | AST.Block;
|
|
3
3
|
export type SvelteIfBlock = AST.IfBlock;
|
|
4
4
|
export type SvelteEachBlock = AST.EachBlock;
|
|
5
5
|
export type SvelteAwaitBlock = AST.AwaitBlock;
|
|
6
6
|
export declare function svelteParse(template: string): SvelteNode[];
|
|
7
7
|
export type SvelteDirective = Directive | AST.Attribute | AST.SpreadAttribute;
|
|
8
8
|
export type SvelteBlock = AST.EachBlock | AST.IfBlock | AST.AwaitBlock | AST.KeyBlock | AST.SnippetBlock | AST.SvelteBoundary;
|
|
9
|
-
type Tag = AST.ExpressionTag | AST.HtmlTag | AST.ConstTag | AST.DebugTag | AST.RenderTag;
|
|
10
9
|
type Directive = AST.AnimateDirective | AST.BindDirective | AST.ClassDirective | AST.LetDirective | AST.OnDirective | AST.StyleDirective | AST.TransitionDirective | AST.UseDirective;
|
|
11
|
-
type ElementLike = AST.Component | AST.TitleElement | AST.SlotElement | AST.RegularElement | AST.SvelteBody | AST.SvelteComponent | AST.SvelteDocument | AST.SvelteElement | AST.SvelteFragment | AST.SvelteHead | AST.SvelteOptionsRaw | AST.SvelteSelf | AST.SvelteWindow;
|
|
12
10
|
export {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/svelte-parser",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.11",
|
|
4
4
|
"description": "Svelte parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"private": false,
|
|
9
8
|
"type": "module",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
@@ -27,13 +26,13 @@
|
|
|
27
26
|
"scripts": {
|
|
28
27
|
"build": "tsc --project tsconfig.build.json",
|
|
29
28
|
"dev": "tsc --watch --project tsconfig.build.json",
|
|
30
|
-
"clean": "tsc --build --clean"
|
|
29
|
+
"clean": "tsc --build --clean tsconfig.build.json"
|
|
31
30
|
},
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@markuplint/html-parser": "4.6.
|
|
34
|
-
"@markuplint/ml-ast": "4.4.
|
|
35
|
-
"@markuplint/parser-utils": "4.8.
|
|
36
|
-
"svelte": "5.
|
|
32
|
+
"@markuplint/html-parser": "4.6.21",
|
|
33
|
+
"@markuplint/ml-ast": "4.4.10",
|
|
34
|
+
"@markuplint/parser-utils": "4.8.9",
|
|
35
|
+
"svelte": "5.38.3"
|
|
37
36
|
},
|
|
38
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "ae97eb2d31ecedf4f0800fbbf18588aad4ebca04"
|
|
39
38
|
}
|