Skip to content

Commit

Permalink
fix(markdown): issue with h1-6 tags (#1223)
Browse files Browse the repository at this point in the history
* fix(markdown): issue with `h1-6` tags

* test: add heading tests
  • Loading branch information
farnabaz committed Jun 8, 2022
1 parent a7d3f4d commit 1777fd7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/runtime/markdown-parser/handler/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
14 changes: 14 additions & 0 deletions test/features/parser-markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<h1>Hello</h1>'
}
})

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

0 comments on commit 1777fd7

Please sign in to comment.