@markuplint/parser-utils 3.11.0 → 4.0.0-alpha.2
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/const.js +5 -8
- package/lib/create-token.js +11 -17
- package/lib/debugger.js +3 -9
- package/lib/decision.js +6 -11
- package/lib/detect-element-type.js +3 -7
- package/lib/flatten-nodes.js +24 -30
- package/lib/get-location.js +6 -15
- package/lib/get-space-before.d.ts +1 -1
- package/lib/get-space-before.js +4 -9
- package/lib/idl-attributes.js +4 -9
- package/lib/ignore-block.d.ts +1 -1
- package/lib/ignore-block.js +22 -28
- package/lib/ignore-front-matter.js +1 -5
- package/lib/index.d.ts +16 -16
- package/lib/index.js +16 -19
- package/lib/parse-attr.js +17 -23
- package/lib/parser-error.js +7 -15
- package/lib/remove-deprecated-node.js +1 -5
- package/lib/siblings-correction.js +3 -8
- package/lib/tag-splitter.js +7 -10
- package/lib/types.js +1 -2
- package/lib/walker.js +1 -5
- package/package.json +12 -7
- package/lib/idl-attributes.test.d.ts +0 -1
- package/lib/idl-attributes.test.js +0 -45
- package/test/create-token.spec.js +0 -17
- package/test/flatten-nodes.spec.js +0 -31
- package/test/get-location.spec.js +0 -38
- package/test/ignore-block.spec.js +0 -274
- package/test/ignore-front-matter.spec.js +0 -20
- package/test/parse-attr.spec.js +0 -68
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const { ignoreFrontMatter } = require('../lib/ignore-front-matter');
|
|
2
|
-
|
|
3
|
-
describe('ignoreFrontMatter', () => {
|
|
4
|
-
it('basic', () => {
|
|
5
|
-
expect(ignoreFrontMatter('---')).toStrictEqual('---');
|
|
6
|
-
expect(ignoreFrontMatter('---\np: v')).toStrictEqual('---\np: v');
|
|
7
|
-
expect(ignoreFrontMatter('---\np: v\n---')).toStrictEqual('---\np: v\n---');
|
|
8
|
-
expect(ignoreFrontMatter('---\np: v\n---\n')).toStrictEqual(' \n \n \n');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('basic', () => {
|
|
12
|
-
expect(
|
|
13
|
-
ignoreFrontMatter(`
|
|
14
|
-
---
|
|
15
|
-
prop: value
|
|
16
|
-
---
|
|
17
|
-
<html></html>`),
|
|
18
|
-
).toStrictEqual('\n \n \n \n<html></html>');
|
|
19
|
-
});
|
|
20
|
-
});
|
package/test/parse-attr.spec.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
const { tokenize, defaultValueDelimiters } = require('../lib/parse-attr');
|
|
2
|
-
|
|
3
|
-
describe('tokenize', () => {
|
|
4
|
-
test('name', () => {
|
|
5
|
-
expect(tokenize('a').name).toBe('a');
|
|
6
|
-
expect(tokenize('abc').name).toBe('abc');
|
|
7
|
-
expect(tokenize('abc:').name).toBe('abc:');
|
|
8
|
-
expect(tokenize(':abc').name).toBe(':abc');
|
|
9
|
-
expect(tokenize('xxx:abc').name).toBe('xxx:abc');
|
|
10
|
-
expect(tokenize('@abc').name).toBe('@abc');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('value', () => {
|
|
14
|
-
expect(tokenize('a=b').value).toBe('b');
|
|
15
|
-
expect(tokenize('abc=xyz').value).toBe('xyz');
|
|
16
|
-
expect(tokenize('abc:="xyz"').value).toBe('xyz');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('complex', () => {
|
|
20
|
-
expect(tokenize(' @a:x.y\n= x + y ')).toStrictEqual({
|
|
21
|
-
beforeName: ' ',
|
|
22
|
-
name: '@a:x.y',
|
|
23
|
-
afterName: '\n',
|
|
24
|
-
equal: '=',
|
|
25
|
-
beforeValue: '',
|
|
26
|
-
startQuote: '',
|
|
27
|
-
value: ' x + y ',
|
|
28
|
-
endQuote: '',
|
|
29
|
-
afterAttr: '',
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
expect(tokenize(' @a:x.y\n= " x\' + y " ')).toStrictEqual({
|
|
33
|
-
beforeName: ' ',
|
|
34
|
-
name: '@a:x.y',
|
|
35
|
-
afterName: '\n',
|
|
36
|
-
equal: '=',
|
|
37
|
-
beforeValue: ' ',
|
|
38
|
-
startQuote: '"',
|
|
39
|
-
value: " x' + y ",
|
|
40
|
-
endQuote: '"',
|
|
41
|
-
afterAttr: ' ',
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('jsx', () => {
|
|
46
|
-
expect(
|
|
47
|
-
tokenize(' className={classList.map((c) => `${c.toLowerCase()}`).join(",")} ', {
|
|
48
|
-
valueDelimiters: [
|
|
49
|
-
...defaultValueDelimiters,
|
|
50
|
-
{
|
|
51
|
-
start: '{',
|
|
52
|
-
end: '}',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
}),
|
|
56
|
-
).toStrictEqual({
|
|
57
|
-
beforeName: ' ',
|
|
58
|
-
name: 'className',
|
|
59
|
-
afterName: '',
|
|
60
|
-
equal: '=',
|
|
61
|
-
beforeValue: '',
|
|
62
|
-
startQuote: '{',
|
|
63
|
-
value: 'classList.map((c) => `${c.toLowerCase()}`).join(",")',
|
|
64
|
-
endQuote: '}',
|
|
65
|
-
afterAttr: ' ',
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|