chore: implement part of html renderer

This commit is contained in:
Steven
2023-12-13 23:50:05 +08:00
parent 453707d18c
commit 43ef9eaced
35 changed files with 449 additions and 91 deletions

View File

@ -1,6 +1,8 @@
package parser
import (
"errors"
"github.com/usememos/memos/plugin/gomark/ast"
"github.com/usememos/memos/plugin/gomark/parser/tokenizer"
)
@ -27,13 +29,13 @@ func (*HorizontalRuleParser) Match(tokens []*tokenizer.Token) (int, bool) {
return 3, true
}
func (p *HorizontalRuleParser) Parse(tokens []*tokenizer.Token) ast.Node {
func (p *HorizontalRuleParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
size, ok := p.Match(tokens)
if size == 0 || !ok {
return nil
return nil, errors.New("not matched")
}
return &ast.HorizontalRule{
Symbol: tokens[0].Type,
}
}, nil
}