@markuplint/nunjucks-parser 4.0.0-dev.20 → 4.0.0-dev.23
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/README.md +0 -10
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/parser.d.ts +6 -0
- package/lib/parser.js +25 -0
- package/package.json +6 -5
- package/lib/parse.d.ts +0 -2
- package/lib/parse.js +0 -24
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -53,13 +53,3 @@ If it doesn't nest by quotations.
|
|
|
53
53
|
<div attr={{ value }}></div>
|
|
54
54
|
```
|
|
55
55
|
<!-- prettier-ignore-end -->
|
|
56
|
-
|
|
57
|
-
If it mixes the tags and spaces.
|
|
58
|
-
|
|
59
|
-
```html
|
|
60
|
-
<div attr=" {{ value }} "></div>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```html
|
|
64
|
-
<div attr="{{ value }} {{ value2 }}"></div>
|
|
65
|
-
```
|
package/lib/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parser } from './parser.js';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { parser } from './parser.js';
|
package/lib/parser.d.ts
ADDED
package/lib/parser.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HtmlParser } from '@markuplint/html-parser';
|
|
2
|
+
class NunjucksParser extends HtmlParser {
|
|
3
|
+
constructor() {
|
|
4
|
+
super({
|
|
5
|
+
ignoreTags: [
|
|
6
|
+
{
|
|
7
|
+
type: 'nunjucks-block',
|
|
8
|
+
start: '{%',
|
|
9
|
+
end: '%}',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: 'nunjucks-output',
|
|
13
|
+
start: '{{',
|
|
14
|
+
end: '}}',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'nunjucks-comment',
|
|
18
|
+
start: '{#',
|
|
19
|
+
end: '#}',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const parser = new NunjucksParser();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/nunjucks-parser",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.23+d6f2aa9bc",
|
|
4
4
|
"description": "Nunjucks template parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
"clean": "tsc --build --clean"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@markuplint/html-parser": "4.0.0-dev.
|
|
25
|
-
"@markuplint/ml-ast": "4.0.0-dev.20+6b35da16",
|
|
26
|
-
"@markuplint/parser-utils": "4.0.0-dev.20+6b35da16"
|
|
24
|
+
"@markuplint/html-parser": "4.0.0-dev.23+d6f2aa9bc"
|
|
27
25
|
},
|
|
28
|
-
"
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@markuplint/parser-utils": "4.0.0-dev.23+d6f2aa9bc"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "d6f2aa9bc287768466f23b5340e4e0eecfa30d59"
|
|
29
30
|
}
|
package/lib/parse.d.ts
DELETED
package/lib/parse.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { parse as htmlParse } from '@markuplint/html-parser';
|
|
2
|
-
import { ignoreBlock, restoreNode } from '@markuplint/parser-utils';
|
|
3
|
-
export const parse = (rawCode, options) => {
|
|
4
|
-
const blocks = ignoreBlock(rawCode, [
|
|
5
|
-
{
|
|
6
|
-
type: 'nunjucks-block',
|
|
7
|
-
start: '{%',
|
|
8
|
-
end: '%}',
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
type: 'nunjucks-output',
|
|
12
|
-
start: '{{',
|
|
13
|
-
end: '}}',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: 'nunjucks-comment',
|
|
17
|
-
start: '{#',
|
|
18
|
-
end: '#}',
|
|
19
|
-
},
|
|
20
|
-
]);
|
|
21
|
-
const doc = htmlParse(blocks.replaced, options);
|
|
22
|
-
doc.nodeList = restoreNode(doc.nodeList, blocks);
|
|
23
|
-
return doc;
|
|
24
|
-
};
|