From 521612a6a85135668310ceef8d96e57b9f783117 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 17 Jul 2024 12:27:56 +0200 Subject: [PATCH] Add support for arbitrary indent when w/o `codeIntended` Related-to: facebook/docusaurus#10305. --- dev/lib/directive-container.js | 6 ++++-- test/index.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/dev/lib/directive-container.js b/dev/lib/directive-container.js index 76114c3..ba97138 100644 --- a/dev/lib/directive-container.js +++ b/dev/lib/directive-container.js @@ -197,12 +197,14 @@ function tokenizeDirectiveContainer(effects, ok, nok) { */ function tokenizeClosingFence(effects, ok, nok) { let size = 0 - + assert(self.parser.constructs.disable.null, 'expected `disable.null`') return factorySpace( effects, closingPrefixAfter, types.linePrefix, - constants.tabSize + self.parser.constructs.disable.null.includes('codeIndented') + ? undefined + : constants.tabSize ) /** @type {State} */ diff --git a/test/index.js b/test/index.js index 648ef29..9886878 100644 --- a/test/index.js +++ b/test/index.js @@ -993,6 +993,20 @@ test('micromark-extension-directive (syntax, container)', async function (t) { } ) + 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 () {