Add support for arbitrary indent when w/o codeIntended

Related-to: facebook/docusaurus#10305.
This commit is contained in:
Titus Wormer 2024-07-17 12:27:56 +02:00
parent c33a6406b8
commit 521612a6a8
No known key found for this signature in database
GPG key ID: E6E581152ED04E2E
2 changed files with 18 additions and 2 deletions

View file

@ -197,12 +197,14 @@ function tokenizeDirectiveContainer(effects, ok, nok) {
*/ */
function tokenizeClosingFence(effects, ok, nok) { function tokenizeClosingFence(effects, ok, nok) {
let size = 0 let size = 0
assert(self.parser.constructs.disable.null, 'expected `disable.null`')
return factorySpace( return factorySpace(
effects, effects,
closingPrefixAfter, closingPrefixAfter,
types.linePrefix, types.linePrefix,
constants.tabSize self.parser.constructs.disable.null.includes('codeIndented')
? undefined
: constants.tabSize
) )
/** @type {State} */ /** @type {State} */

View file

@ -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()]
}),
'<p>bravo.</p>'
)
}
)
await t.test( await t.test(
'should support a block quote after a container', 'should support a block quote after a container',
async function () { async function () {