From 23d8742f0d95096b92f11729fb47f86ac3b68d43 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 18 Jul 2020 17:27:41 +0200 Subject: Update dependencies for 1.18.0 release (#1175) --- .../gomarkdown/markdown/html/renderer.go | 10 +++++++-- .../gomarkdown/markdown/parser/inline.go | 26 +++++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'vendor/github.com/gomarkdown/markdown') diff --git a/vendor/github.com/gomarkdown/markdown/html/renderer.go b/vendor/github.com/gomarkdown/markdown/html/renderer.go index f0e10a7f..01e0deec 100644 --- a/vendor/github.com/gomarkdown/markdown/html/renderer.go +++ b/vendor/github.com/gomarkdown/markdown/html/renderer.go @@ -28,6 +28,7 @@ const ( Safelink // Only link to trusted protocols NofollowLinks // Only link with rel="nofollow" NoreferrerLinks // Only link with rel="noreferrer" + NoopenerLinks // Only link with rel="noopener" HrefTargetBlank // Add a blank target CompletePage // Generate a complete HTML page UseXHTML // Generate XHTML output instead of HTML @@ -295,6 +296,9 @@ func appendLinkAttrs(attrs []string, flags Flags, link []byte) []string { if flags&NoreferrerLinks != 0 { val = append(val, "noreferrer") } + if flags&NoopenerLinks != 0 { + val = append(val, "noopener") + } if flags&HrefTargetBlank != 0 { attrs = append(attrs, `target="_blank"`) } @@ -1110,7 +1114,9 @@ func (r *Renderer) writeTOC(w io.Writer, doc ast.Node) { buf.WriteString("") return ast.GoToNext } - nodeData.HeadingID = fmt.Sprintf("toc_%d", headingCount) + if nodeData.HeadingID == "" { + nodeData.HeadingID = fmt.Sprintf("toc_%d", headingCount) + } if nodeData.Level == tocLevel { buf.WriteString("\n\n
  • ") } else if nodeData.Level < tocLevel { @@ -1126,7 +1132,7 @@ func (r *Renderer) writeTOC(w io.Writer, doc ast.Node) { } } - fmt.Fprintf(&buf, ``, headingCount) + fmt.Fprintf(&buf, ``, nodeData.HeadingID) headingCount++ return ast.GoToNext } 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) { -- cgit v1.2.3