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: `
Hello world!
`, }, { text: "> Hello\n> world!", expected: `Hello`, }, { text: "*Hello* world!", expected: `
world!
Hello world!
`, }, { text: "**Hello** world!", expected: `Hello world!
`, }, } for _, test := range tests { tokens := tokenizer.Tokenize(test.text) nodes, err := parser.Parse(tokens) require.NoError(t, err) actual := NewHTMLRenderer().Render(nodes) require.Equal(t, test.expected, actual) } }