chore: implement part of nodes

This commit is contained in:
Steven
2023-12-13 09:06:47 +08:00
parent dd83782522
commit b20e0097cf
16 changed files with 227 additions and 142 deletions

View File

@ -5,17 +5,18 @@ import (
"github.com/stretchr/testify/require"
"github.com/usememos/memos/plugin/gomark/ast"
"github.com/usememos/memos/plugin/gomark/parser/tokenizer"
)
func TestImageParser(t *testing.T) {
tests := []struct {
text string
image *ImageParser
image ast.Node
}{
{
text: "![](https://example.com)",
image: &ImageParser{
image: &ast.Image{
AltText: "",
URL: "https://example.com",
},
@ -30,7 +31,7 @@ func TestImageParser(t *testing.T) {
},
{
text: "![al te](https://example.com)",
image: &ImageParser{
image: &ast.Image{
AltText: "al te",
URL: "https://example.com",
},
@ -38,6 +39,6 @@ func TestImageParser(t *testing.T) {
}
for _, test := range tests {
tokens := tokenizer.Tokenize(test.text)
require.Equal(t, test.image, NewImageParser().Match(tokens))
require.Equal(t, test.image, NewImageParser().Parse(tokens))
}
}