test(markdown): cover attrs behavior before plugin migration

Captures what the markdown-it-attrs patch enforces (curly attributes
never consume fence info, preserving line-highlight syntax) plus the
supported attribute placements, as a regression baseline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pull/5335/head
Divyansh Singh 4 days ago
parent 018887fa1d
commit 7c09583eaa

@ -114,6 +114,31 @@ describe('node/markdown/markdown', () => {
})
})
describe('attrs', () => {
test('does not consume fence info', async () => {
// line-highlight / meta syntax must reach the highlighter untouched
const meta = await render('```js{4}\nconst a = 1\n```')
expect(meta).toContain('language-js')
expect(meta).not.toContain('4=""')
// curly attributes have no effect on fenced code blocks
const backtick = await render('```js {.foo}\nconst a = 1\n```')
expect(backtick).not.toContain('class="foo"')
const tilde = await render('~~~js {.foo}\nconst a = 1\n~~~')
expect(tilde).not.toContain('class="foo"')
})
test('applies to inline elements and blocks', async () => {
expect(await render('*hi*{.cls}')).toContain('<em class="cls">')
expect(await render('`code`{.cls}')).toContain('class="cls"')
expect(await render('text {.cls}')).toContain('<p class="cls">')
expect(await render('- item\n{.cls}')).toContain('<ul class="cls">')
expect(await render('| a |\n| --- |\n| b |\n\n{.cls}')).toContain(
'<table class="cls"'
)
})
})
// attrs applies at a fixed position in the core chain (before linkify),
// while anchor pushes to its end, so anchor always sees user-defined ids
// no matter which plugin is registered first

Loading…
Cancel
Save