|
|
@@ -1,15 +1,16 @@
|
|
|
-import test from 'tape'
|
|
|
-import {fromMarkdown} from 'mdast-util-from-markdown'
|
|
|
-import {toMarkdown} from 'mdast-util-to-markdown'
|
|
|
-import {removePosition} from 'unist-util-remove-position'
|
|
|
-import {directive} from 'micromark-extension-directive'
|
|
|
-import {directiveFromMarkdown, directiveToMarkdown} from './index.js'
|
|
|
+import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
|
+import { toMarkdown } from 'mdast-util-to-markdown';
|
|
|
+import { directive } from 'micromark-extension-directive';
|
|
|
+import test from 'tape';
|
|
|
+import { removePosition } from 'unist-util-remove-position';
|
|
|
+
|
|
|
+import { directiveFromMarkdown, directiveToMarkdown } from './index.js';
|
|
|
|
|
|
test('markdown -> mdast', (t) => {
|
|
|
t.deepEqual(
|
|
|
fromMarkdown('a :b[c]{d} e.', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}).children[0],
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
@@ -18,100 +19,100 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'text',
|
|
|
value: 'a ',
|
|
|
position: {
|
|
|
- start: {line: 1, column: 1, offset: 0},
|
|
|
- end: {line: 1, column: 3, offset: 2}
|
|
|
- }
|
|
|
+ start: { line: 1, column: 1, offset: 0 },
|
|
|
+ end: { line: 1, column: 3, offset: 2 },
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {d: ''},
|
|
|
+ attributes: { d: '' },
|
|
|
children: [
|
|
|
{
|
|
|
type: 'text',
|
|
|
value: 'c',
|
|
|
position: {
|
|
|
- start: {line: 1, column: 6, offset: 5},
|
|
|
- end: {line: 1, column: 7, offset: 6}
|
|
|
- }
|
|
|
- }
|
|
|
+ start: { line: 1, column: 6, offset: 5 },
|
|
|
+ end: { line: 1, column: 7, offset: 6 },
|
|
|
+ },
|
|
|
+ },
|
|
|
],
|
|
|
position: {
|
|
|
- start: {line: 1, column: 3, offset: 2},
|
|
|
- end: {line: 1, column: 11, offset: 10}
|
|
|
- }
|
|
|
+ start: { line: 1, column: 3, offset: 2 },
|
|
|
+ end: { line: 1, column: 11, offset: 10 },
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
type: 'text',
|
|
|
value: ' e.',
|
|
|
position: {
|
|
|
- start: {line: 1, column: 11, offset: 10},
|
|
|
- end: {line: 1, column: 14, offset: 13}
|
|
|
- }
|
|
|
- }
|
|
|
+ start: { line: 1, column: 11, offset: 10 },
|
|
|
+ end: { line: 1, column: 14, offset: 13 },
|
|
|
+ },
|
|
|
+ },
|
|
|
],
|
|
|
position: {
|
|
|
- start: {line: 1, column: 1, offset: 0},
|
|
|
- end: {line: 1, column: 14, offset: 13}
|
|
|
- }
|
|
|
+ start: { line: 1, column: 1, offset: 0 },
|
|
|
+ end: { line: 1, column: 14, offset: 13 },
|
|
|
+ },
|
|
|
},
|
|
|
- 'should support directives (text)'
|
|
|
- )
|
|
|
+ 'should support directives (text)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
fromMarkdown('::a[b]{c}', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}).children[0],
|
|
|
{
|
|
|
- type: 'leafDirective',
|
|
|
+ type: 'leafGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- attributes: {c: ''},
|
|
|
+ attributes: { c: '' },
|
|
|
children: [
|
|
|
{
|
|
|
type: 'text',
|
|
|
value: 'b',
|
|
|
position: {
|
|
|
- start: {line: 1, column: 5, offset: 4},
|
|
|
- end: {line: 1, column: 6, offset: 5}
|
|
|
- }
|
|
|
- }
|
|
|
+ start: { line: 1, column: 5, offset: 4 },
|
|
|
+ end: { line: 1, column: 6, offset: 5 },
|
|
|
+ },
|
|
|
+ },
|
|
|
],
|
|
|
position: {
|
|
|
- start: {line: 1, column: 1, offset: 0},
|
|
|
- end: {line: 1, column: 10, offset: 9}
|
|
|
- }
|
|
|
+ start: { line: 1, column: 1, offset: 0 },
|
|
|
+ end: { line: 1, column: 10, offset: 9 },
|
|
|
+ },
|
|
|
},
|
|
|
- 'should support directives (leaf)'
|
|
|
- )
|
|
|
+ 'should support directives (leaf)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
fromMarkdown(':::a[b]{c}\nd', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}).children[0],
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- attributes: {c: ''},
|
|
|
+ attributes: { c: '' },
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- data: {directiveLabel: true},
|
|
|
+ data: { directiveLabel: true },
|
|
|
children: [
|
|
|
{
|
|
|
type: 'text',
|
|
|
value: 'b',
|
|
|
position: {
|
|
|
- start: {line: 1, column: 6, offset: 5},
|
|
|
- end: {line: 1, column: 7, offset: 6}
|
|
|
- }
|
|
|
- }
|
|
|
+ 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}
|
|
|
- }
|
|
|
+ start: { line: 1, column: 5, offset: 4 },
|
|
|
+ end: { line: 1, column: 8, offset: 7 },
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
@@ -120,32 +121,32 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'text',
|
|
|
value: 'd',
|
|
|
position: {
|
|
|
- start: {line: 2, column: 1, offset: 11},
|
|
|
- end: {line: 2, column: 2, offset: 12}
|
|
|
- }
|
|
|
- }
|
|
|
+ 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}
|
|
|
- }
|
|
|
- }
|
|
|
+ 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}
|
|
|
- }
|
|
|
+ start: { line: 1, column: 1, offset: 0 },
|
|
|
+ end: { line: 2, column: 2, offset: 12 },
|
|
|
+ },
|
|
|
},
|
|
|
- 'should support directives (container)'
|
|
|
- )
|
|
|
+ 'should support directives (container)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
fromMarkdown(':a[b *c*\nd]', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
- true
|
|
|
+ true,
|
|
|
),
|
|
|
{
|
|
|
type: 'root',
|
|
|
@@ -154,29 +155,29 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
attributes: {},
|
|
|
children: [
|
|
|
- {type: 'text', value: 'b '},
|
|
|
- {type: 'emphasis', children: [{type: 'text', value: 'c'}]},
|
|
|
- {type: 'text', value: '\nd'}
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ { type: 'text', value: 'b ' },
|
|
|
+ { type: 'emphasis', children: [{ type: 'text', value: 'c' }] },
|
|
|
+ { type: 'text', value: '\nd' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- 'should support content in a label'
|
|
|
- )
|
|
|
+ 'should support content in a label',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
fromMarkdown(':a{#b.c.d e=f g="h&i&unknown;j"}', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
- true
|
|
|
+ true,
|
|
|
),
|
|
|
{
|
|
|
type: 'root',
|
|
|
@@ -185,25 +186,27 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- attributes: {id: 'b', class: 'c d', e: 'f', g: 'h&i&unknown;j'},
|
|
|
- children: []
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ attributes: {
|
|
|
+ id: 'b', class: 'c d', e: 'f', g: 'h&i&unknown;j',
|
|
|
+ },
|
|
|
+ children: [],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- 'should support attributes'
|
|
|
- )
|
|
|
+ 'should support attributes',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
fromMarkdown(':a{b\nc="d\ne"}', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
- true
|
|
|
+ true,
|
|
|
),
|
|
|
{
|
|
|
type: 'root',
|
|
|
@@ -212,36 +215,36 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- attributes: {b: '', c: 'd\ne'},
|
|
|
- children: []
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ attributes: { b: '', c: 'd\ne' },
|
|
|
+ children: [],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- 'should support EOLs in attributes'
|
|
|
- )
|
|
|
+ 'should support EOLs in attributes',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
removePosition(
|
|
|
fromMarkdown('::::a\n:::b\n:c\n:::\n::::', {
|
|
|
extensions: [directive()],
|
|
|
- mdastExtensions: [directiveFromMarkdown]
|
|
|
+ mdastExtensions: [directiveFromMarkdown],
|
|
|
}),
|
|
|
- true
|
|
|
+ true,
|
|
|
),
|
|
|
{
|
|
|
type: 'root',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
attributes: {},
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
attributes: {},
|
|
|
children: [
|
|
|
@@ -249,24 +252,24 @@ test('markdown -> mdast', (t) => {
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'c',
|
|
|
attributes: {},
|
|
|
- children: []
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ children: [],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- 'should support directives in directives'
|
|
|
- )
|
|
|
+ 'should support directives in directives',
|
|
|
+ );
|
|
|
|
|
|
- t.end()
|
|
|
-})
|
|
|
+ t.end();
|
|
|
+});
|
|
|
|
|
|
test('mdast -> markdown', (t) => {
|
|
|
t.deepEqual(
|
|
|
@@ -274,636 +277,638 @@ test('mdast -> markdown', (t) => {
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
// @ts-expect-error: `children`, `name` missing.
|
|
|
- {type: 'textDirective'},
|
|
|
- {type: 'text', value: ' b.'}
|
|
|
- ]
|
|
|
+ { type: 'textGrowiPluginDirective' },
|
|
|
+ { type: 'text', value: ' b.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a : b.\n',
|
|
|
- 'should try to serialize a directive (text) w/o `name`'
|
|
|
- )
|
|
|
+ 'should try to serialize a directive (text) w/o `name`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
// @ts-expect-error: `children` missing.
|
|
|
- {type: 'textDirective', name: 'b'},
|
|
|
- {type: 'text', value: ' c.'}
|
|
|
- ]
|
|
|
+ { type: 'textGrowiPluginDirective', name: 'b' },
|
|
|
+ { type: 'text', value: ' c.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b c.\n',
|
|
|
- 'should serialize a directive (text) w/ `name`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (text) w/ `name`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- children: [{type: 'text', value: 'c'}]
|
|
|
+ children: [{ type: 'text', value: 'c' }],
|
|
|
},
|
|
|
- {type: 'text', value: ' d.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' d.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b[c] d.\n',
|
|
|
- 'should serialize a directive (text) w/ `children`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (text) w/ `children`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- children: [{type: 'text', value: 'c[d]e'}]
|
|
|
+ children: [{ type: 'text', value: 'c[d]e' }],
|
|
|
},
|
|
|
- {type: 'text', value: ' f.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' f.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b[c\\[d\\]e] f.\n',
|
|
|
- 'should escape brackets in a directive (text) label'
|
|
|
- )
|
|
|
+ 'should escape brackets in a directive (text) label',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- children: [{type: 'text', value: 'c\nd'}]
|
|
|
+ children: [{ type: 'text', value: 'c\nd' }],
|
|
|
},
|
|
|
- {type: 'text', value: ' e.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' e.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b[c\nd] e.\n',
|
|
|
- 'should support EOLs in a directive (text) label'
|
|
|
- )
|
|
|
+ 'should support EOLs in a directive (text) label',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
// @ts-expect-error: should contain only `string`s
|
|
|
- attributes: {c: 'd', e: 'f', g: '', h: null, i: undefined, j: 2},
|
|
|
- children: []
|
|
|
+ attributes: {
|
|
|
+ c: 'd', e: 'f', g: '', h: null, i: undefined, j: 2,
|
|
|
+ },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' k.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' k.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b{c="d" e="f" g j="2"} k.\n',
|
|
|
- 'should serialize a directive (text) w/ `attributes`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (text) w/ `attributes`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {class: 'a b\nc', id: 'd', key: 'value'},
|
|
|
- children: []
|
|
|
+ attributes: { class: 'a b\nc', id: 'd', key: 'value' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' k.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' k.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b{#d .a.b.c key="value"} k.\n',
|
|
|
- 'should serialize a directive (text) w/ `id`, `class` attributes'
|
|
|
- )
|
|
|
+ 'should serialize a directive (text) w/ `id`, `class` attributes',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {x: 'y"\'\r\nz'},
|
|
|
- children: []
|
|
|
+ attributes: { x: 'y"\'\r\nz' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' k.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' k.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b{x="y"\'\r\nz"} k.\n',
|
|
|
- 'should encode the quote in an attribute value (text)'
|
|
|
- )
|
|
|
+ 'should encode the quote in an attribute value (text)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {x: 'y"\'\r\nz'},
|
|
|
- children: []
|
|
|
+ attributes: { x: 'y"\'\r\nz' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' k.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' k.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b{x="y"\'\r\nz"} k.\n',
|
|
|
- 'should encode the quote in an attribute value (text)'
|
|
|
- )
|
|
|
+ 'should encode the quote in an attribute value (text)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {id: 'c#d'},
|
|
|
- children: []
|
|
|
+ attributes: { id: 'c#d' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' e.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' e.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b{id="c#d"} e.\n',
|
|
|
- 'should not use the `id` shortcut if impossible characters exist'
|
|
|
- )
|
|
|
+ 'should not use the `id` shortcut if impossible characters exist',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {class: 'c.d e<f'},
|
|
|
- children: []
|
|
|
+ attributes: { class: 'c.d e<f' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' g.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' g.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a :b{class="c.d e<f"} g.\n',
|
|
|
- 'should not use the `class` shortcut if impossible characters exist'
|
|
|
- )
|
|
|
+ 'should not use the `class` shortcut if impossible characters exist',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'text', value: 'a '},
|
|
|
+ { type: 'text', value: 'a ' },
|
|
|
{
|
|
|
- type: 'textDirective',
|
|
|
+ type: 'textGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
- attributes: {class: 'c.d e f<g hij'},
|
|
|
- children: []
|
|
|
+ attributes: { class: 'c.d e f<g hij' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {type: 'text', value: ' k.'}
|
|
|
- ]
|
|
|
+ { type: 'text', value: ' k.' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'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)'
|
|
|
- )
|
|
|
+ '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: 'leafDirective'}, {extensions: [directiveToMarkdown]}),
|
|
|
+ toMarkdown({ type: 'leafGrowiPluginDirective' }, { extensions: [directiveToMarkdown] }),
|
|
|
'::\n',
|
|
|
- 'should try to serialize a directive (leaf) w/o `name`'
|
|
|
- )
|
|
|
+ 'should try to serialize a directive (leaf) w/o `name`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
// @ts-expect-error: `children` missing.
|
|
|
- {type: 'leafDirective', name: 'a'},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { type: 'leafGrowiPluginDirective', name: 'a' },
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::a\n',
|
|
|
- 'should serialize a directive (leaf) w/ `name`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (leaf) w/ `name`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'leafDirective',
|
|
|
+ type: 'leafGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- children: [{type: 'text', value: 'b'}]
|
|
|
+ children: [{ type: 'text', value: 'b' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::a[b]\n',
|
|
|
- 'should serialize a directive (leaf) w/ `children`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (leaf) w/ `children`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'leafDirective',
|
|
|
+ type: 'leafGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- children: [{type: 'text', value: 'b'}]
|
|
|
+ children: [{ type: 'text', value: 'b' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::a[b]\n',
|
|
|
- 'should serialize a directive (leaf) w/ `children`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (leaf) w/ `children`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'leafDirective',
|
|
|
+ type: 'leafGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- children: [{type: 'text', value: 'b\nc'}]
|
|
|
+ children: [{ type: 'text', value: 'b\nc' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::a[b
c]\n',
|
|
|
- 'should serialize a directive (leaf) w/ EOLs in `children`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (leaf) w/ EOLs in `children`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'leafDirective',
|
|
|
+ type: 'leafGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- attributes: {id: 'b', class: 'c d', key: 'e\nf'},
|
|
|
- children: []
|
|
|
+ attributes: { id: 'b', class: 'c d', key: 'e\nf' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::a{#b .c.d key="e
f"}\n',
|
|
|
- 'should serialize a directive (leaf) w/ EOLs in `attributes`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (leaf) w/ EOLs in `attributes`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
// @ts-expect-error: `children`, `name` missing.
|
|
|
- {type: 'containerDirective'},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { type: 'containerGrowiPluginDirective' },
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::\n:::\n',
|
|
|
- 'should try to serialize a directive (container) w/o `name`'
|
|
|
- )
|
|
|
+ 'should try to serialize a directive (container) w/o `name`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
// @ts-expect-error: `children` missing.
|
|
|
- {type: 'containerDirective', name: 'a'},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { type: 'containerGrowiPluginDirective', name: 'a' },
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::a\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ `name`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (container) w/ `name`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- children: [{type: 'paragraph', children: [{type: 'text', value: 'b'}]}]
|
|
|
+ children: [{ type: 'paragraph', children: [{ type: 'text', value: 'b' }] }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::a\nb\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ `children`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (container) w/ `children`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
- {type: 'heading', depth: 1, children: [{type: 'text', value: 'b'}]}
|
|
|
- ]
|
|
|
+ { type: 'heading', depth: 1, children: [{ type: 'text', value: 'b' }] },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::a\n# b\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ `children` (heading)'
|
|
|
- )
|
|
|
+ 'should serialize a directive (container) w/ `children` (heading)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
- {type: 'paragraph', children: [{type: 'text', value: 'b\nc'}]}
|
|
|
- ]
|
|
|
+ { type: 'paragraph', children: [{ type: 'text', value: 'b\nc' }] },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::a\nb\nc\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ EOLs in `children`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (container) w/ EOLs in `children`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
- attributes: {id: 'b', class: 'c d', key: 'e\nf'},
|
|
|
- children: []
|
|
|
+ attributes: { id: 'b', class: 'c d', key: 'e\nf' },
|
|
|
+ children: [],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::a{#b .c.d key="e
f"}\n:::\n',
|
|
|
- 'should serialize a directive (container) w/ EOLs in `attributes`'
|
|
|
- )
|
|
|
+ 'should serialize a directive (container) w/ EOLs in `attributes`',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- data: {directiveLabel: true},
|
|
|
- children: [{type: 'text', value: 'b'}]
|
|
|
- }
|
|
|
- ]
|
|
|
+ data: { directiveLabel: true },
|
|
|
+ children: [{ type: 'text', value: 'b' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::a[b]\n:::\n',
|
|
|
- 'should serialize the first paragraph w/ `data.directiveLabel` as a label in a directive (container)'
|
|
|
- )
|
|
|
+ 'should serialize the first paragraph w/ `data.directiveLabel` as a label in a directive (container)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'c'}]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ children: [{ type: 'text', value: 'c' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::::a\n:::b\nc\n:::\n::::\n',
|
|
|
- 'should serialize the outer containers w/ more colons than inner containers'
|
|
|
- )
|
|
|
+ 'should serialize the outer containers w/ more colons than inner containers',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'c'}]
|
|
|
- }
|
|
|
- ]
|
|
|
+ children: [{ type: 'text', value: 'c' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'd',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'e'}]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ children: [{ type: 'text', value: 'e' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::::a\n:::b\nc\n:::\n\n:::d\ne\n:::\n::::\n',
|
|
|
- 'should serialize w/ `3 + nesting`, not the total count (1)'
|
|
|
- )
|
|
|
+ 'should serialize w/ `3 + nesting`, not the total count (1)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'c',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'd'}]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ children: [{ type: 'text', value: 'd' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':::::a\n::::b\n:::c\nd\n:::\n::::\n:::::\n',
|
|
|
- 'should serialize w/ `3 + nesting`, not the total count (2)'
|
|
|
- )
|
|
|
+ 'should serialize w/ `3 + nesting`, not the total count (2)',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'a',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'blockquote',
|
|
|
children: [
|
|
|
{
|
|
|
- type: 'containerDirective',
|
|
|
+ type: 'containerGrowiPluginDirective',
|
|
|
name: 'b',
|
|
|
children: [
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'c'}]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ children: [{ type: 'text', value: 'c' }],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'::::a\n> :::b\n> c\n> :::\n::::\n',
|
|
|
- 'should serialize w/ `3 + nesting`, not the total count (3)'
|
|
|
- )
|
|
|
+ '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]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a\\:b\n',
|
|
|
- 'should escape a `:` in phrasing when followed by an alpha'
|
|
|
- )
|
|
|
+ 'should escape a `:` in phrasing when followed by an alpha',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'a:9'}]
|
|
|
+ children: [{ type: 'text', value: 'a:9' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a:9\n',
|
|
|
- 'should not escape a `:` in phrasing when followed by a non-alpha'
|
|
|
- )
|
|
|
+ 'should not escape a `:` in phrasing when followed by a non-alpha',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: 'a::c'}]
|
|
|
+ children: [{ type: 'text', value: 'a::c' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'a::c\n',
|
|
|
- 'should not escape a `:` in phrasing when preceded by a colon'
|
|
|
- )
|
|
|
+ 'should not escape a `:` in phrasing when preceded by a colon',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: ':\na'}]
|
|
|
+ children: [{ type: 'text', value: ':\na' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':\na\n',
|
|
|
- 'should not escape a `:` at a break'
|
|
|
- )
|
|
|
+ 'should not escape a `:` at a break',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: ':a'}]
|
|
|
+ children: [{ type: 'text', value: ':a' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'\\:a\n',
|
|
|
- 'should not escape a `:` at a break when followed by an alpha'
|
|
|
- )
|
|
|
+ 'should not escape a `:` at a break when followed by an alpha',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: '::\na'}]
|
|
|
+ children: [{ type: 'text', value: '::\na' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'\\::\na\n',
|
|
|
- 'should escape a `:` at a break when followed by a colon'
|
|
|
- )
|
|
|
+ 'should escape a `:` at a break when followed by a colon',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: ':::\na'}]
|
|
|
+ children: [{ type: 'text', value: ':::\na' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'\\:::\na\n',
|
|
|
- 'should escape a `:` at a break when followed by two colons'
|
|
|
- )
|
|
|
+ 'should escape a `:` at a break when followed by two colons',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
- children: [{type: 'text', value: ':::\na'}]
|
|
|
+ children: [{ type: 'text', value: ':::\na' }],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
'\\:::\na\n',
|
|
|
- 'should escape a `:` at a break when followed by two colons'
|
|
|
- )
|
|
|
+ 'should escape a `:` at a break when followed by two colons',
|
|
|
+ );
|
|
|
|
|
|
t.deepEqual(
|
|
|
toMarkdown(
|
|
|
{
|
|
|
type: 'paragraph',
|
|
|
children: [
|
|
|
- {type: 'textDirective', name: 'red', children: []},
|
|
|
- {type: 'text', value: ':'}
|
|
|
- ]
|
|
|
+ { type: 'textGrowiPluginDirective', name: 'red', children: [] },
|
|
|
+ { type: 'text', value: ':' },
|
|
|
+ ],
|
|
|
},
|
|
|
- {extensions: [directiveToMarkdown]}
|
|
|
+ { extensions: [directiveToMarkdown] },
|
|
|
),
|
|
|
':red:\n',
|
|
|
- 'should escape a `:` after a text directive'
|
|
|
- )
|
|
|
+ 'should escape a `:` after a text directive',
|
|
|
+ );
|
|
|
|
|
|
- t.end()
|
|
|
-})
|
|
|
+ t.end();
|
|
|
+});
|