@markdoc/markdoc 0.5.12 → 0.5.14
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/README.md +35 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +472 -448
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +472 -448
- package/dist/index.mjs.map +4 -4
- package/dist/react.js +4 -4
- package/dist/react.js.map +2 -2
- package/dist/src/ast/base.d.ts +1 -1
- package/dist/src/ast/base.d.ts.map +1 -1
- package/dist/src/ast/function.d.ts +1 -1
- package/dist/src/ast/function.d.ts.map +1 -1
- package/dist/src/ast/index.d.ts +2 -2
- package/dist/src/ast/index.d.ts.map +1 -1
- package/dist/src/ast/node.d.ts.map +1 -1
- package/dist/src/ast/variable.d.ts +1 -1
- package/dist/src/ast/variable.d.ts.map +1 -1
- package/dist/src/formatter.d.ts.map +1 -1
- package/dist/src/functions/index.d.ts.map +1 -1
- package/dist/src/parser.d.ts.map +1 -1
- package/dist/src/renderers/html.d.ts.map +1 -1
- package/dist/src/renderers/react/react.d.ts +2 -2
- package/dist/src/renderers/react/react.d.ts.map +1 -1
- package/dist/src/renderers/react/static.d.ts +1 -1
- package/dist/src/renderers/react/static.d.ts.map +1 -1
- package/dist/src/schema-types/class.d.ts +1 -1
- package/dist/src/schema-types/class.d.ts.map +1 -1
- package/dist/src/schema-types/conditional.d.ts +1 -1
- package/dist/src/schema-types/conditional.d.ts.map +1 -1
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/tags/conditional.d.ts +1 -1
- package/dist/src/tags/conditional.d.ts.map +1 -1
- package/dist/src/tokenizer/index.d.ts.map +1 -1
- package/dist/src/tokenizer/plugins/annotations.d.ts.map +1 -1
- package/dist/src/transformer.d.ts.map +1 -1
- package/dist/src/validator.d.ts +1 -1
- package/dist/src/validator.d.ts.map +1 -1
- package/index.ts +21 -22
- package/package.json +9 -14
- package/spec/support/matchers.d.ts +6 -4
- package/src/ast/base.ts +21 -6
- package/src/ast/function.ts +1 -1
- package/src/ast/index.ts +3 -4
- package/src/ast/node.test.ts +126 -36
- package/src/ast/node.ts +4 -4
- package/src/ast/variable.test.ts +5 -4
- package/src/ast/variable.ts +1 -1
- package/src/formatter.test.ts +4 -3
- package/src/formatter.ts +11 -11
- package/src/functions/index.test.ts +8 -7
- package/src/functions/index.ts +1 -1
- package/src/grammar/tag.d.ts +1 -1
- package/src/grammar/tag.js +208 -285
- package/src/grammar/tag.pegjs +8 -8
- package/src/grammar/tag.test.ts +80 -48
- package/src/parser.test.ts +124 -66
- package/src/parser.ts +29 -7
- package/src/renderers/html.test.ts +56 -16
- package/src/renderers/html.ts +10 -2
- package/src/renderers/react/react.test.ts +39 -27
- package/src/renderers/react/react.ts +9 -10
- package/src/renderers/react/static.ts +5 -6
- package/src/schema-types/class.ts +1 -1
- package/src/schema-types/conditional.ts +1 -1
- package/src/schema.ts +9 -4
- package/src/tag.test.ts +2 -1
- package/src/tag.ts +1 -1
- package/src/tags/conditional.ts +4 -4
- package/src/tags/index.ts +2 -2
- package/src/tags/partial.ts +1 -1
- package/src/tokenizer/index.ts +6 -5
- package/src/tokenizer/plugins/annotations.test.ts +29 -28
- package/src/tokenizer/plugins/annotations.ts +12 -12
- package/src/tokenizer/plugins/comments.test.ts +11 -10
- package/src/tokenizer/plugins/comments.ts +2 -2
- package/src/tokenizer/plugins/frontmatter.test.ts +7 -6
- package/src/tokenizer/plugins/frontmatter.ts +2 -2
- package/src/tokenizer/plugins/link.test.ts +14 -13
- package/src/transformer.ts +11 -7
- package/src/transforms/table.test.ts +18 -17
- package/src/transforms/table.ts +1 -1
- package/src/utils.test.ts +23 -22
- package/src/utils.ts +3 -3
- package/src/validator.test.ts +205 -31
- package/src/validator.ts +21 -13
package/src/grammar/tag.pegjs
CHANGED
|
@@ -13,7 +13,7 @@ TopLevelValue =
|
|
|
13
13
|
|
|
14
14
|
Annotation =
|
|
15
15
|
attributes:TagAttributes _* {
|
|
16
|
-
|
|
16
|
+
return {type: 'annotation', meta: {attributes}}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
TagOpen =
|
|
@@ -23,13 +23,13 @@ TagOpen =
|
|
|
23
23
|
)?
|
|
24
24
|
attributes:TagAttributes? _*
|
|
25
25
|
close:'/'? {
|
|
26
|
-
|
|
26
|
+
if (primary) {
|
|
27
27
|
attributes = attributes || [];
|
|
28
28
|
attributes.unshift({type: 'attribute', name: 'primary', value: primary});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const [type, nesting] = close ? ['tag', 0] : ['tag_open', 1];
|
|
32
|
-
|
|
32
|
+
return {type, nesting, meta: {tag, attributes}};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
TagClose =
|
|
@@ -68,7 +68,7 @@ TagAttribute =
|
|
|
68
68
|
name:Identifier
|
|
69
69
|
'='
|
|
70
70
|
value:Value {
|
|
71
|
-
|
|
71
|
+
return {type: 'attribute', name, value};
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
Function =
|
|
@@ -78,9 +78,9 @@ Function =
|
|
|
78
78
|
tail:FunctionParameterTail* { return head ? [head, ...tail] : []; }
|
|
79
79
|
)?
|
|
80
80
|
')' {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const parameters = Object.fromEntries(
|
|
82
|
+
params.map(({name, value}, index) => [name || index, value])
|
|
83
|
+
);
|
|
84
84
|
return new Function(name, parameters);
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -140,7 +140,7 @@ ValueHash =
|
|
|
140
140
|
value:(
|
|
141
141
|
head:ValueHashItem
|
|
142
142
|
tail:ValueHashTail*
|
|
143
|
-
TrailingComma { return Object.
|
|
143
|
+
TrailingComma { return Object.fromEntries([head, ...tail].flatMap(Object.entries)); }
|
|
144
144
|
)?
|
|
145
145
|
_* '}' { return value || {}; }
|
|
146
146
|
|
package/src/grammar/tag.test.ts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import Function from '../../src/ast/function';
|
|
2
3
|
import Variable from '../../src/ast/variable';
|
|
4
|
+
import { parse, SyntaxError } from '../../src/grammar/tag';
|
|
5
|
+
|
|
6
|
+
describe('Markdoc tag parser', () => {
|
|
7
|
+
it('preserves __proto__ hash keys as own data properties in any position', () => {
|
|
8
|
+
for (const value of [
|
|
9
|
+
'{__proto__:{src:"unsafe"}, safe:true}',
|
|
10
|
+
'{safe:true, __proto__:{src:"unsafe"}}',
|
|
11
|
+
]) {
|
|
12
|
+
const result = parse(`foo value=${value} /`);
|
|
13
|
+
const hash = result.meta.attributes[0].value;
|
|
14
|
+
expect(Object.getPrototypeOf(hash)).toBe(Object.prototype);
|
|
15
|
+
// biome-ignore lint/suspicious/noPrototypeBuiltins: Keep the regression check compatible with ES2021.
|
|
16
|
+
expect(Object.prototype.hasOwnProperty.call(hash, '__proto__')).toBe(
|
|
17
|
+
true,
|
|
18
|
+
);
|
|
19
|
+
expect(hash.src).toBeUndefined();
|
|
20
|
+
// biome-ignore lint/suspicious/noProto: Verify the own __proto__ data property preserved by the security fix.
|
|
21
|
+
expect(hash.__proto__.src).toBe('unsafe');
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('preserves __proto__ function parameters as own data properties', () => {
|
|
26
|
+
const result = parse('foo value=example(__proto__={src:"unsafe"}) /', {
|
|
27
|
+
Function,
|
|
28
|
+
});
|
|
29
|
+
const parameters = result.meta.attributes[0].value.parameters;
|
|
30
|
+
expect(Object.getPrototypeOf(parameters)).toBe(Object.prototype);
|
|
31
|
+
expect(Object.keys(parameters)).toEqual(['__proto__']);
|
|
32
|
+
expect(parameters.src).toBeUndefined();
|
|
33
|
+
// biome-ignore lint/suspicious/noProto: Verify the own __proto__ data property preserved by the security fix.
|
|
34
|
+
expect(parameters.__proto__.src).toBe('unsafe');
|
|
35
|
+
});
|
|
3
36
|
|
|
4
|
-
describe('
|
|
5
|
-
|
|
6
|
-
it('with a simple opening tag', function () {
|
|
37
|
+
describe('tag parsing', () => {
|
|
38
|
+
it('with a simple opening tag', () => {
|
|
7
39
|
const example = parse('foo');
|
|
8
40
|
expect(example).toDeepEqual({
|
|
9
41
|
type: 'tag_open',
|
|
@@ -12,7 +44,7 @@ describe('Markdoc tag parser', function () {
|
|
|
12
44
|
});
|
|
13
45
|
});
|
|
14
46
|
|
|
15
|
-
it('with an opening tag that has attributes',
|
|
47
|
+
it('with an opening tag that has attributes', () => {
|
|
16
48
|
const example = parse('foo foo=1 bar=true');
|
|
17
49
|
expect(example).toDeepEqual({
|
|
18
50
|
type: 'tag_open',
|
|
@@ -27,7 +59,7 @@ describe('Markdoc tag parser', function () {
|
|
|
27
59
|
});
|
|
28
60
|
});
|
|
29
61
|
|
|
30
|
-
it('with a self-closing tag',
|
|
62
|
+
it('with a self-closing tag', () => {
|
|
31
63
|
const example = parse('foo /');
|
|
32
64
|
expect(example).toDeepEqual({
|
|
33
65
|
type: 'tag',
|
|
@@ -36,7 +68,7 @@ describe('Markdoc tag parser', function () {
|
|
|
36
68
|
});
|
|
37
69
|
});
|
|
38
70
|
|
|
39
|
-
it('with a self-closing tag that has attributes',
|
|
71
|
+
it('with a self-closing tag that has attributes', () => {
|
|
40
72
|
const example = parse('foo foo=1 bar=true /');
|
|
41
73
|
expect(example).toDeepEqual({
|
|
42
74
|
type: 'tag',
|
|
@@ -51,7 +83,7 @@ describe('Markdoc tag parser', function () {
|
|
|
51
83
|
});
|
|
52
84
|
});
|
|
53
85
|
|
|
54
|
-
it('with a closing tag',
|
|
86
|
+
it('with a closing tag', () => {
|
|
55
87
|
const example = parse('/foo');
|
|
56
88
|
expect(example).toDeepEqual({
|
|
57
89
|
type: 'tag_close',
|
|
@@ -60,17 +92,17 @@ describe('Markdoc tag parser', function () {
|
|
|
60
92
|
});
|
|
61
93
|
});
|
|
62
94
|
|
|
63
|
-
it('with an invalid closing tag',
|
|
95
|
+
it('with an invalid closing tag', () => {
|
|
64
96
|
expect(() => parse('/foo/')).toThrowError(SyntaxError);
|
|
65
97
|
});
|
|
66
98
|
|
|
67
|
-
it('with an invalid closing tag that has attributes',
|
|
99
|
+
it('with an invalid closing tag that has attributes', () => {
|
|
68
100
|
expect(() => parse('/foo test=1')).toThrowError(SyntaxError);
|
|
69
101
|
});
|
|
70
102
|
});
|
|
71
103
|
|
|
72
|
-
describe('variable parsing',
|
|
73
|
-
it('with a simple variable',
|
|
104
|
+
describe('variable parsing', () => {
|
|
105
|
+
it('with a simple variable', () => {
|
|
74
106
|
const example = parse('$foo', { Variable });
|
|
75
107
|
expect(example).toDeepEqual({
|
|
76
108
|
type: 'variable',
|
|
@@ -78,7 +110,7 @@ describe('Markdoc tag parser', function () {
|
|
|
78
110
|
});
|
|
79
111
|
});
|
|
80
112
|
|
|
81
|
-
it('with multiple levels of depth',
|
|
113
|
+
it('with multiple levels of depth', () => {
|
|
82
114
|
const example = parse('$foo.bar.baz', { Variable });
|
|
83
115
|
expect(example).toDeepEqual({
|
|
84
116
|
type: 'variable',
|
|
@@ -86,7 +118,7 @@ describe('Markdoc tag parser', function () {
|
|
|
86
118
|
});
|
|
87
119
|
});
|
|
88
120
|
|
|
89
|
-
it('with an array index',
|
|
121
|
+
it('with an array index', () => {
|
|
90
122
|
const example = parse('$foo[1]', { Variable });
|
|
91
123
|
expect(example).toDeepEqual({
|
|
92
124
|
type: 'variable',
|
|
@@ -94,7 +126,7 @@ describe('Markdoc tag parser', function () {
|
|
|
94
126
|
});
|
|
95
127
|
});
|
|
96
128
|
|
|
97
|
-
it('with multiple array indexes',
|
|
129
|
+
it('with multiple array indexes', () => {
|
|
98
130
|
const example = parse('$foo[1][2]', { Variable });
|
|
99
131
|
expect(example).toDeepEqual({
|
|
100
132
|
type: 'variable',
|
|
@@ -102,7 +134,7 @@ describe('Markdoc tag parser', function () {
|
|
|
102
134
|
});
|
|
103
135
|
});
|
|
104
136
|
|
|
105
|
-
it('with array indexes and properties',
|
|
137
|
+
it('with array indexes and properties', () => {
|
|
106
138
|
const example = parse('$foo[1].bar.baz[2].test', { Variable });
|
|
107
139
|
expect(example).toDeepEqual({
|
|
108
140
|
type: 'variable',
|
|
@@ -112,33 +144,33 @@ describe('Markdoc tag parser', function () {
|
|
|
112
144
|
});
|
|
113
145
|
});
|
|
114
146
|
|
|
115
|
-
it('with an invalid array index',
|
|
147
|
+
it('with an invalid array index', () => {
|
|
116
148
|
expect(() => parse('$foo[asdf]', { Variable })).toThrowError(SyntaxError);
|
|
117
149
|
});
|
|
118
150
|
|
|
119
|
-
it('with an invalid namespace',
|
|
151
|
+
it('with an invalid namespace', () => {
|
|
120
152
|
expect(() => parse('$.foo:bar.baz', { Variable })).toThrowError(
|
|
121
|
-
SyntaxError
|
|
153
|
+
SyntaxError,
|
|
122
154
|
);
|
|
123
155
|
});
|
|
124
156
|
});
|
|
125
157
|
|
|
126
|
-
describe('parsing attributes',
|
|
127
|
-
it('parsing annotation with a single attribute',
|
|
158
|
+
describe('parsing attributes', () => {
|
|
159
|
+
it('parsing annotation with a single attribute', () => {
|
|
128
160
|
const example = parse('test=1');
|
|
129
161
|
expect(example.meta.attributes).toDeepEqual([
|
|
130
162
|
{ type: 'attribute', name: 'test', value: 1 },
|
|
131
163
|
]);
|
|
132
164
|
});
|
|
133
165
|
|
|
134
|
-
it('with an id',
|
|
166
|
+
it('with an id', () => {
|
|
135
167
|
const example = parse('#test');
|
|
136
168
|
expect(example.meta.attributes).toDeepEqual([
|
|
137
169
|
{ type: 'attribute', name: 'id', value: 'test' },
|
|
138
170
|
]);
|
|
139
171
|
});
|
|
140
172
|
|
|
141
|
-
it('with hyphens',
|
|
173
|
+
it('with hyphens', () => {
|
|
142
174
|
const example = parse('#test-1 .foo-bar');
|
|
143
175
|
expect(example.meta.attributes).toDeepEqual([
|
|
144
176
|
{ type: 'attribute', name: 'id', value: 'test-1' },
|
|
@@ -146,7 +178,7 @@ describe('Markdoc tag parser', function () {
|
|
|
146
178
|
]);
|
|
147
179
|
});
|
|
148
180
|
|
|
149
|
-
it('with chained classes',
|
|
181
|
+
it('with chained classes', () => {
|
|
150
182
|
const example = parse('.foo .bar');
|
|
151
183
|
expect(example.meta.attributes).toDeepEqual([
|
|
152
184
|
{ type: 'class', name: 'foo', value: true },
|
|
@@ -154,7 +186,7 @@ describe('Markdoc tag parser', function () {
|
|
|
154
186
|
]);
|
|
155
187
|
});
|
|
156
188
|
|
|
157
|
-
it('with chained id and classes',
|
|
189
|
+
it('with chained id and classes', () => {
|
|
158
190
|
const example = parse('#test-1 .foo .bar');
|
|
159
191
|
expect(example.meta.attributes).toDeepEqual([
|
|
160
192
|
{ type: 'attribute', name: 'id', value: 'test-1' },
|
|
@@ -167,7 +199,7 @@ describe('Markdoc tag parser', function () {
|
|
|
167
199
|
expect(() => parse('#foo@bar.baz@test')).toThrowError(SyntaxError);
|
|
168
200
|
});
|
|
169
201
|
|
|
170
|
-
it('with key/value pairs',
|
|
202
|
+
it('with key/value pairs', () => {
|
|
171
203
|
const example = parse('foo="bar" baz=3 test=true');
|
|
172
204
|
expect(example.meta.attributes).toDeepEqual([
|
|
173
205
|
{ type: 'attribute', name: 'foo', value: 'bar' },
|
|
@@ -176,7 +208,7 @@ describe('Markdoc tag parser', function () {
|
|
|
176
208
|
]);
|
|
177
209
|
});
|
|
178
210
|
|
|
179
|
-
it('with shortcuts and key/value pairs',
|
|
211
|
+
it('with shortcuts and key/value pairs', () => {
|
|
180
212
|
const example = parse('#foo .bar test="asdf"', { Variable });
|
|
181
213
|
expect(example.meta.attributes).toDeepEqual([
|
|
182
214
|
{ type: 'attribute', name: 'id', value: 'foo' },
|
|
@@ -185,7 +217,7 @@ describe('Markdoc tag parser', function () {
|
|
|
185
217
|
]);
|
|
186
218
|
});
|
|
187
219
|
|
|
188
|
-
it('with boolean key/value pairs',
|
|
220
|
+
it('with boolean key/value pairs', () => {
|
|
189
221
|
const example = parse('test=true foo=false bar=true');
|
|
190
222
|
expect(example.meta.attributes).toDeepEqual([
|
|
191
223
|
{ type: 'attribute', name: 'test', value: true },
|
|
@@ -194,15 +226,15 @@ describe('Markdoc tag parser', function () {
|
|
|
194
226
|
]);
|
|
195
227
|
});
|
|
196
228
|
|
|
197
|
-
it('with null key/value pair',
|
|
229
|
+
it('with null key/value pair', () => {
|
|
198
230
|
const example = parse('foo=null');
|
|
199
231
|
expect(example.meta.attributes).toDeepEqual([
|
|
200
232
|
{ type: 'attribute', name: 'foo', value: null },
|
|
201
233
|
]);
|
|
202
234
|
});
|
|
203
235
|
|
|
204
|
-
describe('with variables as values',
|
|
205
|
-
it('with a simple variable',
|
|
236
|
+
describe('with variables as values', () => {
|
|
237
|
+
it('with a simple variable', () => {
|
|
206
238
|
const example = parse('test=$foo', { Variable });
|
|
207
239
|
expect(example.meta.attributes).toDeepEqual([
|
|
208
240
|
{
|
|
@@ -213,7 +245,7 @@ describe('Markdoc tag parser', function () {
|
|
|
213
245
|
]);
|
|
214
246
|
});
|
|
215
247
|
|
|
216
|
-
it('with multiple levels of depth',
|
|
248
|
+
it('with multiple levels of depth', () => {
|
|
217
249
|
const example = parse('test=$foo.bar.baz', { Variable });
|
|
218
250
|
expect(example.meta.attributes).toDeepEqual([
|
|
219
251
|
{
|
|
@@ -224,7 +256,7 @@ describe('Markdoc tag parser', function () {
|
|
|
224
256
|
]);
|
|
225
257
|
});
|
|
226
258
|
|
|
227
|
-
it('with an array index',
|
|
259
|
+
it('with an array index', () => {
|
|
228
260
|
const example = parse('test=$foo[1]', { Variable });
|
|
229
261
|
expect(example.meta.attributes).toDeepEqual([
|
|
230
262
|
{
|
|
@@ -235,7 +267,7 @@ describe('Markdoc tag parser', function () {
|
|
|
235
267
|
]);
|
|
236
268
|
});
|
|
237
269
|
|
|
238
|
-
it('with multiple array indexes',
|
|
270
|
+
it('with multiple array indexes', () => {
|
|
239
271
|
const example = parse('test=$foo[1][2]', { Variable });
|
|
240
272
|
expect(example.meta.attributes).toDeepEqual([
|
|
241
273
|
{
|
|
@@ -246,7 +278,7 @@ describe('Markdoc tag parser', function () {
|
|
|
246
278
|
]);
|
|
247
279
|
});
|
|
248
280
|
|
|
249
|
-
it('with array indexes and properties',
|
|
281
|
+
it('with array indexes and properties', () => {
|
|
250
282
|
const example = parse('test=$foo[1].bar.baz[2].test', { Variable });
|
|
251
283
|
expect(example.meta.attributes).toDeepEqual([
|
|
252
284
|
{
|
|
@@ -257,24 +289,24 @@ describe('Markdoc tag parser', function () {
|
|
|
257
289
|
]);
|
|
258
290
|
});
|
|
259
291
|
|
|
260
|
-
it('with an invalid array index',
|
|
292
|
+
it('with an invalid array index', () => {
|
|
261
293
|
expect(() => parse('test=$foo[asdf]', { Variable })).toThrowError(
|
|
262
|
-
SyntaxError
|
|
294
|
+
SyntaxError,
|
|
263
295
|
);
|
|
264
296
|
});
|
|
265
297
|
});
|
|
266
298
|
|
|
267
|
-
describe('with complex values',
|
|
268
|
-
it('with a simple hash literal value',
|
|
299
|
+
describe('with complex values', () => {
|
|
300
|
+
it('with a simple hash literal value', () => {
|
|
269
301
|
const example = parse('foo={bar: true}');
|
|
270
302
|
expect(example.meta.attributes).toDeepEqual([
|
|
271
303
|
{ type: 'attribute', name: 'foo', value: { bar: true } },
|
|
272
304
|
]);
|
|
273
305
|
});
|
|
274
306
|
|
|
275
|
-
it('with a nested hash literal value',
|
|
307
|
+
it('with a nested hash literal value', () => {
|
|
276
308
|
const example1 = parse(
|
|
277
|
-
'foo={bar: true, baz: {test: "this is a test"}}'
|
|
309
|
+
'foo={bar: true, baz: {test: "this is a test"}}',
|
|
278
310
|
);
|
|
279
311
|
const example2 = parse('foo={bar:true,baz:{test:"this is a test"}}');
|
|
280
312
|
const expected = [
|
|
@@ -292,14 +324,14 @@ describe('Markdoc tag parser', function () {
|
|
|
292
324
|
expect(example2.meta.attributes).toDeepEqual(expected);
|
|
293
325
|
});
|
|
294
326
|
|
|
295
|
-
it('with a hash literal that has string keys',
|
|
327
|
+
it('with a hash literal that has string keys', () => {
|
|
296
328
|
const example = parse('foo={bar: true, "baz": 1}');
|
|
297
329
|
expect(example.meta.attributes).toDeepEqual([
|
|
298
330
|
{ type: 'attribute', name: 'foo', value: { bar: true, baz: 1 } },
|
|
299
331
|
]);
|
|
300
332
|
});
|
|
301
333
|
|
|
302
|
-
it('with multiple hash literal values',
|
|
334
|
+
it('with multiple hash literal values', () => {
|
|
303
335
|
const example = parse('foo={bar: true} baz={test: "testing"}');
|
|
304
336
|
expect(example.meta.attributes).toDeepEqual([
|
|
305
337
|
{ type: 'attribute', name: 'foo', value: { bar: true } },
|
|
@@ -307,7 +339,7 @@ describe('Markdoc tag parser', function () {
|
|
|
307
339
|
]);
|
|
308
340
|
});
|
|
309
341
|
|
|
310
|
-
it('with an array literal value',
|
|
342
|
+
it('with an array literal value', () => {
|
|
311
343
|
const example1 = parse('foo=[1, 2, 3]');
|
|
312
344
|
const example2 = parse('foo=[1,2,3]');
|
|
313
345
|
const expected = [{ type: 'attribute', name: 'foo', value: [1, 2, 3] }];
|
|
@@ -316,7 +348,7 @@ describe('Markdoc tag parser', function () {
|
|
|
316
348
|
expect(example2.meta.attributes).toDeepEqual(expected);
|
|
317
349
|
});
|
|
318
350
|
|
|
319
|
-
it('with nested array literal values',
|
|
351
|
+
it('with nested array literal values', () => {
|
|
320
352
|
const example1 = parse('foo=[1, 2, ["test", true, null]]');
|
|
321
353
|
const example2 = parse('foo=[1,2,["test",true,null]]');
|
|
322
354
|
const expected = [
|
|
@@ -331,7 +363,7 @@ describe('Markdoc tag parser', function () {
|
|
|
331
363
|
expect(example2.meta.attributes).toDeepEqual(expected);
|
|
332
364
|
});
|
|
333
365
|
|
|
334
|
-
it('with multiple nested array literal values',
|
|
366
|
+
it('with multiple nested array literal values', () => {
|
|
335
367
|
const example = parse('foo=[1, 2, ["test", true, null]] bar=["baz"]');
|
|
336
368
|
expect(example.meta.attributes).toDeepEqual([
|
|
337
369
|
{
|
|
@@ -343,7 +375,7 @@ describe('Markdoc tag parser', function () {
|
|
|
343
375
|
]);
|
|
344
376
|
});
|
|
345
377
|
|
|
346
|
-
it('with array and object literals',
|
|
378
|
+
it('with array and object literals', () => {
|
|
347
379
|
const example = parse('foo=[1, 2, {bar: "baz", test: [1, 2, 3]}]');
|
|
348
380
|
expect(example.meta.attributes).toDeepEqual([
|
|
349
381
|
{
|
|
@@ -355,7 +387,7 @@ describe('Markdoc tag parser', function () {
|
|
|
355
387
|
});
|
|
356
388
|
});
|
|
357
389
|
|
|
358
|
-
it('with an invalid value',
|
|
390
|
+
it('with an invalid value', () => {
|
|
359
391
|
const examples = ['foo=bar', 'foo=a1', 'foo=1a'];
|
|
360
392
|
for (const example of examples)
|
|
361
393
|
expect(() => parse(example)).toThrowError(SyntaxError);
|