fix: heading render

This commit is contained in:
Steven 2023-12-16 09:12:55 +08:00
parent 6421fbc68a
commit bdc867d153
2 changed files with 5 additions and 1 deletions

View file

@ -96,7 +96,7 @@ func (r *HTMLRender) renderCodeBlock(node *ast.CodeBlock) {
}
func (r *HTMLRender) renderHeading(node *ast.Heading) {
element := fmt.Sprintf("<h%d>", node.Level)
element := fmt.Sprintf("h%d", node.Level)
r.output.WriteString(fmt.Sprintf("<%s>", element))
r.RenderNodes(node.Children)
r.output.WriteString(fmt.Sprintf("</%s>", element))

View file

@ -18,6 +18,10 @@ func TestHTMLRender(t *testing.T) {
text: "Hello world!",
expected: `<p>Hello world!</p>`,
},
{
text: "# Hello world!",
expected: `<h1>Hello world!</h1>`,
},
{
text: "> Hello\n> world!",
expected: `<blockquote>Hello<br>world!</blockquote>`,