summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-12-31 14:48:12 +0100
committerGitHub <noreply@github.com>2020-12-31 14:48:12 +0100
commit4f20ebead36876a88391bf033d1de3e4cf0228da (patch)
tree70b6fd79c6a5e00c958c29a7bd3926f074e76ba6 /vendor/github.com/mattermost/mattermost-server/v5/utils/markdown
parenta9f89dbc645aafc68daa9fc8d589f55104b535c7 (diff)
downloadmatterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.tar.gz
matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.tar.bz2
matterbridge-msglm-4f20ebead36876a88391bf033d1de3e4cf0228da.zip
Update vendor for next release (#1343)
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/utils/markdown')
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go12
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/blocks.go13
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/inlines.go2
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/lines.go7
-rw-r--r--vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/markdown.go3
5 files changed, 19 insertions, 18 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go
index 14180836..d06ada66 100644
--- a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go
+++ b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/autolink.go
@@ -14,6 +14,7 @@ import (
var (
DefaultUrlSchemes = []string{"http", "https", "ftp", "mailto", "tel"}
+ wwwAutoLinkRegex = regexp.MustCompile(`^www\d{0,3}\.`)
)
// Given a string with a w at the given position, tries to parse and return a range containing a www link.
@@ -30,7 +31,7 @@ func parseWWWAutolink(data string, position int) (Range, bool) {
}
// Check that this starts with www
- if len(data)-position < 4 || !regexp.MustCompile(`^www\d{0,3}\.`).MatchString(data[position:]) {
+ if len(data)-position < 4 || !wwwAutoLinkRegex.MatchString(data[position:]) {
return Range{}, false
}
@@ -59,9 +60,8 @@ func isAllowedBeforeWWWLink(c byte) bool {
switch c {
case '*', '_', '~', ')':
return true
- default:
- return false
}
+ return false
}
// Given a string with a : at the given position, tried to parse and return a range containing a URL scheme
@@ -153,9 +153,8 @@ func checkDomain(data string, allowShort bool) int {
// this is called from parseWWWAutolink
if foundPeriod {
return i
- } else {
- return 0
}
+ return 0
}
// Returns true if the provided link starts with a valid character for a domain name. Equivalent to
@@ -251,7 +250,6 @@ func canEndAutolink(c rune) bool {
switch c {
case '?', '!', '.', ',', ':', '*', '_', '~', '\'', '"':
return false
- default:
- return true
}
+ return true
}
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/blocks.go b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/blocks.go
index 44ee178d..607356e0 100644
--- a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/blocks.go
+++ b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/blocks.go
@@ -37,13 +37,14 @@ type Range struct {
End int
}
-func closeBlocks(blocks []Block, referenceDefinitions *[]*ReferenceDefinition) {
+func closeBlocks(blocks []Block, referenceDefinitions []*ReferenceDefinition) []*ReferenceDefinition {
for _, block := range blocks {
block.Close()
if p, ok := block.(*Paragraph); ok && len(p.ReferenceDefinitions) > 0 {
- *referenceDefinitions = append(*referenceDefinitions, p.ReferenceDefinitions...)
+ referenceDefinitions = append(referenceDefinitions, p.ReferenceDefinitions...)
}
}
+ return referenceDefinitions
}
func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefinition) {
@@ -78,7 +79,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
for i := lastMatchIndex; i >= 0; i-- {
if container, ok := openBlocks[i].(ContainerBlock); ok {
if addedBlocks := container.AddChild(newBlocks); addedBlocks != nil {
- closeBlocks(openBlocks[i+1:], &referenceDefinitions)
+ referenceDefinitions = closeBlocks(openBlocks[i+1:], referenceDefinitions)
openBlocks = openBlocks[:i+1]
openBlocks = append(openBlocks, addedBlocks...)
didAdd = true
@@ -98,7 +99,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
continue
}
- closeBlocks(openBlocks[lastMatchIndex+1:], &referenceDefinitions)
+ referenceDefinitions = closeBlocks(openBlocks[lastMatchIndex+1:], referenceDefinitions)
openBlocks = openBlocks[:lastMatchIndex+1]
if openBlocks[lastMatchIndex].AddLine(indentation, r) {
@@ -109,7 +110,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
for i := lastMatchIndex; i >= 0; i-- {
if container, ok := openBlocks[i].(ContainerBlock); ok {
if newBlocks := container.AddChild([]Block{paragraph}); newBlocks != nil {
- closeBlocks(openBlocks[i+1:], &referenceDefinitions)
+ referenceDefinitions = closeBlocks(openBlocks[i+1:], referenceDefinitions)
openBlocks = openBlocks[:i+1]
openBlocks = append(openBlocks, newBlocks...)
break
@@ -119,7 +120,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
}
}
- closeBlocks(openBlocks, &referenceDefinitions)
+ referenceDefinitions = closeBlocks(openBlocks, referenceDefinitions)
return document, referenceDefinitions
}
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/inlines.go b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/inlines.go
index 4303607f..a67f2f04 100644
--- a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/inlines.go
+++ b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/inlines.go
@@ -595,7 +595,7 @@ func ParseInlines(markdown string, ranges []Range, referenceDefinitions []*Refer
}
func MergeInlineText(inlines []Inline) []Inline {
- var ret []Inline
+ ret := inlines[:0]
for i, v := range inlines {
// always add first node
if i == 0 {
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/lines.go b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/lines.go
index a0a64491..a67ec976 100644
--- a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/lines.go
+++ b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/lines.go
@@ -3,13 +3,16 @@
package markdown
+import "strings"
+
type Line struct {
Range
}
-func ParseLines(markdown string) (lines []Line) {
+func ParseLines(markdown string) []Line {
lineStartPosition := 0
isAfterCarriageReturn := false
+ lines := make([]Line, 0, strings.Count(markdown, "\n"))
for position, r := range markdown {
if r == '\n' {
lines = append(lines, Line{Range{lineStartPosition, position + 1}})
@@ -23,5 +26,5 @@ func ParseLines(markdown string) (lines []Line) {
if lineStartPosition < len(markdown) {
lines = append(lines, Line{Range{lineStartPosition, len(markdown)}})
}
- return
+ return lines
}
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/markdown.go b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/markdown.go
index a9879cee..5ccdad8c 100644
--- a/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/markdown.go
+++ b/vendor/github.com/mattermost/mattermost-server/v5/utils/markdown/markdown.go
@@ -23,9 +23,8 @@ func isWhitespace(c rune) bool {
switch c {
case ' ', '\t', '\n', '\u000b', '\u000c', '\r':
return true
- default:
- return false
}
+ return false
}
func isWhitespaceByte(c byte) bool {