fix(markdown): remove extra whitespace from container markup

pull/5337/head
Divyansh Singh 2 months ago
parent 992f08fa84
commit b6d9cb83c7

@ -223,6 +223,22 @@ describe('node/markdown/plugins/containers', () => {
`)
})
// FIXME: enable after attrs plugin version bump
test.skip('respects attrs plugin options on the fence line', async () => {
const delimiters = await render(
'::: tip Custom %(.extra-class)%\ncontent\n:::',
{ attrs: { left: '%(', right: ')%' } }
)
expect(delimiters).toContain('<div class="extra-class tip custom-block">')
const allowed = await render(
'::: tip Custom {.extra-class data-x=1}\ncontent\n:::',
{ attrs: { allowed: ['class'] } }
)
expect(allowed).toContain('<div class="extra-class tip custom-block">')
expect(allowed).not.toContain('data-x')
})
test('keeps fence line braces verbatim when attrs are disabled', async () => {
expect(
await render('::: details Click me {open}\ncontent\n:::', {

@ -138,7 +138,7 @@ function createOpenRender(
// details always needs its summary, so no-title is ignored there
const noTitle = attrPop(token, 'no-title') === '' && name !== 'details'
token.attrJoin('class', `${name} custom-block`)
const renderedAttrs = md.renderer.renderAttrs(token)
const renderedAttrs = md.renderer.renderAttrs(token).trim()
if (noTitle) return `<div ${renderedAttrs}>\n`
const title = md.renderInline(
info || titlesFor(titles, env.localeIndex)[name],

Loading…
Cancel
Save