@markdoc/markdoc 0.5.1 → 0.5.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/dist/index.js +2 -2
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +2 -2
- package/dist/src/formatter.d.ts +1 -1
- package/dist/src/formatter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/formatter.ts +2 -2
- package/src/tokenizer/plugins/comments.test.ts +24 -0
- package/src/tokenizer/plugins/comments.ts +2 -2
package/dist/src/formatter.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ declare type Options = {
|
|
|
6
6
|
parent?: Node;
|
|
7
7
|
indent?: number;
|
|
8
8
|
};
|
|
9
|
-
export default function format(v: Value, options?: Options): string;
|
|
9
|
+
export default function format(v: Value | Value[], options?: Options): string;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -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,eAAe,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IACzC,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAmeF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,
|
|
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,eAAe,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IACzC,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAmeF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAI5E"}
|
package/package.json
CHANGED
package/src/formatter.ts
CHANGED
|
@@ -453,7 +453,7 @@ function* formatNode(n: Node, o: Options = {}) {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
function* formatValue(
|
|
456
|
-
v: Value,
|
|
456
|
+
v: Value | Value[],
|
|
457
457
|
o: Options = {}
|
|
458
458
|
): Generator<string, void, unknown> {
|
|
459
459
|
switch (typeof v) {
|
|
@@ -491,7 +491,7 @@ function* formatValue(
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
|
|
494
|
-
export default function format(v: Value, options?: Options): string {
|
|
494
|
+
export default function format(v: Value | Value[], options?: Options): string {
|
|
495
495
|
let doc = '';
|
|
496
496
|
for (const s of formatValue(v, options)) doc += s;
|
|
497
497
|
return doc.trimStart();
|
|
@@ -90,5 +90,29 @@ describe('MarkdownIt Comments plugin', function () {
|
|
|
90
90
|
|
|
91
91
|
expect(example).toDeepEqualSubset(output);
|
|
92
92
|
});
|
|
93
|
+
|
|
94
|
+
it('block comment across multiple lines with blank lines', function () {
|
|
95
|
+
const actual = tokenizer.tokenize(
|
|
96
|
+
`
|
|
97
|
+
foo <!-- example
|
|
98
|
+
|
|
99
|
+
comment --> bar
|
|
100
|
+
`.trim()
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const expected = [
|
|
104
|
+
{ type: 'paragraph_open' },
|
|
105
|
+
{
|
|
106
|
+
type: 'inline',
|
|
107
|
+
children: [{ type: 'text', content: 'foo <!-- example' }],
|
|
108
|
+
},
|
|
109
|
+
{ type: 'paragraph_close' },
|
|
110
|
+
{ type: 'paragraph_open' },
|
|
111
|
+
{ type: 'inline', content: 'comment --> bar' },
|
|
112
|
+
{ type: 'paragraph_close' },
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
expect(actual).toDeepEqualSubset(expected);
|
|
116
|
+
});
|
|
93
117
|
});
|
|
94
118
|
});
|
|
@@ -16,7 +16,7 @@ function block(
|
|
|
16
16
|
|
|
17
17
|
const close = state.src.indexOf(CLOSE, start);
|
|
18
18
|
|
|
19
|
-
if (
|
|
19
|
+
if (close === -1) return false;
|
|
20
20
|
if (silent) return true;
|
|
21
21
|
|
|
22
22
|
const content = state.src.slice(start + OPEN.length, close);
|
|
@@ -34,7 +34,7 @@ function inline(state: StateInline, silent: boolean): boolean {
|
|
|
34
34
|
|
|
35
35
|
const close = state.src.indexOf(CLOSE, state.pos);
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (close === -1) return false;
|
|
38
38
|
if (silent) return true;
|
|
39
39
|
|
|
40
40
|
const content = state.src.slice(state.pos + OPEN.length, close);
|