mirror of
https://github.com/usememos/memos.git
synced 2024-12-26 15:13:10 +08:00
chore: update parser functions
This commit is contained in:
parent
47af632c79
commit
aee0e31b0a
2 changed files with 11 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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] + "..."
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue