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

@@ -10,12 +10,6 @@ type Text struct {
var NodeTypeText = NewNodeType("Text")
func NewText(content string) *Text {
return &Text{
Content: content,
}
}
func (*Text) Type() NodeType {
return NodeTypeText
}
@@ -30,13 +24,70 @@ type Bold struct {
var NodeTypeBold = NewNodeType("Bold")
func NewBold(symbol, content string) *Bold {
return &Bold{
Symbol: symbol,
Content: content,
}
}
func (*Bold) Type() NodeType {
return NodeTypeBold
}
type Code struct {
BaseInline
Content string
}
var NodeTypeCode = NewNodeType("Code")
func (*Code) Type() NodeType {
return NodeTypeCode
}
type Image struct {
BaseInline
AltText string
URL string
}
var NodeTypeImage = NewNodeType("Image")
func (*Image) Type() NodeType {
return NodeTypeImage
}
type Link struct {
BaseInline
Text string
URL string
}
var NodeTypeLink = NewNodeType("Link")
func (*Link) Type() NodeType {
return NodeTypeLink
}
type Italic struct {
BaseInline
// Symbol is "*" or "_"
Symbol string
Content string
}
var NodeTypeItalic = NewNodeType("Italic")
func (*Italic) Type() NodeType {
return NodeTypeItalic
}
type Tag struct {
BaseInline
Content string
}
var NodeTypeTag = NewNodeType("Tag")
func (*Tag) Type() NodeType {
return NodeTypeTag
}