Skip to content

Commit

Permalink
chore: fix auto link matcher
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Jan 28, 2024
1 parent ef73299 commit 55ecdae
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plugin/gomark/parser/auto_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ func (*AutoLinkParser) Match(tokens []*tokenizer.Token) (ast.Node, int) {
urlStr = tokenizer.Stringify(matchedTokens[1 : len(matchedTokens)-1])
isRawText = false
} else {
contentTokens := []*tokenizer.Token{}
for _, token := range matchedTokens {
if token.Type == tokenizer.Space {
break
}
contentTokens = append(contentTokens, token)
}
if len(contentTokens) == 0 {
return nil, 0
}

matchedTokens = contentTokens
u, err := url.Parse(tokenizer.Stringify(matchedTokens))
if err != nil || u.Scheme == "" || u.Host == "" {
return nil, 0
Expand Down

0 comments on commit 55ecdae

Please sign in to comment.