mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: implement gomark skeleton
This commit is contained in:
30
plugin/gomark/parser/text.go
Normal file
30
plugin/gomark/parser/text.go
Normal file
@ -0,0 +1,30 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"github.com/usememos/memos/plugin/gomark/ast"
|
||||
"github.com/usememos/memos/plugin/gomark/parser/tokenizer"
|
||||
)
|
||||
|
||||
type TextParser struct {
|
||||
Content string
|
||||
}
|
||||
|
||||
var defaultTextParser = &TextParser{}
|
||||
|
||||
func NewTextParser() *TextParser {
|
||||
return defaultTextParser
|
||||
}
|
||||
|
||||
func (*TextParser) Match(tokens []*tokenizer.Token) (int, bool) {
|
||||
if len(tokens) == 0 {
|
||||
return 0, false
|
||||
}
|
||||
return 1, true
|
||||
}
|
||||
|
||||
func (*TextParser) Parse(tokens []*tokenizer.Token) ast.Node {
|
||||
if len(tokens) == 0 {
|
||||
return ast.NewText("")
|
||||
}
|
||||
return ast.NewText(tokens[0].String())
|
||||
}
|
Reference in New Issue
Block a user