@markdoc/markdoc 0.1.11 → 0.1.12

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;AA2YF,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;AAmZF,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.11",
4
+ "version": "0.1.12",
5
5
  "description": "A text markup language for documentation",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -18,7 +18,8 @@ Markdoc is a **Markdown**-based \`syntax\` and _toolchain_ for creating ~~custom
18
18
 
19
19
  ---
20
20
 
21
- ![Alt](/image)
21
+ [Link](/href "title")
22
+ ![Alt](/image "title")
22
23
 
23
24
  {% callout #id .class .class2 a="check" b={"e":{"with space": 5}} c=8 d=[1, "2",true] %}
24
25
  Markdoc is open-source—check out it's [source](http://github.com/markdoc/markdoc) to see how it works.
@@ -50,7 +51,8 @@ Markdoc is a **Markdown**-based \`syntax\` and _toolchain_ for creating ~~custom
50
51
 
51
52
  ---
52
53
 
53
- ![Alt](/image)
54
+ [Link](/href "title")
55
+ ![Alt](/image "title")
54
56
 
55
57
  {% callout
56
58
  #id
@@ -451,6 +453,13 @@ Yes!
451
453
  * Create your CNAME record
452
454
 
453
455
  1. Click **Add record**.
456
+
457
+ \`\`\`json
458
+ {
459
+ "nested": "code block"
460
+ }
461
+ \`\`\`
462
+
454
463
  1. Enter these values in the form that opens:
455
464
 
456
465
  {% table %}
@@ -489,6 +498,12 @@ Yes!
489
498
  - Create your CNAME record
490
499
 
491
500
  1. Click **Add record**.
501
+
502
+ \`\`\`json
503
+ {
504
+ "nested": "code block"
505
+ }
506
+ \`\`\`
492
507
  1. Enter these values in the form that opens:
493
508
 
494
509
  {% table %}
@@ -528,6 +543,24 @@ Yes!
528
543
  stable(expected);
529
544
  });
530
545
 
546
+ it('lists with annotated items', () => {
547
+ const source = `
548
+ - attributes: An object literal with key-value pairs that describe the attributes accepted by the tag. {% #id %}
549
+ - localizable: A boolean value (or an array) indicating whether the attribute’s value is translatable. {% #localizable %}
550
+ - Defaults to \`false\`
551
+ - description: A documentation string that describes the purpose of the attribute {% align="center" %}`;
552
+
553
+ const expected = `
554
+ - attributes: An object literal with key-value pairs that describe the attributes accepted by the tag. {% #id %}
555
+ - localizable: A boolean value (or an array) indicating whether the attribute’s value is translatable. {% #localizable %}
556
+ - Defaults to \`false\`
557
+ - description: A documentation string that describes the purpose of the attribute {% align="center" %}
558
+ `;
559
+
560
+ check(source, expected);
561
+ stable(expected);
562
+ });
563
+
531
564
  it('fences with block level tags', () => {
532
565
  const source = `{% tab %}
533
566
  \`\`\`json {% filename="package.json" %}
package/src/formatter.ts CHANGED
@@ -151,12 +151,28 @@ function* formatNode(n: Node, o: Options = {}) {
151
151
  yield* formatChildren(n, no);
152
152
  break;
153
153
  }
154
+ case 'image': {
155
+ yield '!';
156
+ yield '[';
157
+ yield* formatValue(n.attributes.alt, no);
158
+ yield ']';
159
+ yield '(';
160
+ yield* formatValue(n.attributes.src, no);
161
+ if (n.attributes.title) {
162
+ yield SPACE + `"${n.attributes.title}"`;
163
+ }
164
+ yield ')';
165
+ break;
166
+ }
154
167
  case 'link': {
155
168
  yield '[';
156
169
  yield* formatChildren(n, no);
157
170
  yield ']';
158
171
  yield '(';
159
172
  yield* formatValue(n.attributes.href, no);
173
+ if (n.attributes.title) {
174
+ yield SPACE + `"${n.attributes.title}"`;
175
+ }
160
176
  yield ')';
161
177
  break;
162
178
  }
@@ -180,16 +196,6 @@ function* formatNode(n: Node, o: Options = {}) {
180
196
  yield NL;
181
197
  break;
182
198
  }
183
- case 'image': {
184
- yield '!';
185
- yield '[';
186
- yield* formatValue(n.attributes.alt, no);
187
- yield ']';
188
- yield '(';
189
- yield* formatValue(n.attributes.src, no);
190
- yield ')';
191
- break;
192
- }
193
199
  case 'fence': {
194
200
  yield NL;
195
201
  yield indent;
@@ -200,8 +206,7 @@ function* formatNode(n: Node, o: Options = {}) {
200
206
  yield NL;
201
207
  yield indent;
202
208
  // TODO use formatChildren once we can differentiate inline from block tags within fences
203
- yield n.attributes.content; // yield* formatChildren(n, no);
204
- yield indent;
209
+ yield n.attributes.content.split(NL).join(NL + indent); // yield* formatChildren(n, no);
205
210
  yield '```';
206
211
  yield NL;
207
212
  break;
@@ -251,8 +256,11 @@ function* formatNode(n: Node, o: Options = {}) {
251
256
  break;
252
257
  }
253
258
  case 'item': {
254
- yield* formatChildren(n, no);
255
- yield* formatAnnotations(n);
259
+ for (let i = 0; i < n.children.length; i++) {
260
+ const child = n.children[i];
261
+ yield* formatValue(child, no);
262
+ if (i === 0) yield* formatAnnotations(n);
263
+ }
256
264
  break;
257
265
  }
258
266
  case 'strong': {