chore: update inline parser

This commit is contained in:
Steven
2023-12-16 10:09:20 +08:00
parent 7b0ceee57b
commit 47af632c79
19 changed files with 73 additions and 222 deletions

View File

@ -32,8 +32,12 @@ func TestParser(t *testing.T) {
&ast.Paragraph{
Children: []ast.Node{
&ast.Bold{
Symbol: "*",
Content: "Hello",
Symbol: "*",
Children: []ast.Node{
&ast.Text{
Content: "Hello",
},
},
},
&ast.Text{
Content: " world!",
@ -51,8 +55,12 @@ func TestParser(t *testing.T) {
Content: "Hello ",
},
&ast.Bold{
Symbol: "*",
Content: "world",
Symbol: "*",
Children: []ast.Node{
&ast.Text{
Content: "world",
},
},
},
&ast.Text{
Content: "!",
@ -78,8 +86,12 @@ func TestParser(t *testing.T) {
Content: "Hello ",
},
&ast.Bold{
Symbol: "*",
Content: "world",
Symbol: "*",
Children: []ast.Node{
&ast.Text{
Content: "world",
},
},
},
&ast.Text{
Content: "!",
@ -150,7 +162,7 @@ func StringifyNode(node ast.Node) string {
case *ast.Text:
return "Text(" + n.Content + ")"
case *ast.Bold:
return "Bold(" + n.Symbol + n.Content + n.Symbol + ")"
return "Bold(" + n.Symbol + StringifyNodes(n.Children) + n.Symbol + ")"
case *ast.Italic:
return "Italic(" + n.Symbol + n.Content + n.Symbol + ")"
case *ast.BoldItalic: