memos/plugin/gomark/ast/inline.go

158 lines
2.4 KiB
Go
Raw Normal View History

2023-12-12 23:24:02 +08:00
package ast
2023-12-13 21:00:13 +08:00
type BaseInline struct {
2023-12-13 23:50:05 +08:00
BaseNode
2023-12-13 21:00:13 +08:00
}
2023-12-12 23:24:02 +08:00
type Text struct {
BaseInline
Content string
}
var NodeTypeText = NewNodeType("Text")
func (*Text) Type() NodeType {
return NodeTypeText
}
2023-12-13 23:50:05 +08:00
func (n *Text) String() string {
return n.Type().String() + " " + n.Content
}
2023-12-12 23:24:02 +08:00
type Bold struct {
BaseInline
2023-12-13 23:50:05 +08:00
// Symbol is "*" or "_".
2023-12-12 23:24:02 +08:00
Symbol string
Content string
}
var NodeTypeBold = NewNodeType("Bold")
func (*Bold) Type() NodeType {
return NodeTypeBold
}
2023-12-13 09:06:47 +08:00
2023-12-13 23:50:05 +08:00
func (n *Bold) String() string {
return n.Type().String() + " " + n.Symbol + " " + n.Content
}
2023-12-13 21:00:13 +08:00
type Italic struct {
BaseInline
2023-12-13 23:50:05 +08:00
// Symbol is "*" or "_".
2023-12-13 21:00:13 +08:00
Symbol string
Content string
}
var NodeTypeItalic = NewNodeType("Italic")
func (*Italic) Type() NodeType {
return NodeTypeItalic
}
2023-12-13 23:50:05 +08:00
func (n *Italic) String() string {
return n.Type().String() + " " + n.Symbol + " " + n.Content
}
2023-12-13 21:00:13 +08:00
type BoldItalic struct {
BaseInline
2023-12-13 23:50:05 +08:00
// Symbol is "*" or "_".
2023-12-13 21:00:13 +08:00
Symbol string
Content string
}
var NodeTypeBoldItalic = NewNodeType("BoldItalic")
func (*BoldItalic) Type() NodeType {
return NodeTypeBoldItalic
}
2023-12-13 23:50:05 +08:00
func (n *BoldItalic) String() string {
return n.Type().String() + " " + n.Symbol + " " + n.Content
}
2023-12-13 09:06:47 +08:00
type Code struct {
BaseInline
Content string
}
var NodeTypeCode = NewNodeType("Code")
func (*Code) Type() NodeType {
return NodeTypeCode
}
2023-12-13 23:50:05 +08:00
func (n *Code) String() string {
return n.Type().String() + " " + n.Content
}
2023-12-13 09:06:47 +08:00
type Image struct {
BaseInline
AltText string
URL string
}
var NodeTypeImage = NewNodeType("Image")
func (*Image) Type() NodeType {
return NodeTypeImage
}
2023-12-13 23:50:05 +08:00
func (n *Image) String() string {
return n.Type().String() + " " + n.AltText + " " + n.URL
}
2023-12-13 09:06:47 +08:00
type Link struct {
BaseInline
Text string
URL string
}
var NodeTypeLink = NewNodeType("Link")
func (*Link) Type() NodeType {
return NodeTypeLink
}
2023-12-13 23:50:05 +08:00
func (n *Link) String() string {
return n.Type().String() + " " + n.Text + " " + n.URL
}
2023-12-13 21:00:13 +08:00
type Tag struct {
2023-12-13 09:06:47 +08:00
BaseInline
Content string
}
2023-12-13 21:00:13 +08:00
var NodeTypeTag = NewNodeType("Tag")
2023-12-13 09:06:47 +08:00
2023-12-13 21:00:13 +08:00
func (*Tag) Type() NodeType {
return NodeTypeTag
2023-12-13 09:06:47 +08:00
}
2023-12-13 23:50:05 +08:00
func (n *Tag) String() string {
return n.Type().String() + " " + n.Content
}
2023-12-13 21:00:13 +08:00
type Strikethrough struct {
2023-12-13 09:06:47 +08:00
BaseInline
Content string
}
2023-12-13 21:00:13 +08:00
var NodeTypeStrikethrough = NewNodeType("Strikethrough")
2023-12-13 09:06:47 +08:00
2023-12-13 21:00:13 +08:00
func (*Strikethrough) Type() NodeType {
return NodeTypeStrikethrough
2023-12-13 09:06:47 +08:00
}
2023-12-13 23:50:05 +08:00
func (n *Strikethrough) String() string {
return n.Type().String() + " " + n.Content
}