chore: update parser functions

This commit is contained in:
Steven 2023-12-16 10:38:05 +08:00
parent 47af632c79
commit aee0e31b0a
2 changed files with 11 additions and 3 deletions

View file

@ -37,10 +37,18 @@ var defaultBlockParsers = []BlockParser{
}
func Parse(tokens []*tokenizer.Token) ([]ast.Node, error) {
return ParseBlock(tokens)
}
func ParseBlock(tokens []*tokenizer.Token) ([]ast.Node, error) {
return ParseBlockWithParsers(tokens, defaultBlockParsers)
}
func ParseBlockWithParsers(tokens []*tokenizer.Token, blockParsers []BlockParser) ([]ast.Node, error) {
nodes := []ast.Node{}
var prevNode ast.Node
for len(tokens) > 0 {
for _, blockParser := range defaultBlockParsers {
for _, blockParser := range blockParsers {
size, matched := blockParser.Match(tokens)
if matched {
node, err := blockParser.Parse(tokens)

View file

@ -166,8 +166,8 @@ func generateMemoMetadata(memo *store.Memo, creator *store.User) string {
if len(description) == 0 {
description = memo.Content
}
if len(description) > 100 {
description = description[:100] + "..."
if len(description) > 200 {
description = description[:200] + "..."
}
}