@markdoc/markdoc 0.5.13 → 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.
Files changed (86) hide show
  1. package/README.md +11 -0
  2. package/dist/index.d.ts +4 -4
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +467 -462
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.mjs +467 -462
  7. package/dist/index.mjs.map +4 -4
  8. package/dist/react.js +1 -1
  9. package/dist/react.js.map +2 -2
  10. package/dist/src/ast/base.d.ts +1 -1
  11. package/dist/src/ast/base.d.ts.map +1 -1
  12. package/dist/src/ast/function.d.ts +1 -1
  13. package/dist/src/ast/function.d.ts.map +1 -1
  14. package/dist/src/ast/index.d.ts +2 -2
  15. package/dist/src/ast/index.d.ts.map +1 -1
  16. package/dist/src/ast/node.d.ts.map +1 -1
  17. package/dist/src/ast/variable.d.ts +1 -1
  18. package/dist/src/ast/variable.d.ts.map +1 -1
  19. package/dist/src/formatter.d.ts.map +1 -1
  20. package/dist/src/functions/index.d.ts.map +1 -1
  21. package/dist/src/parser.d.ts.map +1 -1
  22. package/dist/src/renderers/html.d.ts.map +1 -1
  23. package/dist/src/renderers/react/react.d.ts +2 -2
  24. package/dist/src/renderers/react/react.d.ts.map +1 -1
  25. package/dist/src/renderers/react/static.d.ts +1 -1
  26. package/dist/src/renderers/react/static.d.ts.map +1 -1
  27. package/dist/src/schema-types/class.d.ts +1 -1
  28. package/dist/src/schema-types/class.d.ts.map +1 -1
  29. package/dist/src/schema-types/conditional.d.ts +1 -1
  30. package/dist/src/schema-types/conditional.d.ts.map +1 -1
  31. package/dist/src/schema.d.ts.map +1 -1
  32. package/dist/src/tags/conditional.d.ts +1 -1
  33. package/dist/src/tags/conditional.d.ts.map +1 -1
  34. package/dist/src/tokenizer/index.d.ts.map +1 -1
  35. package/dist/src/tokenizer/plugins/annotations.d.ts.map +1 -1
  36. package/dist/src/transformer.d.ts.map +1 -1
  37. package/dist/src/validator.d.ts +1 -1
  38. package/dist/src/validator.d.ts.map +1 -1
  39. package/index.ts +21 -22
  40. package/package.json +7 -13
  41. package/spec/support/matchers.d.ts +6 -4
  42. package/src/ast/base.ts +2 -2
  43. package/src/ast/function.ts +1 -1
  44. package/src/ast/index.ts +3 -4
  45. package/src/ast/node.test.ts +60 -46
  46. package/src/ast/node.ts +3 -3
  47. package/src/ast/variable.test.ts +5 -4
  48. package/src/ast/variable.ts +1 -1
  49. package/src/formatter.test.ts +4 -3
  50. package/src/formatter.ts +11 -11
  51. package/src/functions/index.test.ts +8 -7
  52. package/src/functions/index.ts +1 -1
  53. package/src/grammar/tag.d.ts +1 -1
  54. package/src/grammar/tag.js +208 -285
  55. package/src/grammar/tag.pegjs +4 -4
  56. package/src/grammar/tag.test.ts +56 -52
  57. package/src/parser.test.ts +93 -70
  58. package/src/parser.ts +19 -6
  59. package/src/renderers/html.test.ts +56 -16
  60. package/src/renderers/html.ts +10 -2
  61. package/src/renderers/react/react.test.ts +29 -28
  62. package/src/renderers/react/react.ts +7 -8
  63. package/src/renderers/react/static.ts +5 -6
  64. package/src/schema-types/class.ts +1 -1
  65. package/src/schema-types/conditional.ts +1 -1
  66. package/src/schema.ts +9 -4
  67. package/src/tag.test.ts +2 -1
  68. package/src/tag.ts +1 -1
  69. package/src/tags/conditional.ts +4 -4
  70. package/src/tags/index.ts +2 -2
  71. package/src/tags/partial.ts +1 -1
  72. package/src/tokenizer/index.ts +6 -5
  73. package/src/tokenizer/plugins/annotations.test.ts +29 -28
  74. package/src/tokenizer/plugins/annotations.ts +12 -12
  75. package/src/tokenizer/plugins/comments.test.ts +11 -10
  76. package/src/tokenizer/plugins/comments.ts +2 -2
  77. package/src/tokenizer/plugins/frontmatter.test.ts +7 -6
  78. package/src/tokenizer/plugins/frontmatter.ts +2 -2
  79. package/src/tokenizer/plugins/link.test.ts +14 -13
  80. package/src/transformer.ts +7 -5
  81. package/src/transforms/table.test.ts +18 -17
  82. package/src/transforms/table.ts +1 -1
  83. package/src/utils.test.ts +23 -22
  84. package/src/utils.ts +3 -3
  85. package/src/validator.test.ts +60 -59
  86. package/src/validator.ts +13 -11
