From 4587451da565dec1b4a99023801ee0e38e283721 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 7 Jun 2022 01:34:54 +0200 Subject: [PATCH 1/2] fix(markdown): issue with `h1-6` tags --- src/runtime/markdown-parser/handler/html.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/markdown-parser/handler/html.ts b/src/runtime/markdown-parser/handler/html.ts index ba4eff9cf..036aef31b 100644 --- a/src/runtime/markdown-parser/handler/html.ts +++ b/src/runtime/markdown-parser/handler/html.ts @@ -6,7 +6,7 @@ import { getTagName } from './utils' export default function html (h: H, node: any) { const tagName = getTagName(node.value) - if (tagName) { + if (tagName && /[A-Z]/.test(tagName)) { node.value = node.value.replace(tagName, kebabCase(tagName)) } From 47f93ba5549c167d9a2171bdf3003d5a7cc5cae4 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Tue, 7 Jun 2022 01:38:21 +0200 Subject: [PATCH 2/2] test: add heading tests --- test/features/parser-markdown.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/features/parser-markdown.ts b/test/features/parser-markdown.ts index 39bd03e32..d73a54234 100644 --- a/test/features/parser-markdown.ts +++ b/test/features/parser-markdown.ts @@ -68,5 +68,19 @@ export const testMarkdownParser = () => { expect(parsed.body).toHaveProperty('children') expect(parsed.body.children.length).toEqual(0) }) + + test('h1 tags', async () => { + const parsed = await $fetch('/api/parse', { + method: 'POST', + body: { + id: 'content:index.md', + content: '

Hello

' + } + }) + + expect(parsed.body).toHaveProperty('children') + expect(parsed.body.children.length).toEqual(1) + expect(parsed.body.children[0].tag).toEqual('h1') + }) }) }