@markuplint/pug-parser 3.9.1 → 3.11.0
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 +3 -6
- package/package.json +4 -4
- package/test/index.spec.js +29 -0
package/lib/parse.js
CHANGED
|
@@ -127,12 +127,9 @@ class Parser {
|
|
|
127
127
|
offsetLine: originNode.line - 1,
|
|
128
128
|
offsetColumn: originNode.column - 1,
|
|
129
129
|
});
|
|
130
|
-
const nodes = htmlDoc.nodeList
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
node.parentNode = parentNode;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
130
|
+
const nodes = htmlDoc.nodeList.filter(node => {
|
|
131
|
+
return node.parentNode == null && node.type !== 'endtag';
|
|
132
|
+
});
|
|
136
133
|
return nodes;
|
|
137
134
|
}
|
|
138
135
|
case 'Comment': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/pug-parser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Pug parser for markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"clean": "tsc --build --clean"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@markuplint/html-parser": "3.
|
|
19
|
+
"@markuplint/html-parser": "3.12.0",
|
|
20
20
|
"@markuplint/ml-ast": "3.2.0",
|
|
21
|
-
"@markuplint/parser-utils": "3.
|
|
21
|
+
"@markuplint/parser-utils": "3.12.0",
|
|
22
22
|
"pug-lexer": "^5.0.1",
|
|
23
23
|
"pug-parser": "^6.0.0",
|
|
24
24
|
"tslib": "^2.6.2"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "e2adbe92c74631af9c98cb816286287f9f983053"
|
|
27
27
|
}
|
package/test/index.spec.js
CHANGED
|
@@ -554,3 +554,32 @@ html
|
|
|
554
554
|
expect(doc.nodeList[2].namespace).toBe('http://www.w3.org/2000/svg');
|
|
555
555
|
});
|
|
556
556
|
});
|
|
557
|
+
|
|
558
|
+
describe('Issues', () => {
|
|
559
|
+
test('#1221', () => {
|
|
560
|
+
const doc = parse('html: p <span>text</span>');
|
|
561
|
+
const map = nodeListToDebugMaps(doc.nodeList);
|
|
562
|
+
expect(map).toStrictEqual([
|
|
563
|
+
'[1:1]>[1:5](0,4)html: html',
|
|
564
|
+
'[1:7]>[1:8](6,7)p: p',
|
|
565
|
+
'[1:9]>[1:15](8,14)span: <span>',
|
|
566
|
+
'[1:15]>[1:19](14,18)#text: text',
|
|
567
|
+
'[1:19]>[1:26](18,25)span: </span>',
|
|
568
|
+
]);
|
|
569
|
+
|
|
570
|
+
const html = doc.nodeList[0];
|
|
571
|
+
const p = doc.nodeList[1];
|
|
572
|
+
const span = doc.nodeList[2];
|
|
573
|
+
const text = doc.nodeList[3];
|
|
574
|
+
const spanClose = doc.nodeList[4];
|
|
575
|
+
|
|
576
|
+
expect(html.uuid).toBe(p.parentNode.uuid);
|
|
577
|
+
expect(html.childNodes.length).toBe(1);
|
|
578
|
+
expect(p.uuid).toBe(html.childNodes[0].uuid);
|
|
579
|
+
expect(p.childNodes.length).toBe(1);
|
|
580
|
+
expect(span.uuid).toBe(p.childNodes[0].uuid);
|
|
581
|
+
expect(span.childNodes.length).toBe(1);
|
|
582
|
+
expect(text.uuid).toBe(span.childNodes[0].uuid);
|
|
583
|
+
expect(spanClose.uuid).toBe(span.pearNode.uuid);
|
|
584
|
+
});
|
|
585
|
+
});
|