|
|
@@ -8,7 +8,7 @@ import { directive } from '../src/micromark-extension-growi-plugin/index.js';
|
|
|
|
|
|
test('markdown -> mdast', (t) => {
|
|
|
t.deepEqual(
|
|
|
- fromMarkdown('a :b[c]{d} e.', {
|
|
|
+ fromMarkdown('a $b[c]{d} e.', {
|
|
|
extensions: [directive()],
|
|
|
mdastExtensions: [directiveFromMarkdown],
|
|
|
}).children[0],
|
|
|
@@ -60,7 +60,7 @@ test('markdown -> mdast', (t) => {
|
|
|
);
|
|
|
|
|
|
t.deepEqual(
|
|
|
- fromMarkdown('::a[b]{c}', {
|
|
|
+ fromMarkdown('$a[b]{c}', {
|
|
|
extensions: [directive()],
|
|
|
mdastExtensions: [directiveFromMarkdown],
|
|
|
}).children[0],
|
|
|
@@ -73,76 +73,22 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'text',
|
|
|
value: 'b',
|
|
|
position: {
|
|
|
- start: { line: 1, column: 5, offset: 4 },
|
|
|
- end: { line: 1, column: 6, offset: 5 },
|
|
|
+ start: { line: 1, column: 4, offset: 3 },
|
|
|
+ end: { line: 1, column: 5, offset: 4 },
|
|
|
},
|
|
|
},
|
|
|
],
|
|
|
position: {
|
|
|
start: { line: 1, column: 1, offset: 0 },
|
|
|
- end: { line: 1, column: 10, offset: 9 },
|
|
|
+ end: { line: 1, column: 9, offset: 8 },
|
|
|
},
|
|
|
},
|
|
|
'should support directives (leaf)',
|
|
|
);
|
|
|
|
|
|
- t.deepEqual(
|
|
|
- fromMarkdown(':::a[b]{c}\nd', {
|
|
|
- extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown],
|
|
|
- }).children[0],
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- attributes: { c: '' },
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- data: { directiveLabel: true },
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- value: 'b',
|
|
|
- position: {
|
|
|
- start: { line: 1, column: 6, offset: 5 },
|
|
|
- end: { line: 1, column: 7, offset: 6 },
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- position: {
|
|
|
- start: { line: 1, column: 5, offset: 4 },
|
|
|
- end: { line: 1, column: 8, offset: 7 },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'text',
|
|
|
- value: 'd',
|
|
|
- position: {
|
|
|
- start: { line: 2, column: 1, offset: 11 },
|
|
|
- end: { line: 2, column: 2, offset: 12 },
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- position: {
|
|
|
- start: { line: 2, column: 1, offset: 11 },
|
|
|
- end: { line: 2, column: 2, offset: 12 },
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- position: {
|
|
|
- start: { line: 1, column: 1, offset: 0 },
|
|
|
- end: { line: 2, column: 2, offset: 12 },
|
|
|
- },
|
|
|
- },
|
|
|
- 'should support directives (container)',
|
|
|
- );
|
|
|
-
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
- fromMarkdown(':a[b *c*\nd]', {
|
|
|
+ fromMarkdown('x $a[b *c*\nd]', {
|
|
|
extensions: [directive()],
|
|
|
mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
@@ -154,6 +100,7 @@ test('markdown -> mdast', (t) => {
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
+ { type: 'text', value: 'x ' },
|
|
|
{
|
|
|
type: 'textGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
@@ -173,7 +120,7 @@ test('markdown -> mdast', (t) => {
|
|
|
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
- fromMarkdown(':a{#b.c.d e=f g="h&i&unknown;j"}', {
|
|
|
+ fromMarkdown('x $a{#b.c.d e=f g="h&i&unknown;j"}', {
|
|
|
extensions: [directive()],
|
|
|
mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
@@ -185,6 +132,7 @@ test('markdown -> mdast', (t) => {
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
+ { type: 'text', value: 'x ' },
|
|
|
{
|
|
|
type: 'textGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
@@ -202,7 +150,7 @@ test('markdown -> mdast', (t) => {
|
|
|
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
- fromMarkdown(':a{b\nc="d\ne"}', {
|
|
|
+ fromMarkdown('$a{b\nc="d\ne"}', {
|
|
|
extensions: [directive()],
|
|
|
mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
@@ -227,47 +175,6 @@ test('markdown -> mdast', (t) => {
|
|
|
'should support EOLs in attributes',
|
|
|
);
|
|
|
|
|
|
- t.deepEqual(
|
|
|
- removePosition(
|
|
|
- fromMarkdown('::::a\n:::b\n:c\n:::\n::::', {
|
|
|
- extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown],
|
|
|
- }),
|
|
|
- true,
|
|
|
- ),
|
|
|
- {
|
|
|
- type: 'root',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- attributes: {},
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'b',
|
|
|
- attributes: {},
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'textGrowiPluginDirective',
|
|
|
- name: 'c',
|
|
|
- attributes: {},
|
|
|
- children: [],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- 'should support directives in directives',
|
|
|
- );
|
|
|
-
|
|
|
t.end();
|
|
|
});
|
|
|
|
|
|
@@ -285,7 +192,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a : b.\n',
|
|
|
+ 'a $ b.\n',
|
|
|
'should try to serialize a directive (text) w/o `name`',
|
|
|
);
|
|
|
|
|
|
@@ -302,7 +209,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b c.\n',
|
|
|
+ 'a $b c.\n',
|
|
|
'should serialize a directive (text) w/ `name`',
|
|
|
);
|
|
|
|
|
|
@@ -322,7 +229,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b[c] d.\n',
|
|
|
+ 'a $b[c] d.\n',
|
|
|
'should serialize a directive (text) w/ `children`',
|
|
|
);
|
|
|
|
|
|
@@ -342,7 +249,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b[c\\[d\\]e] f.\n',
|
|
|
+ 'a $b[c\\[d\\]e] f.\n',
|
|
|
'should escape brackets in a directive (text) label',
|
|
|
);
|
|
|
|
|
|
@@ -362,7 +269,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b[c\nd] e.\n',
|
|
|
+ 'a $b[c\nd] e.\n',
|
|
|
'should support EOLs in a directive (text) label',
|
|
|
);
|
|
|
|
|
|
@@ -386,7 +293,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{c="d" e="f" g j="2"} k.\n',
|
|
|
+ 'a $b{c="d" e="f" g j="2"} k.\n',
|
|
|
'should serialize a directive (text) w/ `attributes`',
|
|
|
);
|
|
|
|
|
|
@@ -407,7 +314,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{#d .a.b.c key="value"} k.\n',
|
|
|
+ 'a $b{#d .a.b.c key="value"} k.\n',
|
|
|
'should serialize a directive (text) w/ `id`, `class` attributes',
|
|
|
);
|
|
|
|
|
|
@@ -428,7 +335,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{x="y"\'\r\nz"} k.\n',
|
|
|
+ 'a $b{x="y"\'\r\nz"} k.\n',
|
|
|
'should encode the quote in an attribute value (text)',
|
|
|
);
|
|
|
|
|
|
@@ -449,7 +356,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{x="y"\'\r\nz"} k.\n',
|
|
|
+ 'a $b{x="y"\'\r\nz"} k.\n',
|
|
|
'should encode the quote in an attribute value (text)',
|
|
|
);
|
|
|
|
|
|
@@ -470,7 +377,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{id="c#d"} e.\n',
|
|
|
+ 'a $b{id="c#d"} e.\n',
|
|
|
'should not use the `id` shortcut if impossible characters exist',
|
|
|
);
|
|
|
|
|
|
@@ -491,7 +398,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{class="c.d e<f"} g.\n',
|
|
|
+ 'a $b{class="c.d e<f"} g.\n',
|
|
|
'should not use the `class` shortcut if impossible characters exist',
|
|
|
);
|
|
|
|
|
|
@@ -512,14 +419,14 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a :b{.e.hij class="c.d f<g"} k.\n',
|
|
|
+ 'a $b{.e.hij class="c.d f<g"} k.\n',
|
|
|
'should not use the `class` shortcut if impossible characters exist (but should use it for classes that don’t)',
|
|
|
);
|
|
|
|
|
|
t.deepEqual(
|
|
|
// @ts-expect-error: `children`, `name` missing.
|
|
|
toMarkdown({ type: 'leafGrowiPluginDirective' }, { extensions: [directiveToMarkdown] }),
|
|
|
- '::\n',
|
|
|
+ '$\n',
|
|
|
'should try to serialize a directive (leaf) w/o `name`',
|
|
|
);
|
|
|
|
|
|
@@ -529,7 +436,7 @@ test('mdast -> markdown', (t) => {
|
|
|
{ type: 'leafGrowiPluginDirective', name: 'a' },
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '::a\n',
|
|
|
+ '$a\n',
|
|
|
'should serialize a directive (leaf) w/ `name`',
|
|
|
);
|
|
|
|
|
|
@@ -542,7 +449,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '::a[b]\n',
|
|
|
+ '$a[b]\n',
|
|
|
'should serialize a directive (leaf) w/ `children`',
|
|
|
);
|
|
|
|
|
|
@@ -555,7 +462,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '::a[b]\n',
|
|
|
+ '$a[b]\n',
|
|
|
'should serialize a directive (leaf) w/ `children`',
|
|
|
);
|
|
|
|
|
|
@@ -568,7 +475,7 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '::a[b
c]\n',
|
|
|
+ '$a[b
c]\n',
|
|
|
'should serialize a directive (leaf) w/ EOLs in `children`',
|
|
|
);
|
|
|
|
|
|
@@ -582,232 +489,19 @@ test('mdast -> markdown', (t) => {
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '::a{#b .c.d key="e
f"}\n',
|
|
|
+ '$a{#b .c.d key="e
f"}\n',
|
|
|
'should serialize a directive (leaf) w/ EOLs in `attributes`',
|
|
|
);
|
|
|
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- // @ts-expect-error: `children`, `name` missing.
|
|
|
- { type: 'containerGrowiPluginDirective' },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::\n:::\n',
|
|
|
- 'should try to serialize a directive (container) w/o `name`',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- // @ts-expect-error: `children` missing.
|
|
|
- { type: 'containerGrowiPluginDirective', name: 'a' },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::a\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ `name`',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [{ type: 'paragraph', children: [{ type: 'text', value: 'b' }] }],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::a\nb\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ `children`',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- { type: 'heading', depth: 1, children: [{ type: 'text', value: 'b' }] },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::a\n# b\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ `children` (heading)',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- { type: 'paragraph', children: [{ type: 'text', value: 'b\nc' }] },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::a\nb\nc\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ EOLs in `children`',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- attributes: { id: 'b', class: 'c d', key: 'e\nf' },
|
|
|
- children: [],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::a{#b .c.d key="e
f"}\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ EOLs in `attributes`',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- data: { directiveLabel: true },
|
|
|
- children: [{ type: 'text', value: 'b' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::a[b]\n:::\n',
|
|
|
- 'should serialize the first paragraph w/ `data.directiveLabel` as a label in a directive (container)',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'b',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'c' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- '::::a\n:::b\nc\n:::\n::::\n',
|
|
|
- 'should serialize the outer containers w/ more colons than inner containers',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'b',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'c' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'd',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'e' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- '::::a\n:::b\nc\n:::\n\n:::d\ne\n:::\n::::\n',
|
|
|
- 'should serialize w/ `3 + nesting`, not the total count (1)',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'b',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'c',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'd' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- ':::::a\n::::b\n:::c\nd\n:::\n::::\n:::::\n',
|
|
|
- 'should serialize w/ `3 + nesting`, not the total count (2)',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'a',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'blockquote',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'containerGrowiPluginDirective',
|
|
|
- name: 'b',
|
|
|
- children: [
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'c' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- '::::a\n> :::b\n> c\n> :::\n::::\n',
|
|
|
- 'should serialize w/ `3 + nesting`, not the total count (3)',
|
|
|
- );
|
|
|
-
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'a:b' }],
|
|
|
+ children: [{ type: 'text', value: 'a$b' }],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a\\:b\n',
|
|
|
+ 'a\\$b\n',
|
|
|
'should escape a `:` in phrasing when followed by an alpha',
|
|
|
);
|
|
|
|
|
|
@@ -815,11 +509,11 @@ test('mdast -> markdown', (t) => {
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'a:9' }],
|
|
|
+ children: [{ type: 'text', value: 'a$9' }],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a:9\n',
|
|
|
+ 'a$9\n',
|
|
|
'should not escape a `:` in phrasing when followed by a non-alpha',
|
|
|
);
|
|
|
|
|
|
@@ -827,11 +521,11 @@ test('mdast -> markdown', (t) => {
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: 'a::c' }],
|
|
|
+ children: [{ type: 'text', value: 'a$c' }],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- 'a::c\n',
|
|
|
+ 'a\\$c\n',
|
|
|
'should not escape a `:` in phrasing when preceded by a colon',
|
|
|
);
|
|
|
|
|
|
@@ -839,11 +533,11 @@ test('mdast -> markdown', (t) => {
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: ':\na' }],
|
|
|
+ children: [{ type: 'text', value: '$\na' }],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- ':\na\n',
|
|
|
+ '$\na\n',
|
|
|
'should not escape a `:` at a break',
|
|
|
);
|
|
|
|
|
|
@@ -851,11 +545,11 @@ test('mdast -> markdown', (t) => {
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: ':a' }],
|
|
|
+ children: [{ type: 'text', value: '$a' }],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '\\:a\n',
|
|
|
+ '\\$a\n',
|
|
|
'should not escape a `:` at a break when followed by an alpha',
|
|
|
);
|
|
|
|
|
|
@@ -863,50 +557,26 @@ test('mdast -> markdown', (t) => {
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: '::\na' }],
|
|
|
+ children: [{ type: 'text', value: '$\na' }],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- '\\::\na\n',
|
|
|
+ '$\na\n',
|
|
|
'should escape a `:` at a break when followed by a colon',
|
|
|
);
|
|
|
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: ':::\na' }],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- '\\:::\na\n',
|
|
|
- 'should escape a `:` at a break when followed by two colons',
|
|
|
- );
|
|
|
-
|
|
|
- t.deepEqual(
|
|
|
- toMarkdown(
|
|
|
- {
|
|
|
- type: 'paragraph',
|
|
|
- children: [{ type: 'text', value: ':::\na' }],
|
|
|
- },
|
|
|
- { extensions: [directiveToMarkdown] },
|
|
|
- ),
|
|
|
- '\\:::\na\n',
|
|
|
- 'should escape a `:` at a break when followed by two colons',
|
|
|
- );
|
|
|
-
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
{ type: 'textGrowiPluginDirective', name: 'red', children: [] },
|
|
|
- { type: 'text', value: ':' },
|
|
|
+ { type: 'text', value: '$' },
|
|
|
],
|
|
|
},
|
|
|
{ extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
- ':red:\n',
|
|
|
+ '$red$\n',
|
|
|
'should escape a `:` after a text directive',
|
|
|
);
|
|
|
|