diff options
Diffstat (limited to 'vendor/github.com/yuin')
-rw-r--r-- | vendor/github.com/yuin/goldmark/README.md | 4 | ||||
-rw-r--r-- | vendor/github.com/yuin/goldmark/parser/raw_html.go | 6 | ||||
-rw-r--r-- | vendor/github.com/yuin/goldmark/renderer/html/html.go | 16 | ||||
-rw-r--r-- | vendor/github.com/yuin/goldmark/text/reader.go | 21 |
4 files changed, 31 insertions, 16 deletions
diff --git a/vendor/github.com/yuin/goldmark/README.md b/vendor/github.com/yuin/goldmark/README.md index 6244b4792..eaaf27e38 100644 --- a/vendor/github.com/yuin/goldmark/README.md +++ b/vendor/github.com/yuin/goldmark/README.md @@ -440,6 +440,9 @@ Extensions - [goldmark-pdf](https://github.com/stephenafamo/goldmark-pdf): A PDF renderer that can be passed to `goldmark.WithRenderer()`. - [goldmark-hashtag](https://github.com/abhinav/goldmark-hashtag): Adds support for `#hashtag`-based tagging to goldmark. - [goldmark-wikilink](https://github.com/abhinav/goldmark-wikilink): Adds support for `[[wiki]]`-style links to goldmark. +- [goldmark-anchor](https://github.com/abhinav/goldmark-anchor): Adds anchors (permalinks) next to all headers in a document. +- [goldmark-figure](https://github.com/mangoumbrella/goldmark-figure): Adds support for rendering paragraphs starting with an image to `<figure>` elements. +- [goldmark-frontmatter](https://github.com/abhinav/goldmark-frontmatter): Adds support for YAML, TOML, and custom front matter to documents. - [goldmark-toc](https://github.com/abhinav/goldmark-toc): Adds support for generating tables-of-contents for goldmark documents. - [goldmark-mermaid](https://github.com/abhinav/goldmark-mermaid): Adds support for rendering [Mermaid](https://mermaid-js.github.io/mermaid/) diagrams in goldmark documents. - [goldmark-pikchr](https://github.com/jchenry/goldmark-pikchr): Adds support for rendering [Pikchr](https://pikchr.org/home/doc/trunk/homepage.md) diagrams in goldmark documents. @@ -448,6 +451,7 @@ Extensions - [goldmark-fences](https://github.com/stefanfritsch/goldmark-fences): Support for pandoc-style [fenced divs](https://pandoc.org/MANUAL.html#divs-and-spans) in goldmark. - [goldmark-d2](https://github.com/FurqanSoftware/goldmark-d2): Adds support for [D2](https://d2lang.com/) diagrams. - [goldmark-katex](https://github.com/FurqanSoftware/goldmark-katex): Adds support for [KaTeX](https://katex.org/) math and equations. +- [goldmark-img64](https://github.com/tenkoh/goldmark-img64): Adds support for embedding images into the document as DataURL (base64 encoded). goldmark internal(for extension developers) diff --git a/vendor/github.com/yuin/goldmark/parser/raw_html.go b/vendor/github.com/yuin/goldmark/parser/raw_html.go index 55b9a9967..cae88a66e 100644 --- a/vendor/github.com/yuin/goldmark/parser/raw_html.go +++ b/vendor/github.com/yuin/goldmark/parser/raw_html.go @@ -48,10 +48,10 @@ func (s *rawHTMLParser) Parse(parent ast.Node, block text.Reader, pc Context) as } var tagnamePattern = `([A-Za-z][A-Za-z0-9-]*)` - +var spaceOrOneNewline = `(?:[ \t]|(?:\r\n|\n){0,1})` var attributePattern = `(?:[\r\n \t]+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:[\r\n \t]*=[\r\n \t]*(?:[^\"'=<>` + "`" + `\x00-\x20]+|'[^']*'|"[^"]*"))?)` -var openTagRegexp = regexp.MustCompile("^<" + tagnamePattern + attributePattern + `*[ \t]*/?>`) -var closeTagRegexp = regexp.MustCompile("^</" + tagnamePattern + `\s*>`) +var openTagRegexp = regexp.MustCompile("^<" + tagnamePattern + attributePattern + `*` + spaceOrOneNewline + `*/?>`) +var closeTagRegexp = regexp.MustCompile("^</" + tagnamePattern + spaceOrOneNewline + `*>`) var openProcessingInstruction = []byte("<?") var closeProcessingInstruction = []byte("?>") diff --git a/vendor/github.com/yuin/goldmark/renderer/html/html.go b/vendor/github.com/yuin/goldmark/renderer/html/html.go index 7bf2ab808..72f7e74d8 100644 --- a/vendor/github.com/yuin/goldmark/renderer/html/html.go +++ b/vendor/github.com/yuin/goldmark/renderer/html/html.go @@ -901,20 +901,24 @@ var bVb = []byte("vbscript:") var bFile = []byte("file:") var bData = []byte("data:") +func hasPrefix(s, prefix []byte) bool { + return len(s) >= len(prefix) && bytes.Equal(bytes.ToLower(s[0:len(prefix)]), bytes.ToLower(prefix)) +} + // IsDangerousURL returns true if the given url seems a potentially dangerous url, // otherwise false. func IsDangerousURL(url []byte) bool { - if bytes.HasPrefix(url, bDataImage) && len(url) >= 11 { + if hasPrefix(url, bDataImage) && len(url) >= 11 { v := url[11:] - if bytes.HasPrefix(v, bPng) || bytes.HasPrefix(v, bGif) || - bytes.HasPrefix(v, bJpeg) || bytes.HasPrefix(v, bWebp) || - bytes.HasPrefix(v, bSvg) { + if hasPrefix(v, bPng) || hasPrefix(v, bGif) || + hasPrefix(v, bJpeg) || hasPrefix(v, bWebp) || + hasPrefix(v, bSvg) { return false } return true } - return bytes.HasPrefix(url, bJs) || bytes.HasPrefix(url, bVb) || - bytes.HasPrefix(url, bFile) || bytes.HasPrefix(url, bData) + return hasPrefix(url, bJs) || hasPrefix(url, bVb) || + hasPrefix(url, bFile) || hasPrefix(url, bData) } func nodeToHTMLText(n ast.Node, source []byte) []byte { diff --git a/vendor/github.com/yuin/goldmark/text/reader.go b/vendor/github.com/yuin/goldmark/text/reader.go index 319f1c8b8..d43690a19 100644 --- a/vendor/github.com/yuin/goldmark/text/reader.go +++ b/vendor/github.com/yuin/goldmark/text/reader.go @@ -1,6 +1,7 @@ package text import ( + "bytes" "io" "regexp" "unicode/utf8" @@ -537,24 +538,30 @@ func matchReader(r Reader, reg *regexp.Regexp) bool { } func findSubMatchReader(r Reader, reg *regexp.Regexp) [][]byte { - oldline, oldseg := r.Position() + oldLine, oldSeg := r.Position() match := reg.FindReaderSubmatchIndex(r) - r.SetPosition(oldline, oldseg) + r.SetPosition(oldLine, oldSeg) if match == nil { return nil } - runes := make([]rune, 0, match[1]-match[0]) + var bb bytes.Buffer + bb.Grow(match[1] - match[0]) for i := 0; i < match[1]; { r, size, _ := readRuneReader(r) i += size - runes = append(runes, r) + bb.WriteRune(r) } - result := [][]byte{} + bs := bb.Bytes() + var result [][]byte for i := 0; i < len(match); i += 2 { - result = append(result, []byte(string(runes[match[i]:match[i+1]]))) + if match[i] < 0 { + result = append(result, []byte{}) + continue + } + result = append(result, bs[match[i]:match[i+1]]) } - r.SetPosition(oldline, oldseg) + r.SetPosition(oldLine, oldSeg) r.Advance(match[1] - match[0]) return result } |