@@ -1,14 +1,13 @@
1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
1
+ import { describe, expect, it } from 'vitest';
2
2
  import markdoc from '../../index';
3
+ import Tag from '../tag';
4
+ import { getAstValues } from './base';
3
5
  import FunctionNode from './function';
4
6
  import Node from './node';
5
7
  import Variable from './variable';
6
- import { getAstValues } from './base';
7
8
 
8
- import Tag from '../tag';
9
-
10
- describe('Node object', function () {
11
- it('copies only own attributes into a prototype-free dictionary', function () {
9
+ describe('Node object', () => {
10
+ it('copies only own attributes into a prototype-free dictionary', () => {
12
11
  const attributes = Object.assign(Object.create({ inherited: 'value' }), {
13
12
  own: 'value',
14
13
  });
@@ -18,7 +17,7 @@ describe('Node object', function () {
18
17
  expect(node.attributes.own).toBe('value');
19
18
  });
20
19
 
21
- it('preserves prototype-free attributes and resolves nested values', function () {
20
+ it('preserves prototype-free attributes and resolves nested values', () => {
22
21
  const attributes = Object.fromEntries([
23
22
  ['__proto__', { src: new Variable(['url']) }],
24
23
  ['src', new Variable(['url'])],
@@ -29,17 +28,18 @@ describe('Node object', function () {
29
28
  });
30
29
  expect(Object.getPrototypeOf(resolved.attributes)).toBeNull();
31
30
  expect(Object.keys(resolved.attributes)).toEqual(['__proto__', 'src']);
31
+ // biome-ignore lint/suspicious/noProto: Verify the own __proto__ data property preserved by the security fix.
32
32
  expect(resolved.attributes.__proto__.src).toBe('https://example.com/');
33
33
  expect(resolved.attributes.src).toBe('https://example.com/');
34
34
  });
35
35
 
36
- it('traverses AST values in prototype-free attribute dictionaries', function () {
36
+ it('traverses AST values in prototype-free attribute dictionaries', () => {
37
37
  const variable = new Variable(['url']);
38
38
  const node = new Node('tag', { src: variable });
39
39
  expect([...getAstValues(node.attributes)]).toEqual([variable]);
40
40
  });
41
41
 
42
- it('resolves object values without invoking prototype setters', function () {
42
+ it('resolves object values without invoking prototype setters', () => {
43
43
  const value = Object.fromEntries([
44
44
  ['safe', new Variable(['url'])],
45
45
  ['__proto__', { src: new Variable(['url']) }],
@@ -49,26 +49,27 @@ describe('Node object', function () {
49
49
  variables: { url: 'https://example.com/' },
50
50
  });
51
51
  expect(Object.getPrototypeOf(resolved.attributes.value)).toBe(
52
- Object.prototype
52
+ Object.prototype,
53
53
  );
54
54
  expect(Object.keys(resolved.attributes.value)).toEqual([
55
55
  'safe',
56
56
  '__proto__',
57
57
  ]);
58
58
  expect(resolved.attributes.value.src).toBeUndefined();
59
+ // biome-ignore lint/suspicious/noProto: Verify the own __proto__ data property preserved by the security fix.
59
60
  expect(resolved.attributes.value.__proto__.src).toBe(
60
- 'https://example.com/'
61
+ 'https://example.com/',
61
62
  );
62
63
  });
63
64
 
64
- it('resolves serialized function and variable attributes', function () {
65
+ it('resolves serialized function and variable attributes', () => {
65
66
  const serialized = JSON.parse(
66
67
  JSON.stringify({
67
68
  direct: new Variable(['answer']),
68
69
  computed: new FunctionNode('identity', {
69
70
  0: new Variable(['answer']),
70
71
  }),
71
- })
72
+ }),
72
73
  );
73
74
  const node = new Node('tag', serialized);
74
75
  const resolved = node.resolve({
@@ -82,8 +83,8 @@ describe('Node object', function () {
82
83
  expect(resolved.attributes.computed).toBe('resolved');
83
84
  });
84
85
 
85
- describe('traversal', function () {
86
- it('with a simple document', function () {
86
+ describe('traversal', () => {
87
+ it('with a simple document', () => {
87
88
  const example = new Node('document', {}, [
88
89
  new Node('heading', { level: 1 }, [
89
90
  new Node('inline', {}, [
@@ -105,7 +106,7 @@ describe('Node object', function () {
105
106
  });
106
107
  });
107
108
 
108
- it('without slots', function () {
109
+ it('without slots', () => {
109
110
  const example = `
110
111
  {% example %}
111
112
  # bar
@@ -127,7 +128,7 @@ baz
127
128
  ]);
128
129
  });
129
130
 
130
- it('with slots', function () {
131
+ it('with slots', () => {
131
132
  const example = `
132
133
  {% example %}
133
134
  # bar
@@ -153,13 +154,13 @@ baz
153
154
  });
154
155
  });
155
156
 
156
- describe('transform', function () {
157
+ describe('transform', () => {
157
158
  function transform(content, config = {}) {
158
159
  return markdoc.transform(content, config);
159
160
  }
160
161
 
161
- describe('built-in nodes', function () {
162
- it('a heading node', function () {
162
+ describe('built-in nodes', () => {
163
+ it('a heading node', () => {
163
164
  const example = new Node('heading', { level: 1 }, [
164
165
  new Node('inline', {}, [
165
166
  new Node('text', { content: 'This is a heading' }),
@@ -170,22 +171,35 @@ describe('transform', function () {
170
171
  expect(output).toDeepEqual(new Tag('h1', {}, ['This is a heading']));
171
172
  });
172
173
 
173
- describe('fenced code blocks', function () {
174
- it('fenced code block with language', function () {
174
+ it('a heading node with an invalid level', () => {
175
+ const levels = ['1>x', '2', 0, 7, 1.5];
176
+ for (const level of levels) {
177
+ const example = new Node('heading', { level }, [
178
+ new Node('inline', {}, [
179
+ new Node('text', { content: 'This is a heading' }),
180
+ ]),
181
+ ]);
182
+
183
+ expect(transform(example)).toDeepEqual(['This is a heading']);
184
+ }
185
+ });
186
+
187
+ describe('fenced code blocks', () => {
188
+ it('fenced code block with language', () => {
175
189
  const example = new Node('fence', {
176
190
  language: 'ruby',
177
191
  content: 'test',
178
192
  });
179
193
  const output = transform(example);
180
194
  expect(output).toDeepEqual(
181
- new Tag('pre', { 'data-language': 'ruby' }, ['test'])
195
+ new Tag('pre', { 'data-language': 'ruby' }, ['test']),
182
196
  );
183
197
  });
184
198
  });
185
199
  });
186
200
 
187
- describe('transform functions', function () {
188
- it('with a simple render function', function () {
201
+ describe('transform functions', () => {
202
+ it('with a simple render function', () => {
189
203
  const example = new Node('foo', {});
190
204
 
191
205
  const foo = {
@@ -198,7 +212,7 @@ describe('transform', function () {
198
212
  expect(output).toDeepEqual(new Tag('foo', {}, []));
199
213
  });
200
214
 
201
- it('with a render function that renders attributes', function () {
215
+ it('with a render function that renders attributes', () => {
202
216
  const example = new Node('foo', { bar: 'baz', test: 100 });
203
217
  const foo = {
204
218
  attributes: {
@@ -221,7 +235,7 @@ describe('transform', function () {
221
235
  });
222
236
  });
223
237
 
224
- describe('tags', function () {
238
+ describe('tags', () => {
225
239
  const tags = {
226
240
  foo: {
227
241
  render: 'foo',
@@ -231,32 +245,32 @@ describe('transform', function () {
231
245
  },
232
246
  };
233
247
 
234
- it('with a tag', function () {
248
+ it('with a tag', () => {
235
249
  const example = new Node(
236
250
  'tag',
237
251
  { bar: 'baz' },
238
252
  [new Node('inline', {}, [new Node('text', { content: 'test' })])],
239
- 'foo'
253
+ 'foo',
240
254
  );
241
255
 
242
256
  const output = transform(example, { tags });
243
257
  expect(output).toDeepEqual(new Tag('foo', { bar: 'baz' }, ['test']));
244
258
  });
245
259
 
246
- it('with a non-existing tag', function () {
260
+ it('with a non-existing tag', () => {
247
261
  const example = new Node('container', { bar: 'baz' }, [
248
262
  new Node('inline', {}, [new Node('text', { content: 'test' })]),
249
263
  ]);
250
264
 
251
- // @ts-ignore test mutating node in userland
265
+ // @ts-expect-error test mutating node in userland
252
266
  example.container = 'bar';
253
267
  const output = transform(example, { tags });
254
268
  expect(output).toDeepEqual(['test']);
255
269
  });
256
270
  });
257
271
 
258
- describe('tag name', function () {
259
- it('with a string value', function () {
272
+ describe('tag name', () => {
273
+ it('with a string value', () => {
260
274
  const example = new Node('foo', {});
261
275
  const foo = { render: 'foo' };
262
276
 
@@ -264,7 +278,7 @@ describe('transform', function () {
264
278
  expect(output.name).toEqual('foo');
265
279
  });
266
280
 
267
- it('with no value', function () {
281
+ it('with no value', () => {
268
282
  const example = new Node('foo', {}, [new Node('bar', {})]);
269
283
 
270
284
  const output = transform(example, {
@@ -274,8 +288,8 @@ describe('transform', function () {
274
288
  });
275
289
  });
276
290
 
277
- describe('attributes', function () {
278
- it('with an id', function () {
291
+ describe('attributes', () => {
292
+ it('with an id', () => {
279
293
  const example = new Node('paragraph', { id: 'bar' });
280
294
  const output = transform(example);
281
295
  expect(output).toDeepEqualSubset({
@@ -284,7 +298,7 @@ describe('transform', function () {
284
298
  });
285
299
  });
286
300
 
287
- it('with a class', function () {
301
+ it('with a class', () => {
288
302
  const example = new Node('paragraph', {
289
303
  class: { foo: true, bar: false },
290
304
  });
@@ -292,7 +306,7 @@ describe('transform', function () {
292
306
  expect(output).toDeepEqual(new Tag('p', { class: 'foo' }, []));
293
307
  });
294
308
 
295
- it('with boolean render attribute', function () {
309
+ it('with boolean render attribute', () => {
296
310
  const example = new Node('foo', { bar: 1, baz: 'test' });
297
311
  const foo = {
298
312
  render: 'foo',
@@ -306,7 +320,7 @@ describe('transform', function () {
306
320
  expect(output).toDeepEqual(new Tag('foo', { bar: 1, baz: 'test' }));
307
321
  });
308
322
 
309
- it('with string render attribute', function () {
323
+ it('with string render attribute', () => {
310
324
  const example = new Node('foo', { bar: 1, baz: 'test' });
311
325
  const foo = {
312
326
  render: 'foo',
@@ -318,11 +332,11 @@ describe('transform', function () {
318
332
 
319
333
  const output = transform(example, { nodes: { foo } });
320
334
  expect(output).toDeepEqual(
321
- new Tag('foo', { 'data-bar': 1, 'data-baz': 'test' })
335
+ new Tag('foo', { 'data-bar': 1, 'data-baz': 'test' }),
322
336
  );
323
337
  });
324
338
 
325
- it('with a non-rendered attribute', function () {
339
+ it('with a non-rendered attribute', () => {
326
340
  const example = new Node('foo', { bar: 1, baz: 'test' });
327
341
  const foo = {
328
342
  render: 'foo',
@@ -332,11 +346,11 @@ describe('transform', function () {
332
346
  };
333
347
 
334
348
  const output = transform(example, { nodes: { foo } }) as Tag;
335
- expect(Object.keys(output.attributes).includes('baz')).toBeFalse();
349
+ expect(Object.keys(output.attributes).includes('baz')).toBe(false);
336
350
  expect(output).toDeepEqual(new Tag('foo', { bar: 1 }, []));
337
351
  });
338
352
 
339
- it('with a default attribute value', function () {
353
+ it('with a default attribute value', () => {
340
354
  const example = new Node('foo', {});
341
355
  const foo = {
342
356
  render: 'foo',
@@ -349,7 +363,7 @@ describe('transform', function () {
349
363
  expect(output.attributes.bar).toEqual(10);
350
364
  });
351
365
 
352
- it('with an overriden default attribute value', function () {
366
+ it('with an overriden default attribute value', () => {
353
367
  const example = new Node('foo', { bar: 1 });
354
368
  const foo = {
355
369
  render: 'foo',
@@ -362,7 +376,7 @@ describe('transform', function () {
362
376
  expect(output.attributes.bar).toEqual(1);
363
377
  });
364
378
 
365
- it('variable nested in a hash', function () {
379
+ it('variable nested in a hash', () => {
366
380
  const bar = new Variable(['a', 'b', 'c']);
367
381
  const example = new Node('foo', { bar });
368
382
  const foo = {
@@ -431,7 +445,7 @@ describe('transform', function () {
431
445
  describe('annotations', () => {
432
446
  it('multiple values should be ordered correctly', () => {
433
447
  const example = markdoc.parse(
434
- `\`\`\`js {% z=true .class y=2 x="1" #id %} \nContent\n\`\`\``
448
+ `\`\`\`js {% z=true .class y=2 x="1" #id %} \nContent\n\`\`\``,
435
449
  );
436
450
 
437
451
  const fence = example.children[0];
package/src/ast/node.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { resolve } from './base';
2
1
  import transformer from '../transformer';
3
2
  import type {
4
3
  AstType,
@@ -12,6 +11,7 @@ import type {
12
11
  Schema,
13
12
  ValidationError,
14
13
  } from '../types';
14
+ import { resolve } from './base';
15
15
 
16
16
  export default class Node implements AstType {
17
17
  readonly $$mdtype = 'Node';
@@ -32,7 +32,7 @@ export default class Node implements AstType {
32
32
  type: NodeType = 'node',
33
33
  attributes: Record<string, any> = {},
34
34
  children: Node[] = [],
35
- tag?: string
35
+ tag?: string,
36
36
  ) {
37
37
  this.attributes = Object.assign(Object.create(null), attributes);
38
38
  this.children = children;
@@ -61,7 +61,7 @@ export default class Node implements AstType {
61
61
  Object.entries(this.slots).map(([name, slot]) => [
62
62
  name,
63
63
  slot.resolve(config),
64
- ])
64
+ ]),
65
65
  ),
66
66
  });
67
67
  }
@@ -1,6 +1,7 @@
1
+ import { describe, expect, it } from 'vitest';
1
2
  import Variable from './variable';
2
3
 
3
- describe('variable', function () {
4
+ describe('variable', () => {
4
5
  const config = {
5
6
  variables: {
6
7
  foo: {
@@ -10,19 +11,19 @@ describe('variable', function () {
10
11
  },
11
12
  };
12
13
 
13
- it('basic resolution', function () {
14
+ it('basic resolution', () => {
14
15
  const example = new Variable(['foo', 'bar']);
15
16
  const output = example.resolve(config);
16
17
  expect(output).toEqual('example');
17
18
  });
18
19
 
19
- it('resolution with a number in the path', function () {
20
+ it('resolution with a number in the path', () => {
20
21
  const example = new Variable(['foo', 'baz', 1, 'qux']);
21
22
  const output = example.resolve(config);
22
23
  expect(output).toEqual('value');
23
24
  });
24
25
 
25
- it('resolution with a function', function () {
26
+ it('resolution with a function', () => {
26
27
  function variables(path) {
27
28
  expect(path).toDeepEqual(['foo', 'bar']);
28
29
  return 'example';
@@ -1,4 +1,4 @@
1
- import type { Config, AstType } from '../types';
1
+ import type { AstType, Config } from '../types';
2
2
 
3
3
  export default class Variable implements AstType {
4
4
  readonly $$mdtype = 'Variable';
@@ -1,4 +1,5 @@
1
1
  import { diff } from 'jest-diff';
2
+ import { describe, expect, it } from 'vitest';
2
3
 
3
4
  import Markdoc from '../index';
4
5
  import format from './formatter';
@@ -86,7 +87,7 @@ function check(source, expected, options = {}) {
86
87
  const b = format(Markdoc.parse(tokenizer.tokenize(source)), options);
87
88
  // console.log(a, b);
88
89
  const d = diff(a, b);
89
- if (d && d.includes('Compared values have no visual difference.')) return;
90
+ if (d?.includes('Compared values have no visual difference.')) return;
90
91
  throw d;
91
92
  }
92
93
 
@@ -896,14 +897,14 @@ ${'`'.repeat(4)}
896
897
  validAttribute: true,
897
898
  },
898
899
  [],
899
- 'tag'
900
+ 'tag',
900
901
  );
901
902
 
902
903
  const expected = `{% tag validAttribute=true /%}`;
903
904
 
904
905
  const b = format(sourceNode);
905
906
  const d = diff(expected, b.trim());
906
- if (d && d.includes('Compared values have no visual difference.')) return;
907
+ if (d?.includes('Compared values have no visual difference.')) return;
907
908
  });
908
909
 
909
910
  it('makes sure fences are formatted correctly if content has no ending newline', () => {
package/src/formatter.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import Ast from './ast';
2
- import { OPEN, CLOSE, isIdentifier } from './utils';
3
2
  import type { AttributeValue, Function, Node, Value, Variable } from './types';
3
+ import { CLOSE, isIdentifier, OPEN } from './utils';
4
4
 
5
5
  type Options = {
6
6
  allowIndentation?: boolean;
@@ -59,7 +59,7 @@ function formatScalar(v: Value): string | undefined {
59
59
  Object.entries(v)
60
60
  .map(
61
61
  ([key, value]) =>
62
- `${isIdentifier(key) ? key : `"${key}"`}: ${formatScalar(value)}`
62
+ `${isIdentifier(key) ? key : `"${key}"`}: ${formatScalar(value)}`,
63
63
  )
64
64
  .join(SEP) +
65
65
  '}'
@@ -122,7 +122,7 @@ function* formatFunction(f: Function) {
122
122
  }
123
123
 
124
124
  function* trimStart(g: Generator<string>) {
125
- let n;
125
+ let n: string;
126
126
  do {
127
127
  const { value, done } = g.next();
128
128
  if (done) return;
@@ -137,7 +137,7 @@ function* escapeMarkdownCharacters(s: string, characters: RegExp) {
137
137
  .replace(characters, '\\$&')
138
138
  // TODO keep &nbsp; as entity in the AST?
139
139
  // Non-breaking space (0xA0)
140
- .replace(new RegExp('\xa0', 'g'), '&nbsp;');
140
+ .replace(/\xa0/g, '&nbsp;');
141
141
  }
142
142
 
143
143
  function* formatNode(n: Node, o: Options = {}) {
@@ -146,7 +146,7 @@ function* formatNode(n: Node, o: Options = {}) {
146
146
 
147
147
  switch (n.type) {
148
148
  case 'document': {
149
- if (n.attributes.frontmatter && n.attributes.frontmatter.length) {
149
+ if (n.attributes.frontmatter?.length) {
150
150
  yield '---' + NL + n.attributes.frontmatter + NL + '---' + NL + NL;
151
151
  }
152
152
  yield* trimStart(formatChildren(n, no));
@@ -279,7 +279,7 @@ function* formatNode(n: Node, o: Options = {}) {
279
279
  }
280
280
  const open = OPEN + SPACE;
281
281
  const attributes = [...formatAttributes(n)].filter(
282
- (v) => v !== undefined
282
+ (v) => v !== undefined,
283
283
  );
284
284
  const tag = [open + n.tag, ...attributes];
285
285
  const inlineTag = tag.join(SPACE);
@@ -311,7 +311,7 @@ function* formatNode(n: Node, o: Options = {}) {
311
311
  }
312
312
  case 'list': {
313
313
  const isLoose = n.children.some((n) =>
314
- n.children.some((c) => c.type === 'paragraph')
314
+ n.children.some((c) => c.type === 'paragraph'),
315
315
  );
316
316
 
317
317
  for (let i = 0; i < n.children.length; i++) {
@@ -418,14 +418,14 @@ function* formatNode(n: Node, o: Options = {}) {
418
418
 
419
419
  yield NL;
420
420
  yield* formatTableRow(
421
- head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length))
421
+ head.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)),
422
422
  );
423
423
  yield NL;
424
- yield* formatTableRow(head.map((cell, i) => '-'.repeat(widths[i])));
424
+ yield* formatTableRow(head.map((_cell, i) => '-'.repeat(widths[i])));
425
425
  yield NL;
426
426
  for (const row of rows) {
427
427
  yield* formatTableRow(
428
- row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length))
428
+ row.map((cell, i) => cell + SPACE.repeat(widths[i] - cell.length)),
429
429
  );
430
430
  yield NL;
431
431
  }
@@ -462,7 +462,7 @@ function* formatNode(n: Node, o: Options = {}) {
462
462
 
463
463
  function* formatValue(
464
464
  v: Value | Value[],
465
- o: Options = {}
465
+ o: Options = {},
466
466
  ): Generator<string, void, unknown> {
467
467
  switch (typeof v) {
468
468
  case 'undefined':
@@ -1,9 +1,10 @@
1
- import functions from './index';
1
+ import { describe, expect, it } from 'vitest';
2
2
  import Ast from '../ast';
3
+ import functions from './index';
3
4
 
4
- describe('built-in functions', function () {
5
- describe('equals function', function () {
6
- it('true match with variable', function () {
5
+ describe('built-in functions', () => {
6
+ describe('equals function', () => {
7
+ it('true match with variable', () => {
7
8
  const example = new Ast.Function('equals', {
8
9
  0: new Ast.Variable(['foo']),
9
10
  1: 'bar',
@@ -14,10 +15,10 @@ describe('built-in functions', function () {
14
15
  variables: { foo: 'bar' },
15
16
  });
16
17
 
17
- expect(output).toBeTrue();
18
+ expect(output).toBe(true);
18
19
  });
19
20
 
20
- it('false match with variable', function () {
21
+ it('false match with variable', () => {
21
22
  const example = new Ast.Function('equals', {
22
23
  0: new Ast.Variable(['foo']),
23
24
  1: 'bar',
@@ -28,7 +29,7 @@ describe('built-in functions', function () {
28
29
  variables: { foo: 'baz' },
29
30
  });
30
31
 
31
- expect(output).toBeFalse();
32
+ expect(output).toBe(false);
32
33
  });
33
34
  });
34
35
  });
@@ -1,5 +1,5 @@
1
- import type { ConfigFunction } from '../types';
2
1
  import { truthy } from '../tags/conditional';
2
+ import type { ConfigFunction } from '../types';
3
3
 
4
4
  const and: ConfigFunction = {
5
5
  transform(parameters) {
@@ -1,6 +1,6 @@
1
1
  import type { Token } from 'markdown-it';
2
- import type AstVariable from '../ast/variable';
3
2
  import type AstFunction from '../ast/function';
3
+ import type AstVariable from '../ast/variable';
4
4
 
5
5
  type astTypes = {
6
6
  Variable?: typeof AstVariable;