@markdoc/markdoc 0.1.8 → 0.1.9

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.
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,IAAI,EAAE,KAAK,EAAY,MAAM,SAAS,CAAC;AAE/E,aAAK,OAAO,GAAG;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAyXF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAIlE"}
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAA4B,IAAI,EAAE,KAAK,EAAY,MAAM,SAAS,CAAC;AAE/E,aAAK,OAAO,GAAG;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA4XF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAIlE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@markdoc/markdoc",
3
3
  "author": "Ryan Paul",
4
- "version": "0.1.8",
4
+ "version": "0.1.9",
5
5
  "description": "A text markup language for documentation",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -32,7 +32,7 @@
32
32
  "engines": {
33
33
  "node": ">=14.7.0"
34
34
  },
35
- "dependencies": {
35
+ "peerDependencies": {
36
36
  "@types/markdown-it": "*",
37
37
  "@types/react": "*"
38
38
  },
@@ -88,11 +88,27 @@ describe('Formatter', () => {
88
88
  expect(format(null)).toBe('');
89
89
  });
90
90
 
91
+ it('empty', () => {
92
+ check('', '');
93
+ stable('');
94
+ });
95
+
91
96
  it('basics', () => {
92
97
  check(source, expected);
93
98
  stable(expected);
94
99
  });
95
100
 
101
+ it('frontmatter', () => {
102
+ const source = `---
103
+ title: Title
104
+ subtitle: Subtitle
105
+ ---
106
+
107
+ `;
108
+ check(source, source);
109
+ stable(source);
110
+ });
111
+
96
112
  it('attribute edge cases', () => {
97
113
  const source = `{% key id=$user.name class=default($y, "test") %}Child{% /key %}`;
98
114
  const expected = `
@@ -472,4 +488,26 @@ Yes!
472
488
  check(source, expected);
473
489
  stable(expected);
474
490
  });
491
+
492
+ it('fences with block level tags', () => {
493
+ const source = `{% tab %}
494
+ \`\`\`json {% filename="package.json" %}
495
+ {
496
+ "dependencies": {
497
+ ...
498
+ {% highlight type="remove" %}
499
+ "beta": "1.2.3",
500
+ {% /highlight %}
501
+ {% highlight type="add" %}
502
+ "main": "1.2.4",
503
+ {% /highlight %}
504
+ ...
505
+ }
506
+ }
507
+ \`\`\`
508
+ {% /tab %}
509
+ `;
510
+
511
+ check(source, source);
512
+ });
475
513
  });
package/src/formatter.ts CHANGED
@@ -92,10 +92,12 @@ function* formatFunction(f: Function) {
92
92
  yield ')';
93
93
  }
94
94
 
95
- function* trimStart(g: Generator) {
95
+ function* trimStart(g: Generator<string>) {
96
96
  let n;
97
97
  do {
98
- n = g.next().value.trimStart();
98
+ const { value, done } = g.next();
99
+ if (done) return;
100
+ n = value.trimStart();
99
101
  } while (!n.length);
100
102
  yield n;
101
103
  yield* g;
@@ -183,7 +185,8 @@ function* formatNode(n: Node, o: Options = {}) {
183
185
  yield* formatAnnotations(n);
184
186
  yield NL;
185
187
  yield indent;
186
- yield* formatChildren(n, no);
188
+ // TODO use formatChildren once we can differentiate inline from block tags within fences
189
+ yield n.attributes.content; // yield* formatChildren(n, no);
187
190
  yield indent;
188
191
  yield '```';
189
192
  yield NL;