diff --git a/test/index.js b/test/index.js deleted file mode 100644 index 9886878..0000000 --- a/test/index.js +++ /dev/null @@ -1,1772 +0,0 @@ -/** - * @import {Handle, HtmlOptions} from 'micromark-extension-directive' - * @import {CompileContext} from 'micromark-util-types' - */ - -import assert from 'node:assert/strict' -import test from 'node:test' -import {micromark} from 'micromark' -import {htmlVoidElements} from 'html-void-elements' -import {directive, directiveHtml} from 'micromark-extension-directive' - -const own = {}.hasOwnProperty - -test('micromark-extension-directive (core)', async function (t) { - await t.test('should expose the public api', async function () { - assert.deepEqual( - Object.keys(await import('micromark-extension-directive')).sort(), - ['directive', 'directiveHtml'] - ) - }) -}) - -test('micromark-extension-directive (syntax, text)', async function (t) { - await t.test( - 'should support an escaped colon which would otherwise be a directive', - async function () { - assert.equal(micromark('\\:a', options()), '
:a
') - } - ) - - await t.test( - 'should support a directive after an escaped colon', - async function () { - assert.equal(micromark('\\::a', options()), ':
') - } - ) - - await t.test( - 'should not support a directive after a colon', - async function () { - assert.equal(micromark('a ::b', options()), 'a ::b
') - } - ) - - await t.test( - 'should not support a colon not followed by an alpha', - async function () { - assert.equal(micromark(':', options()), ':
') - } - ) - - await t.test( - 'should support a colon followed by an alpha', - async function () { - assert.equal(micromark(':a', options()), '') - } - ) - - await t.test( - 'should not support a colon followed by a digit', - async function () { - assert.equal(micromark(':9', options()), ':9
') - } - ) - - await t.test( - 'should not support a colon followed by a dash', - async function () { - assert.equal(micromark(':-', options()), ':-
') - } - ) - - await t.test( - 'should not support a colon followed by an underscore', - async function () { - assert.equal(micromark(':_', options()), ':_
') - } - ) - - await t.test('should support a digit in a name', async function () { - assert.equal(micromark(':a9', options()), '') - }) - - await t.test('should support a dash in a name', async function () { - assert.equal(micromark(':a-b', options()), '') - }) - - await t.test( - 'should *not* support a dash at the end of a name', - async function () { - assert.equal(micromark(':a-', options()), ':a-
') - } - ) - - await t.test('should support an underscore in a name', async function () { - assert.equal(micromark(':a_b', options()), '') - }) - - await t.test( - 'should *not* support an underscore at the end of a name', - async function () { - assert.equal(micromark(':a_', options()), ':a_
') - } - ) - - await t.test( - 'should *not* support a colon right after a name', - async function () { - assert.equal(micromark(':a:', options()), ':a:
') - } - ) - - await t.test('should not interfere w/ gemoji (1)', async function () { - assert.equal(micromark(':+1:', options()), ':+1:
') - }) - - await t.test('should not interfere w/ gemoji (2)', async function () { - assert.equal(micromark(':heart:', options()), ':heart:
') - }) - - await t.test('should not interfere w/ gemoji (3)', async function () { - assert.equal( - micromark(':call_me_hand:', options()), - ':call_me_hand:
' - ) - }) - - await t.test('should not interfere w/ emphasis (`_`)', async function () { - assert.equal( - micromark('_:directive_', options()), - ':directive
' - ) - }) - - await t.test( - 'should support a name followed by an unclosed `[`', - async function () { - assert.equal(micromark(':a[', options()), '[
') - } - ) - - await t.test( - 'should support a name followed by an unclosed `{`', - async function () { - assert.equal(micromark(':a{', options()), '{
') - } - ) - - await t.test( - 'should support a name followed by an unclosed `[` w/ content', - async function () { - assert.equal(micromark(':a[b', options()), '[b
') - } - ) - - await t.test( - 'should support a name followed by an unclosed `{` w/ content', - async function () { - assert.equal(micromark(':a{b', options()), '{b
') - } - ) - - await t.test('should support an empty label', async function () { - assert.equal(micromark(':a[]', options()), '') - }) - - await t.test('should support a whitespace only label', async function () { - assert.equal(micromark(':a[ \t]', options()), '') - }) - - await t.test('should support an eol in an label', async function () { - assert.equal(micromark(':a[\n]', options()), '') - }) - - await t.test('should support content in an label', async function () { - assert.equal(micromark(':a[a b c]asd', options()), 'asd
') - }) - - await t.test('should support markdown in an label', async function () { - assert.equal(micromark(':a[a *b* c]asd', options()), 'asd
') - }) - - await t.test( - 'should support markdown in an label (hard break)', - async function () { - assert.equal( - micromark(':x[a \nb]c', options({'*': h})), - '
\nb
a g
') - }) - - await t.test('should support content after a label', async function () { - assert.equal(micromark(':a[]asd', options()), 'asd
') - }) - - await t.test('should support empty attributes', async function () { - assert.equal(micromark(':a{}', options()), '') - }) - - await t.test('should support whitespace only attributes', async function () { - assert.equal(micromark(':a{ \t}', options()), '') - }) - - await t.test('should support an eol in attributes', async function () { - assert.equal(micromark(':a{\n}', options()), '') - }) - - await t.test('should support attributes w/o values', async function () { - assert.equal(micromark(':a{a b c}', options()), '') - }) - - await t.test( - 'should support attributes w/ unquoted values', - async function () { - assert.equal(micromark(':a{a=b c=d}', options()), '') - } - ) - - await t.test( - 'should support attributes w/ class shortcut', - async function () { - assert.equal(micromark(':a{.a .b}', options()), '') - } - ) - - await t.test( - 'should support attributes w/ class shortcut w/o whitespace between', - async function () { - assert.equal(micromark(':a{.a.b}', options()), '') - } - ) - - await t.test('should support attributes w/ id shortcut', async function () { - assert.equal(micromark(':a{#a #b}', options()), '') - }) - - await t.test( - 'should support attributes w/ id shortcut w/o whitespace between', - async function () { - assert.equal(micromark(':a{#a#b}', options()), '') - } - ) - - await t.test( - 'should support attributes w/ shortcuts combined w/ other attributes', - async function () { - assert.equal(micromark(':a{#a.b.c#d e f=g #h.i.j}', options()), '') - } - ) - - await t.test('should not support an empty shortcut (`.`)', async function () { - assert.equal(micromark(':a{..b}', options()), '{..b}
') - }) - - await t.test('should not support an empty shortcut (`#`)', async function () { - assert.equal(micromark(':a{.#b}', options()), '{.#b}
') - }) - - await t.test('should not support an empty shortcut (`}`)', async function () { - assert.equal(micromark(':a{.}', options()), '{.}
') - }) - - await t.test( - 'should not support certain characters in shortcuts (`=`)', - async function () { - assert.equal(micromark(':a{.a=b}', options()), '{.a=b}
') - } - ) - - await t.test( - 'should not support certain characters in shortcuts (`"`)', - async function () { - assert.equal(micromark(':a{.a"b}', options()), '{.a"b}
') - } - ) - - await t.test( - 'should not support certain characters in shortcuts (`<`)', - async function () { - assert.equal(micromark(':a{.a{.a<b}') - } - ) - - await t.test( - 'should support most characters in shortcuts', - async function () { - assert.equal(micromark(':a{.ađź’šb}', options()), '') - } - ) - - await t.test( - 'should support an underscore in attribute names', - async function () { - assert.equal(micromark(':a{_}', options()), '') - } - ) - - await t.test('should support a colon in attribute names', async function () { - assert.equal(micromark(':a{xml:lang}', options()), '') - }) - - await t.test('should support double quoted attributes', async function () { - assert.equal(micromark(':a{a="b" c="d e f"}', options()), '') - }) - - await t.test('should support single quoted attributes', async function () { - assert.equal(micromark(":a{a='b' c='d e f'}", options()), '') - }) - - await t.test( - 'should support whitespace around initializers', - async function () { - assert.equal( - micromark(':a{a = b c\t=\t\'d\' f =\r"g"}', options()), - '' - ) - } - ) - - await t.test( - 'should not support `=` to start an unquoted attribute value', - async function () { - assert.equal(micromark(':a{b==}', options()), '{b==}
') - } - ) - - await t.test( - 'should not support a missing attribute value after `=`', - async function () { - assert.equal(micromark(':a{b=}', options()), '{b=}
') - } - ) - - await t.test( - 'should not support an apostrophe in an unquoted attribute value', - async function () { - assert.equal(micromark(":a{b=c'}", options()), "{b=c'}
") - } - ) - - await t.test( - 'should not support a grave accent in an unquoted attribute value', - async function () { - assert.equal(micromark(':a{b=c`}', options()), '{b=c`}
') - } - ) - - await t.test( - 'should support most other characters in unquoted attribute values', - async function () { - assert.equal(micromark(':a{b=ađź’šb}', options()), '') - } - ) - - await t.test( - 'should not support an EOF in a quoted attribute value', - async function () { - assert.equal(micromark(':a{b="c', options()), '{b="c
') - } - ) - - await t.test( - 'should support most other characters in quoted attribute values', - async function () { - assert.equal(micromark(':a{b="ađź’šb"}', options()), '') - } - ) - - await t.test( - 'should support EOLs in quoted attribute values', - async function () { - assert.equal(micromark(':a{b="\nc\r d"}', options()), '') - } - ) - - await t.test( - 'should not support an EOF after a quoted attribute value', - async function () { - assert.equal(micromark(':a{b="c"', options()), '{b="c"
') - } - ) -}) - -test('micromark-extension-directive (syntax, leaf)', async function (t) { - await t.test('should support a directive', async function () { - assert.equal(micromark('::b', options()), '') - }) - - await t.test('should not support one colon', async function () { - assert.equal(micromark(':', options()), ':
') - }) - - await t.test( - 'should not support two colons not followed by an alpha', - async function () { - assert.equal(micromark('::', options()), '::
') - } - ) - - await t.test( - 'should support two colons followed by an alpha', - async function () { - assert.equal(micromark('::a', options()), '') - } - ) - - await t.test( - 'should not support two colons followed by a digit', - async function () { - assert.equal(micromark('::9', options()), '::9
') - } - ) - - await t.test( - 'should not support two colons followed by a dash', - async function () { - assert.equal(micromark('::-', options()), '::-
') - } - ) - - await t.test('should support a digit in a name', async function () { - assert.equal(micromark('::a9', options()), '') - }) - - await t.test('should support a dash in a name', async function () { - assert.equal(micromark('::a-b', options()), '') - }) - - await t.test( - 'should not support a name followed by an unclosed `[`', - async function () { - assert.equal(micromark('::a[', options()), '::a[
') - } - ) - - await t.test( - 'should not support a name followed by an unclosed `{`', - async function () { - assert.equal(micromark('::a{', options()), '::a{
') - } - ) - - await t.test( - 'should not support a name followed by an unclosed `[` w/ content', - async function () { - assert.equal(micromark('::a[b', options()), '::a[b
') - } - ) - - await t.test( - 'should not support a name followed by an unclosed `{` w/ content', - async function () { - assert.equal(micromark('::a{b', options()), '::a{b
') - } - ) - - await t.test('should support an empty label', async function () { - assert.equal(micromark('::a[]', options()), '') - }) - - await t.test('should support a whitespace only label', async function () { - assert.equal(micromark('::a[ \t]', options()), '') - }) - - await t.test('should not support an eol in an label', async function () { - assert.equal(micromark('::a[\n]', options()), '::a[\n]
') - }) - - await t.test('should support content in an label', async function () { - assert.equal(micromark('::a[a b c]', options()), '') - }) - - await t.test('should support markdown in an label', async function () { - assert.equal(micromark('::a[a *b* c]', options()), '') - }) - - await t.test('should not support content after a label', async function () { - assert.equal(micromark('::a[]asd', options()), '::a[]asd
') - }) - - await t.test('should support empty attributes', async function () { - assert.equal(micromark('::a{}', options()), '') - }) - - await t.test('should support whitespace only attributes', async function () { - assert.equal(micromark('::a{ \t}', options()), '') - }) - - await t.test('should not support an eol in attributes', async function () { - assert.equal(micromark('::a{\n}', options()), '::a{\n}
') - }) - - await t.test('should support attributes w/o values', async function () { - assert.equal(micromark('::a{a b c}', options()), '') - }) - - await t.test( - 'should support attributes w/ unquoted values', - async function () { - assert.equal(micromark('::a{a=b c=d}', options()), '') - } - ) - - await t.test( - 'should support attributes w/ class shortcut', - async function () { - assert.equal(micromark('::a{.a .b}', options()), '') - } - ) - - await t.test('should support attributes w/ id shortcut', async function () { - assert.equal(micromark('::a{#a #b}', options()), '') - }) - - await t.test( - 'should support most characters in shortcuts', - async function () { - assert.equal(micromark('::a{.ađź’šb}', options()), '') - } - ) - - await t.test('should support double quoted attributes', async function () { - assert.equal(micromark('::a{a="b" c="d e f"}', options()), '') - }) - - await t.test('should support single quoted attributes', async function () { - assert.equal(micromark("::a{a='b' c='d e f'}", options()), '') - }) - - await t.test( - 'should support whitespace around initializers', - async function () { - assert.equal(micromark("::a{a = b c\t=\t'd'}", options()), '') - } - ) - - await t.test( - 'should not support EOLs around initializers', - async function () { - assert.equal(micromark('::a{f =\rg}', options()), '::a{f =\rg}
') - } - ) - - await t.test( - 'should not support `=` to start an unquoted attribute value', - async function () { - assert.equal(micromark('::a{b==}', options()), '::a{b==}
') - } - ) - - await t.test( - 'should support most other characters in unquoted attribute values', - async function () { - assert.equal(micromark('::a{b=ađź’šb}', options()), '') - } - ) - - await t.test( - 'should not support an EOF in a quoted attribute value', - async function () { - assert.equal(micromark('::a{b="c', options()), '::a{b="c
') - } - ) - - await t.test( - 'should support most other characters in quoted attribute values', - async function () { - assert.equal(micromark('::a{b="ađź’šb"}', options()), '') - } - ) - - await t.test( - 'should not support EOLs in quoted attribute values', - async function () { - assert.equal( - micromark('::a{b="\nc\r d"}', options()), - '::a{b="\nc\rd"}
' - ) - } - ) - - await t.test( - 'should not support an EOF after a quoted attribute value', - async function () { - assert.equal( - micromark('::a{b="c"', options()), - '::a{b="c"
' - ) - } - ) - - await t.test('should support whitespace after directives', async function () { - assert.equal(micromark('::a{b=c} \t ', options()), '') - }) - - await t.test('should support a block quote after a leaf', async function () { - assert.equal( - micromark('::a{b=c}\n>a', options()), - '\n' - ) - }) - - await t.test('should support code (fenced) after a leaf', async function () { - assert.equal( - micromark('::a{b=c}\n```js\na', options()), - 'a
\n
a\n
\n'
- )
- })
-
- await t.test(
- 'should support code (indented) after a leaf',
- async function () {
- assert.equal(
- micromark('::a{b=c}\n a', options()),
- 'a\n
'
- )
- }
- )
-
- await t.test('should support a definition after a leaf', async function () {
- assert.equal(micromark('::a{b=c}\n[a]: b', options()), '')
- })
-
- await t.test(
- 'should support a heading (atx) after a leaf',
- async function () {
- assert.equal(micromark('::a{b=c}\n# a', options()), 'a
') - }) - - await t.test( - 'should support a thematic break after a leaf', - async function () { - assert.equal(micromark('::a{b=c}\n***', options()), '\n\n' - ) - }) - - await t.test('should support code (fenced) before a leaf', async function () { - assert.equal( - micromark('```js\na\n```\n::a{b=c}', options()), - 'a
\n
a\n
\n'
- )
- })
-
- await t.test(
- 'should support code (indented) before a leaf',
- async function () {
- assert.equal(
- micromark(' a\n::a{b=c}', options()),
- 'a\n
\n'
- )
- }
- )
-
- await t.test('should support a definition before a leaf', async function () {
- assert.equal(micromark('[a]: b\n::a{b=c}', options()), '')
- })
-
- await t.test(
- 'should support a heading (atx) before a leaf',
- async function () {
- assert.equal(micromark('# a\n::a{b=c}', options()), 'a
\n') - }) - - await t.test( - 'should support a thematic break before a leaf', - async function () { - assert.equal(micromark('***\n::a{b=c}', options()), '\n\n
b
' - ) - }) - - await t.test('should not support lazyness (2)', async function () { - assert.equal( - micromark('> a\n::b', options({'*': h})), - '\n\n' - ) - }) -}) - -test('micromark-extension-directive (syntax, container)', async function (t) { - await t.test('should support a directive', async function () { - assert.equal(micromark(':::b', options()), '') - }) - - await t.test('should not support one colon', async function () { - assert.equal(micromark(':', options()), 'a
\n
:
') - }) - - await t.test( - 'should not support two colons not followed by an alpha', - async function () { - assert.equal(micromark('::', options()), '::
') - } - ) - - await t.test( - 'should not support three colons not followed by an alpha', - async function () { - assert.equal(micromark(':::', options()), ':::
') - } - ) - - await t.test( - 'should support three colons followed by an alpha', - async function () { - assert.equal(micromark(':::a', options()), '') - } - ) - - await t.test( - 'should not support three colons followed by a digit', - async function () { - assert.equal(micromark(':::9', options()), ':::9
') - } - ) - - await t.test( - 'should not support three colons followed by a dash', - async function () { - assert.equal(micromark(':::-', options()), ':::-
') - } - ) - - await t.test('should support a digit in a name', async function () { - assert.equal(micromark(':::a9', options()), '') - }) - - await t.test('should support a dash in a name', async function () { - assert.equal(micromark(':::a-b', options()), '') - }) - - await t.test( - 'should not support a name followed by an unclosed `[`', - async function () { - assert.equal(micromark(':::a[', options()), ':::a[
') - } - ) - - await t.test( - 'should not support a name followed by an unclosed `{`', - async function () { - assert.equal(micromark(':::a{', options()), ':::a{
') - } - ) - - await t.test( - 'should not support a name followed by an unclosed `[` w/ content', - async function () { - assert.equal(micromark(':::a[b', options()), ':::a[b
') - } - ) - - await t.test( - 'should not support a name followed by an unclosed `{` w/ content', - async function () { - assert.equal(micromark(':::a{b', options()), ':::a{b
') - } - ) - - await t.test('should support an empty label', async function () { - assert.equal(micromark(':::a[]', options()), '') - }) - - await t.test('should support a whitespace only label', async function () { - assert.equal(micromark(':::a[ \t]', options()), '') - }) - - await t.test('should not support an eol in an label', async function () { - assert.equal(micromark(':::a[\n]', options()), ':::a[\n]
') - }) - - await t.test('should support content in an label', async function () { - assert.equal(micromark(':::a[a b c]', options()), '') - }) - - await t.test('should support markdown in an label', async function () { - assert.equal(micromark(':::a[a *b* c]', options()), '') - }) - - await t.test('should not support content after a label', async function () { - assert.equal(micromark(':::a[]asd', options()), ':::a[]asd
') - }) - - await t.test('should support empty attributes', async function () { - assert.equal(micromark(':::a{}', options()), '') - }) - - await t.test('should support whitespace only attributes', async function () { - assert.equal(micromark(':::a{ \t}', options()), '') - }) - - await t.test('should not support an eol in attributes', async function () { - assert.equal(micromark(':::a{\n}', options()), ':::a{\n}
') - }) - - await t.test('should support attributes', async function () { - assert.equal(micromark(':::a{a b c}', options()), '') - }) - - await t.test( - 'should not support EOLs around initializers', - async function () { - assert.equal( - micromark(':::a{f =\rg}', options()), - ':::a{f =\rg}
' - ) - } - ) - - await t.test( - 'should not support an EOF in a quoted attribute value', - async function () { - assert.equal(micromark(':::a{b="c', options()), ':::a{b="c
') - } - ) - - await t.test( - 'should not support EOLs in quoted attribute values', - async function () { - assert.equal( - micromark(':::a{b="\nc\r d"}', options()), - ':::a{b="\nc\rd"}
' - ) - } - ) - - await t.test( - 'should not support an EOF after a quoted attribute value', - async function () { - assert.equal( - micromark(':::a{b="c"', options()), - ':::a{b="c"
' - ) - } - ) - - await t.test('should support whitespace after directives', async function () { - assert.equal(micromark(':::a{b=c} \t ', options()), '') - }) - - await t.test('should support no closing fence', async function () { - assert.equal(micromark(':::a\n', options()), '') - }) - - await t.test('should support an immediate closing fence', async function () { - assert.equal(micromark(':::a\n:::', options()), '') - }) - - await t.test( - 'should support content after a closing fence', - async function () { - assert.equal(micromark(':::a\n:::\nb', options()), 'b
') - } - ) - - await t.test( - 'should not close w/ a “closing” fence of two colons', - async function () { - assert.equal(micromark(':::a\n::\nb', options()), '') - } - ) - - await t.test( - 'should close w/ a closing fence of more colons', - async function () { - assert.equal(micromark(':::a\n::::\nb', options()), 'b
') - } - ) - - await t.test('should support more opening colons', async function () { - assert.equal(micromark('::::a\n::::\nb', options()), 'b
') - }) - - await t.test( - 'should not close w/ a “closing” fence of less colons than the opening', - async function () { - assert.equal(micromark(':::::a\n::::\nb', options()), '') - } - ) - - await t.test( - 'should close w/ a closing fence followed by white space', - async function () { - assert.equal(micromark(':::a\n::: \t\nc', options()), 'c
') - } - ) - - await t.test( - 'should not close w/ a “closing” fence followed by other characters', - async function () { - assert.equal(micromark(':::a\n::: b\nc', options()), '') - } - ) - - await t.test('should close w/ an indented closing fence', async function () { - assert.equal(micromark(':::a\n :::\nc', options()), 'c
') - }) - - await t.test( - 'should not close w/ when the “closing” fence is indented at a tab size', - async function () { - assert.equal(micromark(':::a\n\t:::\nc', options()), '') - } - ) - - await t.test( - 'should not close w/ when the “closing” fence is indented more than a tab size', - async function () { - assert.equal(micromark(':::a\n :::\nc', options()), '') - } - ) - - await t.test('should support blank lines in content', async function () { - assert.equal(micromark(':::a\n\n \n\ta', options()), '') - }) - - await t.test('should support an EOL EOF', async function () { - assert.equal(micromark(':::a\n\ta\n', options()), '') - }) - - await t.test('should support an indented directive', async function () { - assert.equal(micromark(' :::a\n b\n :::\nc', options()), 'c
') - }) - - await t.test( - 'should still not close an indented directive when the “closing” fence is indented a tab size', - async function () { - assert.equal(micromark(' :::a\n\t:::\nc', options()), '') - } - ) - - await t.test( - 'should strip arbitrary length prefix from closing fence line (codeIndented disabled)', - async function () { - assert.equal( - micromark(':::x\nalpha.\n :::\n\nbravo.', { - allowDangerousHtml: true, - extensions: [directive(), {disable: {null: ['codeIndented']}}], - htmlExtensions: [directiveHtml()] - }), - 'bravo.
' - ) - } - ) - - await t.test( - 'should support a block quote after a container', - async function () { - assert.equal( - micromark(':::a\n:::\n>a', options()), - '\n' - ) - } - ) - - await t.test( - 'should support code (fenced) after a container', - async function () { - assert.equal( - micromark(':::a\n:::\n```js\na', options()), - 'a
\n
a\n
\n'
- )
- }
- )
-
- await t.test(
- 'should support code (indented) after a container',
- async function () {
- assert.equal(
- micromark(':::a\n:::\n a', options()),
- 'a\n
'
- )
- }
- )
-
- await t.test(
- 'should support a definition after a container',
- async function () {
- assert.equal(micromark(':::a\n:::\n[a]: b', options()), '')
- }
- )
-
- await t.test(
- 'should support a heading (atx) after a container',
- async function () {
- assert.equal(micromark(':::a\n:::\n# a', options()), 'a
') - } - ) - - await t.test( - 'should support a thematic break after a container', - async function () { - assert.equal(micromark(':::a\n:::\n***', options()), '\n\n' - ) - } - ) - - await t.test( - 'should support code (fenced) before a container', - async function () { - assert.equal( - micromark('```js\na\n```\n:::a\nb', options()), - 'a
\n
a\n
\n'
- )
- }
- )
-
- await t.test(
- 'should support code (indented) before a container',
- async function () {
- assert.equal(
- micromark(' a\n:::a\nb', options()),
- 'a\n
\n'
- )
- }
- )
-
- await t.test(
- 'should support a definition before a container',
- async function () {
- assert.equal(micromark('[a]: b\n:::a\nb', options()), '')
- }
- )
-
- await t.test(
- 'should support a heading (atx) before a container',
- async function () {
- assert.equal(micromark('# a\n:::a\nb', options()), 'a
\n') - } - ) - - await t.test( - 'should support a thematic break before a container', - async function () { - assert.equal(micromark('***\n:::a\nb', options()), '\n\nb
\n
\n\nb
\n
\n\n
b
' - ) - }) - - await t.test('should not support lazyness (2)', async function () { - assert.equal( - micromark('> :::a\n> b\nc', options({'*': h})), - '\n\nb
\n\n
c
' - ) - }) - - await t.test('should not support lazyness (3)', async function () { - assert.equal( - micromark('> a\n:::b', options({'*': h})), - '\n\n' - ) - }) - - await t.test('should not support lazyness (4)', async function () { - assert.equal( - micromark('> :::a\n:::', options({'*': h})), - 'a
\n
\n\n
:::
' - ) - }) -}) - -test('micromark-extension-directive (compile)', async function (t) { - await t.test('should support a directives (abbr)', async function () { - assert.equal( - micromark( - [ - ':abbr', - ':abbr[HTML]', - ':abbr{title="HyperText Markup Language"}', - ':abbr[HTML]{title="HyperText Markup Language"}' - ].join('\n\n'), - options({abbr}) - ), - [ - '', - 'HTML
', - '', - 'HTML
' - ].join('\n') - ) - }) - - await t.test('should support directives (youtube)', async function () { - assert.equal( - micromark( - [ - 'Text:', - ':youtube', - ':youtube[Cat in a box a]', - ':youtube{v=1}', - ':youtube[Cat in a box b]{v=2}', - 'Leaf:', - '::youtube', - '::youtube[Cat in a box c]', - '::youtube{v=3}', - '::youtube[Cat in a box d]{v=4}', - 'Container:', - ':::youtube\nw\n:::', - ':::youtube[Cat in a box e]\nx\n:::', - ':::youtube{v=5}\ny\n:::', - ':::youtube[Cat in a box f]{v=6}\nz\n:::' - ].join('\n\n'), - options({youtube}) - ), - [ - 'Text:
', - '', - '', - '', - '', - 'Leaf:
', - '', - '', - 'Container:
', - '', - '' - ].join('\n') - ) - }) - - await t.test( - 'should support fall through directives (`*`)', - async function () { - assert.equal( - micromark(':youtube[Cat in a box]\n:br', options({youtube, '*': h})), - 'x&y&z
' - ) - } - ) - - await t.test('should support escaped brackets in a label', async function () { - assert.equal( - micromark(':abbr[x\\[y\\]z]', options({abbr})), - 'x[y]z
' - ) - }) - - await t.test( - 'should support balanced brackets in a label', - async function () { - assert.equal( - micromark(':abbr[x[y]z]', options({abbr})), - 'x[y]z
' - ) - } - ) - - await t.test( - 'should support balanced brackets in a label, 32 levels deep', - async function () { - assert.equal( - micromark( - ':abbr[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]', - options({abbr}) - ), - '1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
' - ) - } - ) - - await t.test( - 'should *not* support balanced brackets in a label, 33 levels deep', - async function () { - assert.equal( - micromark( - ':abbr[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[33[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]', - options({abbr}) - ), - '[1[2[3[4[5[6[7[8[9[10[11[12[13[14[15[16[17[18[19[20[21[22[23[24[25[26[27[28[29[30[31[32[33[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
' - ) - } - ) - - await t.test('should support EOLs in a label', async function () { - assert.equal( - micromark(':abbr[a\nb\rc]', options({abbr})), - 'a\nb\rc
' - ) - }) - - await t.test( - 'should support EOLs at the edges of a label (1)', - async function () { - assert.equal( - micromark(':abbr[\na\r]', options({abbr})), - '\na\r
' - ) - } - ) - - await t.test( - 'should support EOLs at the edges of a label (2)', - async function () { - assert.equal( - micromark(':abbr[\n]', options({abbr})), - '\n
' - ) - } - ) - - await t.test( - 'should support EOLs around nested directives', - async function () { - assert.equal( - micromark(':abbr[a\n:abbr[b]\nc]', options({abbr})), - 'a\nb\nc
' - ) - } - ) - - await t.test( - 'should support EOLs inside nested directives (1)', - async function () { - assert.equal( - micromark(':abbr[:abbr[\n]]', options({abbr})), - '\n
' - ) - } - ) - - await t.test( - 'should support EOLs inside nested directives (2)', - async function () { - assert.equal( - micromark(':abbr[:abbr[a\nb]]', options({abbr})), - 'a\nb
' - ) - } - ) - - await t.test( - 'should support EOLs inside nested directives (3)', - async function () { - assert.equal( - micromark(':abbr[:abbr[\nb\n]]', options({abbr})), - '\nb\n
' - ) - } - ) - - await t.test( - 'should support EOLs inside nested directives (4)', - async function () { - assert.equal( - micromark(':abbr[:abbr[\\\n]]', options({abbr})), - '
\n
a b c d
' - ) - }) - - await t.test( - 'should support character references in unquoted attribute values', - async function () { - assert.equal( - micromark(':abbr{title=a'b}', options({abbr})), - '' - ) - } - ) - - await t.test( - 'should support character references in double attribute values', - async function () { - assert.equal( - micromark(':abbr{title="a'b"}', options({abbr})), - '' - ) - } - ) - - await t.test( - 'should support character references in single attribute values', - async function () { - assert.equal( - micromark(":abbr{title='a'b'}", options({abbr})), - '' - ) - } - ) - - await t.test( - 'should support unknown character references in attribute values', - async function () { - assert.equal( - micromark(':abbr{title="a&somethingelse;b"}', options({abbr})), - '' - ) - } - ) - - await t.test( - 'should not support non-terminated character references in unquoted attribute values', - async function () { - assert.equal( - micromark(':a{href=¶m}', options({'*': h})), - '' - ) - } - ) - - await t.test( - 'should not support non-terminated character references in double quoted attribute values', - async function () { - assert.equal( - micromark(':a{href="¶m"}', options({'*': h})), - '' - ) - } - ) - - await t.test( - 'should not support non-terminated character references in single quoted attribute values', - async function () { - assert.equal( - micromark(":a{href='¶m'}", options({'*': h})), - '' - ) - } - ) - - await t.test('should support EOLs between attributes', async function () { - assert.equal( - micromark(':span{a\nb}', options({'*': h})), - '' - ) - }) - - await t.test( - 'should support EOLs at the edges of attributes', - async function () { - assert.equal( - micromark(':span{\na\n}', options({'*': h})), - '
' - ) - } - ) - - await t.test('should support EOLs before initializer', async function () { - assert.equal( - micromark(':span{a\r= b}', options({'*': h})), - '
' - ) - }) - - await t.test('should support EOLs after initializer', async function () { - assert.equal( - micromark(':span{a=\r\nb}', options({'*': h})), - '
' - ) - }) - - await t.test( - 'should support EOLs between an unquoted attribute value and a next attribute name', - async function () { - assert.equal( - micromark(':span{a=b\nc}', options({'*': h})), - '
' - ) - } - ) - - await t.test( - 'should support EOLs in a double quoted attribute value', - async function () { - assert.equal( - micromark(':span{a="b\nc"}', options({'*': h})), - '
' - ) - } - ) - - await t.test( - 'should support EOLs in a single quoted attribute value', - async function () { - assert.equal( - micromark(":span{a='b\nc'}", options({'*': h})), - '
' - ) - } - ) - - await t.test('should support `id` shortcuts', async function () { - assert.equal( - micromark(':span{#a#b}', options({'*': h})), - '
' - ) - }) - - await t.test( - 'should support `id` shortcuts after `id` attributes', - async function () { - assert.equal( - micromark(':span{id=a id="b" #c#d}', options({'*': h})), - '
' - ) - } - ) - - await t.test('should support `class` shortcuts', async function () { - assert.equal( - micromark(':span{.a.b}', options({'*': h})), - '
' - ) - }) - - await t.test( - 'should support `class` shortcuts after `class` attributes', - async function () { - assert.equal( - micromark(':span{class=a class="b c" .d.e}', options({'*': h})), - '
' - ) - } - ) - - await t.test( - 'should support container directives in container directives', - async function () { - assert.equal( - micromark('::::div{.big}\n:::div{.small}\nText', options({'*': h})), - '
Text
\nText
\n