From a20a4d7b8ffe3ae941b5c510b319ac6f9783aabe Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 9 Jan 2025 22:57:02 +0800 Subject: Fix markdoc render code block in if tag (#12930) --- .../markdoc/test/syntax-highlighting.test.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'packages/integrations/markdoc/test/syntax-highlighting.test.js') diff --git a/packages/integrations/markdoc/test/syntax-highlighting.test.js b/packages/integrations/markdoc/test/syntax-highlighting.test.js index f47b891f4..6ea841ae1 100644 --- a/packages/integrations/markdoc/test/syntax-highlighting.test.js +++ b/packages/integrations/markdoc/test/syntax-highlighting.test.js @@ -68,6 +68,27 @@ describe('Markdoc - syntax highlighting', () => { assert.equal(pre.getAttribute('style').includes('word-wrap: break-word'), true); } }); + it('transform within if tags', async () => { + const ast = Markdoc.parse(` +{% if equals("true", "true") %} +Inside truthy + +\`\`\`js +const hello = "yes"; +\`\`\` + +{% /if %}`); + const content = await Markdoc.transform(ast, await getConfigExtendingShiki()); + assert.equal(content.children.length, 1); + assert.equal(content.children[0].length, 2); + const pTag = content.children[0][0]; + assert.equal(pTag.name, 'p'); + const codeBlock = content.children[0][1]; + assert.equal(isHTMLString(codeBlock), true); + const pre = parsePreTag(codeBlock); + assert.equal(pre.classList.contains('astro-code'), true); + assert.equal(pre.classList.contains('github-dark'), true); + }); }); describe('prism', () => { -- cgit v1.2.3