@markuplint/parser-utils 4.0.0-alpha.1 → 4.0.0-alpha.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/LICENSE +1 -1
- package/lib/attr-tokenizer.d.ts +18 -0
- package/lib/attr-tokenizer.js +169 -0
- package/lib/const.d.ts +8 -1
- package/lib/const.js +9 -3
- package/lib/debug.d.ts +4 -0
- package/lib/debug.js +6 -0
- package/lib/debugger.d.ts +3 -2
- package/lib/debugger.js +38 -33
- package/lib/detect-element-type.js +1 -1
- package/lib/enums.d.ts +16 -0
- package/lib/enums.js +18 -0
- package/lib/get-location.d.ts +4 -13
- package/lib/get-location.js +11 -22
- package/lib/idl-attributes.js +2 -2
- package/lib/ignore-block.d.ts +3 -2
- package/lib/ignore-block.js +69 -119
- package/lib/ignore-front-matter.d.ts +4 -1
- package/lib/ignore-front-matter.js +14 -5
- package/lib/index.d.ts +4 -13
- package/lib/index.js +4 -13
- package/lib/parser-error.d.ts +1 -0
- package/lib/parser-error.js +1 -0
- package/lib/parser.d.ts +108 -0
- package/lib/parser.js +1078 -0
- package/lib/script-parser.d.ts +5 -0
- package/lib/script-parser.js +12 -0
- package/lib/sort-nodes.d.ts +2 -0
- package/lib/sort-nodes.js +18 -0
- package/lib/types.d.ts +40 -2
- package/package.json +13 -8
- package/lib/create-token.d.ts +0 -4
- package/lib/create-token.js +0 -29
- package/lib/flatten-nodes.d.ts +0 -2
- package/lib/flatten-nodes.js +0 -245
- package/lib/get-space-before.d.ts +0 -1
- package/lib/get-space-before.js +0 -8
- package/lib/parse-attr.d.ts +0 -24
- package/lib/parse-attr.js +0 -144
- package/lib/remove-deprecated-node.d.ts +0 -7
- package/lib/remove-deprecated-node.js +0 -39
- package/lib/siblings-correction.d.ts +0 -9
- package/lib/siblings-correction.js +0 -21
- package/lib/tag-splitter.d.ts +0 -7
- package/lib/tag-splitter.js +0 -89
- package/lib/walker.d.ts +0 -2
- package/lib/walker.js +0 -18
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Correct the references to prevNode and nextNode in the order listed.
|
|
3
|
-
*
|
|
4
|
-
* @param nodeList
|
|
5
|
-
* @affects nodeList[].prevNode
|
|
6
|
-
* @affects nodeList[].nextNode
|
|
7
|
-
*/
|
|
8
|
-
export function siblingsCorrection(
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
|
-
nodeList) {
|
|
11
|
-
for (let i = 0; i < nodeList.length; i++) {
|
|
12
|
-
const prevNode = nodeList[i - 1] ?? null;
|
|
13
|
-
const node = nodeList[i];
|
|
14
|
-
if (!node) {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const nextNode = nodeList[i + 1] ?? null;
|
|
18
|
-
node.prevNode = prevNode;
|
|
19
|
-
node.nextNode = nextNode;
|
|
20
|
-
}
|
|
21
|
-
}
|
package/lib/tag-splitter.d.ts
DELETED
package/lib/tag-splitter.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { reSplitterTag, reTagName } from './const.js';
|
|
2
|
-
import { getEndCol, getEndLine } from '@markuplint/parser-utils';
|
|
3
|
-
export default function tagSplitter(raw, line, col) {
|
|
4
|
-
return withLocation(tagSplitterAsString(raw), line, col);
|
|
5
|
-
}
|
|
6
|
-
function tagSplitterAsString(raw) {
|
|
7
|
-
const tagMatches = raw.match(reSplitterTag);
|
|
8
|
-
if (!tagMatches) {
|
|
9
|
-
return [raw];
|
|
10
|
-
}
|
|
11
|
-
const tokens = Array.from(tagMatches);
|
|
12
|
-
tokens.unshift(); // remove all match
|
|
13
|
-
const nodes = [];
|
|
14
|
-
let rest = raw;
|
|
15
|
-
for (const token of tokens) {
|
|
16
|
-
const index = rest.indexOf(token);
|
|
17
|
-
let length = token.length;
|
|
18
|
-
if (index > 0) {
|
|
19
|
-
const text = rest.slice(0, index);
|
|
20
|
-
nodes.push(text);
|
|
21
|
-
length += text.length;
|
|
22
|
-
}
|
|
23
|
-
nodes.push(token);
|
|
24
|
-
rest = rest.slice(length);
|
|
25
|
-
}
|
|
26
|
-
if (rest) {
|
|
27
|
-
nodes.push(rest);
|
|
28
|
-
}
|
|
29
|
-
return nodes;
|
|
30
|
-
}
|
|
31
|
-
function withLocation(nodes, line, col) {
|
|
32
|
-
const result = [];
|
|
33
|
-
for (const node of nodes) {
|
|
34
|
-
if (node[0] !== '<') {
|
|
35
|
-
result.push({
|
|
36
|
-
type: 'text',
|
|
37
|
-
raw: node,
|
|
38
|
-
line,
|
|
39
|
-
col,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
const label = node.slice(1).slice(0, -1);
|
|
44
|
-
if (reTagName.test(label)) {
|
|
45
|
-
result.push({
|
|
46
|
-
type: 'starttag',
|
|
47
|
-
raw: node,
|
|
48
|
-
line,
|
|
49
|
-
col,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
else if (label[0] === '/') {
|
|
53
|
-
result.push({
|
|
54
|
-
type: 'endtag',
|
|
55
|
-
raw: node,
|
|
56
|
-
line,
|
|
57
|
-
col,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
else if (label[0] === '!') {
|
|
61
|
-
result.push({
|
|
62
|
-
type: 'comment',
|
|
63
|
-
raw: node,
|
|
64
|
-
line,
|
|
65
|
-
col,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else if (label[0] === '?') {
|
|
69
|
-
result.push({
|
|
70
|
-
type: 'boguscomment',
|
|
71
|
-
raw: node,
|
|
72
|
-
line,
|
|
73
|
-
col,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
result.push({
|
|
78
|
-
type: 'text',
|
|
79
|
-
raw: node,
|
|
80
|
-
line,
|
|
81
|
-
col,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
line = getEndLine(node, line);
|
|
86
|
-
col = getEndCol(node, col);
|
|
87
|
-
}
|
|
88
|
-
return result;
|
|
89
|
-
}
|
package/lib/walker.d.ts
DELETED
package/lib/walker.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function walk(
|
|
2
|
-
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
3
|
-
nodeList, walker, depth = 0) {
|
|
4
|
-
for (const node of nodeList) {
|
|
5
|
-
walker(node, depth);
|
|
6
|
-
if ('childNodes' in node) {
|
|
7
|
-
if (node.type === 'endtag') {
|
|
8
|
-
continue;
|
|
9
|
-
}
|
|
10
|
-
if (node.childNodes && node.childNodes.length > 0) {
|
|
11
|
-
walk(node.childNodes, walker, depth + 1);
|
|
12
|
-
}
|
|
13
|
-
if ('pearNode' in node && node.pearNode) {
|
|
14
|
-
walker(node.pearNode, depth);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|