mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: implement paragraph and italic parsers (#1725)
This commit is contained in:
30
plugin/gomark/parser/paragraph.go
Normal file
30
plugin/gomark/parser/paragraph.go
Normal file
@ -0,0 +1,30 @@
|
||||
package parser
|
||||
|
||||
import "github.com/usememos/memos/plugin/gomark/parser/tokenizer"
|
||||
|
||||
type ParagraphParser struct {
|
||||
ContentTokens []*tokenizer.Token
|
||||
}
|
||||
|
||||
func NewParagraphParser() *ParagraphParser {
|
||||
return &ParagraphParser{}
|
||||
}
|
||||
|
||||
func (*ParagraphParser) Match(tokens []*tokenizer.Token) *ParagraphParser {
|
||||
contentTokens := []*tokenizer.Token{}
|
||||
cursor := 0
|
||||
for ; cursor < len(tokens); cursor++ {
|
||||
token := tokens[cursor]
|
||||
if token.Type == tokenizer.Newline {
|
||||
break
|
||||
}
|
||||
contentTokens = append(contentTokens, token)
|
||||
}
|
||||
if len(contentTokens) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &ParagraphParser{
|
||||
ContentTokens: contentTokens,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user