chore: implement html renderer

This commit is contained in:
Steven
2023-12-14 00:04:20 +08:00
parent 43ef9eaced
commit 5266a62685
5 changed files with 103 additions and 12 deletions

View File

@ -22,6 +22,14 @@ func TestHTMLRenderer(t *testing.T) {
text: "> Hello\n> world!",
expected: `<blockquote>Hello<br>world!</blockquote>`,
},
{
text: "*Hello* world!",
expected: `<p><em>Hello</em> world!</p>`,
},
{
text: "**Hello** world!",
expected: `<p><strong>Hello</strong> world!</p>`,
},
}
for _, test := range tests {
@ -29,8 +37,6 @@ func TestHTMLRenderer(t *testing.T) {
nodes, err := parser.Parse(tokens)
require.NoError(t, err)
actual := NewHTMLRenderer().Render(nodes)
if actual != test.expected {
t.Errorf("expected: %s, actual: %s", test.expected, actual)
}
require.Equal(t, test.expected, actual)
}
}