mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: implement part of html renderer
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package ast
|
||||
|
||||
type BaseInline struct {
|
||||
Node
|
||||
BaseNode
|
||||
}
|
||||
|
||||
type Text struct {
|
||||
@@ -16,10 +16,14 @@ func (*Text) Type() NodeType {
|
||||
return NodeTypeText
|
||||
}
|
||||
|
||||
func (n *Text) String() string {
|
||||
return n.Type().String() + " " + n.Content
|
||||
}
|
||||
|
||||
type Bold struct {
|
||||
BaseInline
|
||||
|
||||
// Symbol is "*" or "_"
|
||||
// Symbol is "*" or "_".
|
||||
Symbol string
|
||||
Content string
|
||||
}
|
||||
@@ -30,10 +34,14 @@ func (*Bold) Type() NodeType {
|
||||
return NodeTypeBold
|
||||
}
|
||||
|
||||
func (n *Bold) String() string {
|
||||
return n.Type().String() + " " + n.Symbol + " " + n.Content
|
||||
}
|
||||
|
||||
type Italic struct {
|
||||
BaseInline
|
||||
|
||||
// Symbol is "*" or "_"
|
||||
// Symbol is "*" or "_".
|
||||
Symbol string
|
||||
Content string
|
||||
}
|
||||
@@ -44,10 +52,14 @@ func (*Italic) Type() NodeType {
|
||||
return NodeTypeItalic
|
||||
}
|
||||
|
||||
func (n *Italic) String() string {
|
||||
return n.Type().String() + " " + n.Symbol + " " + n.Content
|
||||
}
|
||||
|
||||
type BoldItalic struct {
|
||||
BaseInline
|
||||
|
||||
// Symbol is "*" or "_"
|
||||
// Symbol is "*" or "_".
|
||||
Symbol string
|
||||
Content string
|
||||
}
|
||||
@@ -58,6 +70,10 @@ func (*BoldItalic) Type() NodeType {
|
||||
return NodeTypeBoldItalic
|
||||
}
|
||||
|
||||
func (n *BoldItalic) String() string {
|
||||
return n.Type().String() + " " + n.Symbol + " " + n.Content
|
||||
}
|
||||
|
||||
type Code struct {
|
||||
BaseInline
|
||||
|
||||
@@ -70,6 +86,10 @@ func (*Code) Type() NodeType {
|
||||
return NodeTypeCode
|
||||
}
|
||||
|
||||
func (n *Code) String() string {
|
||||
return n.Type().String() + " " + n.Content
|
||||
}
|
||||
|
||||
type Image struct {
|
||||
BaseInline
|
||||
|
||||
@@ -83,6 +103,10 @@ func (*Image) Type() NodeType {
|
||||
return NodeTypeImage
|
||||
}
|
||||
|
||||
func (n *Image) String() string {
|
||||
return n.Type().String() + " " + n.AltText + " " + n.URL
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
BaseInline
|
||||
|
||||
@@ -96,6 +120,10 @@ func (*Link) Type() NodeType {
|
||||
return NodeTypeLink
|
||||
}
|
||||
|
||||
func (n *Link) String() string {
|
||||
return n.Type().String() + " " + n.Text + " " + n.URL
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
BaseInline
|
||||
|
||||
@@ -108,6 +136,10 @@ func (*Tag) Type() NodeType {
|
||||
return NodeTypeTag
|
||||
}
|
||||
|
||||
func (n *Tag) String() string {
|
||||
return n.Type().String() + " " + n.Content
|
||||
}
|
||||
|
||||
type Strikethrough struct {
|
||||
BaseInline
|
||||
|
||||
@@ -119,3 +151,7 @@ var NodeTypeStrikethrough = NewNodeType("Strikethrough")
|
||||
func (*Strikethrough) Type() NodeType {
|
||||
return NodeTypeStrikethrough
|
||||
}
|
||||
|
||||
func (n *Strikethrough) String() string {
|
||||
return n.Type().String() + " " + n.Content
|
||||
}
|
||||
|
Reference in New Issue
Block a user