diff --git a/lib/tokenize-directive-container.js b/lib/tokenize-directive-container.js index 494d345..c5c7139 100644 --- a/lib/tokenize-directive-container.js +++ b/lib/tokenize-directive-container.js @@ -104,7 +104,13 @@ function tokenizeDirectiveContainer(effects, ok, nok) { } function chunkStart(code) { - var token = effects.enter('chunkDocument', { + var token + + if (code === null) { + return after(code) + } + + token = effects.enter('chunkDocument', { contentType: 'document', previous: previous }) diff --git a/test.js b/test.js index 248ffde..b928ddf 100644 --- a/test.js +++ b/test.js @@ -1020,6 +1020,30 @@ test('micromark-extension-directive (syntax)', function (t) { 'should support a thematic break before a container' ) + t.equal( + micromark(' :::x\n ', options({'*': h})), + '', + 'should support prefixed containers (1)' + ) + + t.equal( + micromark(' :::x\n - a', options({'*': h})), + '\n\n', + 'should support prefixed containers (2)' + ) + + t.equal( + micromark(' :::x\n - a\n > b', options({'*': h})), + '\n\n
\n

b

\n
\n
', + 'should support prefixed containers (3)' + ) + + t.equal( + micromark(' :::x\n - a\n > b\n :::', options({'*': h})), + '\n\n
\n

b

\n
\n
', + 'should support prefixed containers (4)' + ) + t.end() })