diff options
author | Wim <wim@42.be> | 2022-09-05 21:00:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-05 21:00:54 +0200 |
commit | fda05f22629156cc2eae130b501ebced2261ab42 (patch) | |
tree | b9761fb5202ab476b11c1136a5bea69df0dd0f83 /vendor/github.com/gomarkdown/markdown/html | |
parent | 7abf1a5884bfba9ac19df26495924d86613874f3 (diff) | |
download | matterbridge-msglm-fda05f22629156cc2eae130b501ebced2261ab42.tar.gz matterbridge-msglm-fda05f22629156cc2eae130b501ebced2261ab42.tar.bz2 matterbridge-msglm-fda05f22629156cc2eae130b501ebced2261ab42.zip |
Update dependencies and fix whatsmeow API changes (#1887)
* Update dependencies
* Fix whatsmau API changes
Diffstat (limited to 'vendor/github.com/gomarkdown/markdown/html')
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/html/renderer.go | 42 | ||||
-rw-r--r-- | vendor/github.com/gomarkdown/markdown/html/smartypants.go | 8 |
2 files changed, 20 insertions, 30 deletions
diff --git a/vendor/github.com/gomarkdown/markdown/html/renderer.go b/vendor/github.com/gomarkdown/markdown/html/renderer.go index 875debe3..fc63c5fe 100644 --- a/vendor/github.com/gomarkdown/markdown/html/renderer.go +++ b/vendor/github.com/gomarkdown/markdown/html/renderer.go @@ -11,7 +11,6 @@ import ( "strings" "github.com/gomarkdown/markdown/ast" - "github.com/gomarkdown/markdown/internal/valid" "github.com/gomarkdown/markdown/parser" ) @@ -133,7 +132,9 @@ type Renderer struct { // if > 0, will strip html tags in Out and Outs DisableTags int - // TODO: documentation + // IsSafeURLOverride allows overriding the default URL matcher. URL is + // safe if the overriding function returns true. Can be used to extend + // the default list of safe URLs. IsSafeURLOverride func(url []byte) bool sr *SPRenderer @@ -216,6 +217,11 @@ func NewRenderer(opts RendererOptions) *Renderer { } func isRelativeLink(link []byte) (yes bool) { + // empty links considerd relative + if len(link) == 0 { + return true + } + // a tag begin with '#' if link[0] == '#' { return true @@ -245,6 +251,9 @@ func isRelativeLink(link []byte) (yes bool) { } func (r *Renderer) addAbsPrefix(link []byte) []byte { + if len(link) == 0 { + return link + } if r.opts.AbsolutePrefix != "" && isRelativeLink(link) && link[0] != '.' { newDest := r.opts.AbsolutePrefix if link[0] != '/' { @@ -291,7 +300,7 @@ func needSkipLink(r *Renderer, dest []byte) bool { } isSafeURL := r.IsSafeURLOverride if isSafeURL == nil { - isSafeURL = valid.IsSafeURL + isSafeURL = parser.IsSafeURL } return flags&Safelink != 0 && !isSafeURL(dest) && !isMailto(dest) } @@ -1269,33 +1278,6 @@ func slugify(in []byte) []byte { return out[a : b+1] } -// TODO: move to internal package -// isAlnum returns true if c is a digit or letter -// TODO: check when this is looking for ASCII alnum and when it should use unicode -func isAlnum(c byte) bool { - return (c >= '0' && c <= '9') || isLetter(c) -} - -// isSpace returns true if c is a white-space charactr -func isSpace(c byte) bool { - return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v' -} - -// isLetter returns true if c is ascii letter -func isLetter(c byte) bool { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') -} - -// isPunctuation returns true if c is a punctuation symbol. -func isPunctuation(c byte) bool { - for _, r := range []byte("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~") { - if c == r { - return true - } - } - return false -} - // BlockAttrs takes a node and checks if it has block level attributes set. If so it // will return a slice each containing a "key=value(s)" string. func BlockAttrs(node ast.Node) []string { diff --git a/vendor/github.com/gomarkdown/markdown/html/smartypants.go b/vendor/github.com/gomarkdown/markdown/html/smartypants.go index a09866b0..706e4ff1 100644 --- a/vendor/github.com/gomarkdown/markdown/html/smartypants.go +++ b/vendor/github.com/gomarkdown/markdown/html/smartypants.go @@ -3,10 +3,18 @@ package html import ( "bytes" "io" + + "github.com/gomarkdown/markdown/parser" ) // SmartyPants rendering +var ( + isSpace = parser.IsSpace + isAlnum = parser.IsAlnum + isPunctuation = parser.IsPunctuation +) + // SPRenderer is a struct containing state of a Smartypants renderer. type SPRenderer struct { inSingleQuote bool |