summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/gomarkdown/markdown/parser/inline.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-07-18 17:27:41 +0200
committerGitHub <noreply@github.com>2020-07-18 17:27:41 +0200
commit23d8742f0d95096b92f11729fb47f86ac3b68d43 (patch)
tree7b8acb02b051ae06e5454fda4a9d5118428fe016 /vendor/github.com/gomarkdown/markdown/parser/inline.go
parent3b6a8be07b9422714db30fb50977f342057febf3 (diff)
downloadmatterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.gz
matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.tar.bz2
matterbridge-msglm-23d8742f0d95096b92f11729fb47f86ac3b68d43.zip
Update dependencies for 1.18.0 release (#1175)
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown/parser/inline.go')
-rw-r--r--vendor/github.com/gomarkdown/markdown/parser/inline.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/parser/inline.go b/vendor/github.com/gomarkdown/markdown/parser/inline.go
index 2a8ac77c..9bb5b30b 100644
--- a/vendor/github.com/gomarkdown/markdown/parser/inline.go
+++ b/vendor/github.com/gomarkdown/markdown/parser/inline.go
@@ -326,6 +326,7 @@ func link(p *Parser, data []byte, offset int) (int, ast.Node) {
i = skipSpace(data, i)
linkB := i
+ brace := 0
// look for link end: ' " )
findlinkend:
@@ -334,7 +335,18 @@ func link(p *Parser, data []byte, offset int) (int, ast.Node) {
case data[i] == '\\':
i += 2
- case data[i] == ')' || data[i] == '\'' || data[i] == '"':
+ case data[i] == '(':
+ brace++
+ i++
+
+ case data[i] == ')':
+ if brace <= 0 {
+ break findlinkend
+ }
+ brace--
+ i++
+
+ case data[i] == '\'' || data[i] == '"':
break findlinkend
default:
@@ -352,19 +364,21 @@ func link(p *Parser, data []byte, offset int) (int, ast.Node) {
if data[i] == '\'' || data[i] == '"' {
i++
titleB = i
+ titleEndCharFound := false
findtitleend:
for i < len(data) {
switch {
case data[i] == '\\':
- i += 2
+ i++
- case data[i] == ')':
- break findtitleend
+ case data[i] == data[titleB-1]: // matching title delimiter
+ titleEndCharFound = true
- default:
- i++
+ case titleEndCharFound && data[i] == ')':
+ break findtitleend
}
+ i++
}
if i >= len(data) {