chore: implement html render

This commit is contained in:
Steven
2023-12-14 22:21:23 +08:00
parent 3edce174d6
commit 242f64fa8e
12 changed files with 264 additions and 277 deletions

View File

@ -10,14 +10,8 @@ type Text struct {
Content string
}
var NodeTypeText = NewNodeType("Text")
func (*Text) Type() NodeType {
return NodeTypeText
}
func (n *Text) String() string {
return n.Type().String() + " " + n.Content
return TextNode
}
type Bold struct {
@ -28,14 +22,8 @@ type Bold struct {
Content string
}
var NodeTypeBold = NewNodeType("Bold")
func (*Bold) Type() NodeType {
return NodeTypeBold
}
func (n *Bold) String() string {
return n.Type().String() + " " + n.Symbol + " " + n.Content
return BoldNode
}
type Italic struct {
@ -46,14 +34,8 @@ type Italic struct {
Content string
}
var NodeTypeItalic = NewNodeType("Italic")
func (*Italic) Type() NodeType {
return NodeTypeItalic
}
func (n *Italic) String() string {
return n.Type().String() + " " + n.Symbol + " " + n.Content
return ItalicNode
}
type BoldItalic struct {
@ -64,14 +46,8 @@ type BoldItalic struct {
Content string
}
var NodeTypeBoldItalic = NewNodeType("BoldItalic")
func (*BoldItalic) Type() NodeType {
return NodeTypeBoldItalic
}
func (n *BoldItalic) String() string {
return n.Type().String() + " " + n.Symbol + " " + n.Content
return BoldItalicNode
}
type Code struct {
@ -80,14 +56,8 @@ type Code struct {
Content string
}
var NodeTypeCode = NewNodeType("Code")
func (*Code) Type() NodeType {
return NodeTypeCode
}
func (n *Code) String() string {
return n.Type().String() + " " + n.Content
return CodeNode
}
type Image struct {
@ -97,14 +67,8 @@ type Image struct {
URL string
}
var NodeTypeImage = NewNodeType("Image")
func (*Image) Type() NodeType {
return NodeTypeImage
}
func (n *Image) String() string {
return n.Type().String() + " " + n.AltText + " " + n.URL
return ImageNode
}
type Link struct {
@ -114,14 +78,8 @@ type Link struct {
URL string
}
var NodeTypeLink = NewNodeType("Link")
func (*Link) Type() NodeType {
return NodeTypeLink
}
func (n *Link) String() string {
return n.Type().String() + " " + n.Text + " " + n.URL
return LinkNode
}
type Tag struct {
@ -130,14 +88,8 @@ type Tag struct {
Content string
}
var NodeTypeTag = NewNodeType("Tag")
func (*Tag) Type() NodeType {
return NodeTypeTag
}
func (n *Tag) String() string {
return n.Type().String() + " " + n.Content
return TagNode
}
type Strikethrough struct {
@ -146,12 +98,6 @@ type Strikethrough struct {
Content string
}
var NodeTypeStrikethrough = NewNodeType("Strikethrough")
func (*Strikethrough) Type() NodeType {
return NodeTypeStrikethrough
}
func (n *Strikethrough) String() string {
return n.Type().String() + " " + n.Content
return StrikethroughNode
}