@markuplint/pug-parser 4.6.1 → 4.6.3
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/CHANGELOG.md +10 -0
- package/lib/parser.d.ts +1 -0
- package/lib/parser.js +7 -1
- package/lib/pug-parser/index.d.ts +10 -1
- package/lib/pug-parser/index.js +18 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.6.3](https://github.com/markuplint/markuplint/compare/@markuplint/pug-parser@4.6.2...@markuplint/pug-parser@4.6.3) (2024-05-28)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **pug-parser:** add to parse `NamedBlock` ([f5197ff](https://github.com/markuplint/markuplint/commit/f5197ffd5281a9a67ad62dfc340b4422a3c20237)), closes [#1741](https://github.com/markuplint/markuplint/issues/1741)
|
|
11
|
+
|
|
12
|
+
## [4.6.2](https://github.com/markuplint/markuplint/compare/@markuplint/pug-parser@4.6.1...@markuplint/pug-parser@4.6.2) (2024-05-12)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @markuplint/pug-parser
|
|
15
|
+
|
|
6
16
|
## [4.6.1](https://github.com/markuplint/markuplint/compare/@markuplint/pug-parser@4.6.1-alpha.0...@markuplint/pug-parser@4.6.1) (2024-05-04)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @markuplint/pug-parser
|
package/lib/parser.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare class PugParser extends Parser<ASTNode> {
|
|
|
14
14
|
visitElement(token: ChildToken & {
|
|
15
15
|
readonly nodeName: string;
|
|
16
16
|
readonly namespace: string;
|
|
17
|
+
readonly isFragment: false;
|
|
17
18
|
}, childNodes: readonly ASTNode[], options: {
|
|
18
19
|
readonly overwriteProps: {
|
|
19
20
|
readonly attributes: readonly MLASTAttr[];
|
package/lib/parser.js
CHANGED
|
@@ -134,6 +134,7 @@ class PugParser extends Parser {
|
|
|
134
134
|
parentNode,
|
|
135
135
|
nodeName: originNode.name,
|
|
136
136
|
namespace,
|
|
137
|
+
isFragment: false,
|
|
137
138
|
}, originNode.block.nodes, {
|
|
138
139
|
overwriteProps: {
|
|
139
140
|
attributes: [...attrs, ...andAttr],
|
|
@@ -146,7 +147,12 @@ class PugParser extends Parser {
|
|
|
146
147
|
depth,
|
|
147
148
|
parentNode,
|
|
148
149
|
nodeName: originNode.type,
|
|
149
|
-
|
|
150
|
+
isFragment: true,
|
|
151
|
+
}, 'block' in originNode && originNode.block
|
|
152
|
+
? originNode.block.nodes
|
|
153
|
+
: 'nodes' in originNode
|
|
154
|
+
? originNode.nodes
|
|
155
|
+
: []);
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
158
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function pugParse(pug: string, useOffset?: boolean): ASTBlock;
|
|
2
2
|
export type ASTBlock = PugAST<ASTNode>;
|
|
3
|
-
export type ASTNode = ASTTagNode | ASTTextNode | ASTEmptyPipeNode | ASTCodeNode | ASTComment | ASTDoctype | ASTIncludeNode | ASTMixinNode | ASTMixinSlotNode | ASTFilterNode | ASTEachNode | ASTConditionalNode | ASTCaseNode | ASTCaseWhenNode;
|
|
3
|
+
export type ASTNode = ASTTagNode | ASTTextNode | ASTEmptyPipeNode | ASTCodeNode | ASTComment | ASTDoctype | ASTIncludeNode | ASTMixinNode | ASTMixinSlotNode | ASTNamedBlockNode | ASTFilterNode | ASTEachNode | ASTConditionalNode | ASTCaseNode | ASTCaseWhenNode;
|
|
4
4
|
export type ASTTagNode = Omit<PugASTTagNode<ASTAttr, ASTBlock>, 'selfClosing' | 'isInline'> & AdditionalASTData;
|
|
5
5
|
export type ASTTextNode = Omit<PugASTTextNode, 'val'> & AdditionalASTData;
|
|
6
6
|
export type ASTEmptyPipeNode = PugASTEmptyPipeNode & AdditionalASTData;
|
|
@@ -10,6 +10,7 @@ export type ASTDoctype = PugASTDoctypeNode & AdditionalASTData;
|
|
|
10
10
|
export type ASTIncludeNode = PugASTIncludeNode<ASTBlock> & AdditionalASTData;
|
|
11
11
|
export type ASTMixinNode = Omit<PugASTMixinNode<ASTAttr, ASTBlock>, 'attributeBlocks'> & AdditionalASTData;
|
|
12
12
|
export type ASTMixinSlotNode = PugASTMixinSlotNode & AdditionalASTData;
|
|
13
|
+
export type ASTNamedBlockNode = PugASTNamedBlockNode<ASTNode> & AdditionalASTData;
|
|
13
14
|
export type ASTFilterNode = PugASTFilterNode<ASTAttr, ASTBlock> & AdditionalASTData;
|
|
14
15
|
export type ASTEachNode = PugASTEachNode<ASTBlock> & AdditionalASTData;
|
|
15
16
|
export type ASTConditionalNode = Omit<PugASTConditionalNode<ASTBlock>, 'consequent' | 'alternate'> & {
|
|
@@ -118,6 +119,14 @@ type PugASTMixinSlotNode = {
|
|
|
118
119
|
line: number;
|
|
119
120
|
column: number;
|
|
120
121
|
};
|
|
122
|
+
interface PugASTNamedBlockNode<N> {
|
|
123
|
+
type: 'NamedBlock';
|
|
124
|
+
name: string;
|
|
125
|
+
mode: 'replace' | 'append' | 'prepend';
|
|
126
|
+
nodes: N[];
|
|
127
|
+
line: number;
|
|
128
|
+
column: number;
|
|
129
|
+
}
|
|
121
130
|
type PugASTFilterNode<A, B> = {
|
|
122
131
|
type: 'Filter';
|
|
123
132
|
name: string;
|
package/lib/pug-parser/index.js
CHANGED
|
@@ -188,6 +188,24 @@ tokens, pug) {
|
|
|
188
188
|
nodes.push(mixinNode);
|
|
189
189
|
continue;
|
|
190
190
|
}
|
|
191
|
+
case 'NamedBlock': {
|
|
192
|
+
const namedBlockNode = {
|
|
193
|
+
...node,
|
|
194
|
+
nodes: optimizeAST({
|
|
195
|
+
...node,
|
|
196
|
+
type: 'Block',
|
|
197
|
+
}, tokens, pug).nodes,
|
|
198
|
+
raw,
|
|
199
|
+
offset,
|
|
200
|
+
endOffset,
|
|
201
|
+
line,
|
|
202
|
+
endLine,
|
|
203
|
+
column,
|
|
204
|
+
endColumn,
|
|
205
|
+
};
|
|
206
|
+
nodes.push(namedBlockNode);
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
191
209
|
case 'Comment': {
|
|
192
210
|
const commentNode = {
|
|
193
211
|
type: node.type,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/pug-parser",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.3",
|
|
4
4
|
"description": "Pug parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"clean": "tsc --build --clean"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@markuplint/html-parser": "4.6.
|
|
25
|
-
"@markuplint/ml-ast": "4.
|
|
26
|
-
"@markuplint/parser-utils": "4.6.
|
|
24
|
+
"@markuplint/html-parser": "4.6.3",
|
|
25
|
+
"@markuplint/ml-ast": "4.4.0",
|
|
26
|
+
"@markuplint/parser-utils": "4.6.3",
|
|
27
27
|
"pug-lexer": "5.0.1",
|
|
28
28
|
"pug-parser": "6.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "bf70c41b1d2497e85b73c9ecd5551eb522e6bdfc"
|
|
31
31
|
}
|