mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: implement part of html renderer
This commit is contained in:
36
plugin/gomark/renderer/html/html_test.go
Normal file
36
plugin/gomark/renderer/html/html_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package html
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/usememos/memos/plugin/gomark/parser"
|
||||
"github.com/usememos/memos/plugin/gomark/parser/tokenizer"
|
||||
)
|
||||
|
||||
func TestHTMLRenderer(t *testing.T) {
|
||||
tests := []struct {
|
||||
text string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
text: "Hello world!",
|
||||
expected: `<p>Hello world!</p>`,
|
||||
},
|
||||
{
|
||||
text: "> Hello\n> world!",
|
||||
expected: `<blockquote>Hello<br>world!</blockquote>`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
tokens := tokenizer.Tokenize(test.text)
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user