refactor: markdown parser matchers

This commit is contained in:
Steven
2024-01-23 21:23:40 +08:00
parent bf905bba86
commit d165d87288
55 changed files with 454 additions and 894 deletions

View File

@ -19,6 +19,14 @@ func TestBoldItalicParser(t *testing.T) {
text: "*Hello world!",
boldItalic: nil,
},
{
text: "*** Hello * *",
boldItalic: nil,
},
{
text: "*** Hello **",
boldItalic: nil,
},
{
text: "***Hello***",
boldItalic: &ast.BoldItalic{
@ -33,19 +41,11 @@ func TestBoldItalicParser(t *testing.T) {
Content: " Hello ",
},
},
{
text: "*** Hello * *",
boldItalic: nil,
},
{
text: "*** Hello **",
boldItalic: nil,
},
}
for _, test := range tests {
tokens := tokenizer.Tokenize(test.text)
node, _ := NewBoldItalicParser().Parse(tokens)
node, _ := NewBoldItalicParser().Match(tokens)
require.Equal(t, restore.Restore([]ast.Node{test.boldItalic}), restore.Restore([]ast.Node{node}))
}
}