From 9f9fb49dd17235bd6b7b56fef2a7ac66121c7024 Mon Sep 17 00:00:00 2001 From: Christopher Fitzner Date: Mon, 12 Aug 2024 15:18:20 -0700 Subject: [PATCH] Update everything else --- go.mod | 2 +- go.sum | 4 +- vendor/github.com/yuin/goldmark/README.md | 39 ++++++++++++------- .../yuin/goldmark/extension/footnote.go | 24 ++++++------ .../yuin/goldmark/extension/linkify.go | 8 ++-- .../yuin/goldmark/extension/typographer.go | 4 +- .../yuin/goldmark/parser/html_block.go | 2 +- .../yuin/goldmark/parser/raw_html.go | 39 +++++++------------ .../yuin/goldmark/renderer/html/html.go | 9 ++++- vendor/github.com/yuin/goldmark/util/util.go | 2 +- vendor/modules.txt | 4 +- 11 files changed, 74 insertions(+), 63 deletions(-) diff --git a/go.mod b/go.mod index d78fe990..a5241eda 100644 --- a/go.mod +++ b/go.mod @@ -71,7 +71,7 @@ require ( github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/yuin/goldmark v1.6.0 // indirect + github.com/yuin/goldmark v1.7.1 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect github.com/zclconf/go-cty v1.14.3 // indirect golang.org/x/crypto v0.21.0 // indirect diff --git a/go.sum b/go.sum index fa566366..196f8118 100644 --- a/go.sum +++ b/go.sum @@ -208,8 +208,8 @@ github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= -github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= github.com/zclconf/go-cty v1.14.3 h1:1JXy1XroaGrzZuG6X9dt7HL6s9AwbY+l4UNL8o5B6ho= diff --git a/vendor/github.com/yuin/goldmark/README.md b/vendor/github.com/yuin/goldmark/README.md index 8d9d83f7..286ef3c1 100644 --- a/vendor/github.com/yuin/goldmark/README.md +++ b/vendor/github.com/yuin/goldmark/README.md @@ -8,7 +8,9 @@ goldmark > A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured. -goldmark is compliant with CommonMark 0.30. +goldmark is compliant with CommonMark 0.31.2. + +- [goldmark playground](https://yuin.github.io/goldmark/playground/) : Try goldmark online. This playground is built with WASM(5-10MB). Motivation ---------------------- @@ -260,7 +262,7 @@ You can override autolinking patterns via options. | Functional option | Type | Description | | ----------------- | ---- | ----------- | -| `extension.WithLinkifyAllowedProtocols` | `[][]byte` | List of allowed protocols such as `[][]byte{ []byte("http:") }` | +| `extension.WithLinkifyAllowedProtocols` | `[][]byte \| []string` | List of allowed protocols such as `[]string{ "http:" }` | | `extension.WithLinkifyURLRegexp` | `*regexp.Regexp` | Regexp that defines URLs, including protocols | | `extension.WithLinkifyWWWRegexp` | `*regexp.Regexp` | Regexp that defines URL starting with `www.`. This pattern corresponds to [the extended www autolink](https://github.github.com/gfm/#extended-www-autolink) | | `extension.WithLinkifyEmailRegexp` | `*regexp.Regexp` | Regexp that defines email addresses` | @@ -277,12 +279,12 @@ markdown := goldmark.New( ), goldmark.WithExtensions( extension.NewLinkify( - extension.WithLinkifyAllowedProtocols([][]byte{ - []byte("http:"), - []byte("https:"), + extension.WithLinkifyAllowedProtocols([]string{ + "http:", + "https:", }), extension.WithLinkifyURLRegexp( - xurls.Strict, + xurls.Strict(), ), ), ), @@ -297,13 +299,13 @@ This extension has some options: | Functional option | Type | Description | | ----------------- | ---- | ----------- | -| `extension.WithFootnoteIDPrefix` | `[]byte` | a prefix for the id attributes.| +| `extension.WithFootnoteIDPrefix` | `[]byte \| string` | a prefix for the id attributes.| | `extension.WithFootnoteIDPrefixFunction` | `func(gast.Node) []byte` | a function that determines the id attribute for given Node.| -| `extension.WithFootnoteLinkTitle` | `[]byte` | an optional title attribute for footnote links.| -| `extension.WithFootnoteBacklinkTitle` | `[]byte` | an optional title attribute for footnote backlinks. | -| `extension.WithFootnoteLinkClass` | `[]byte` | a class for footnote links. This defaults to `footnote-ref`. | -| `extension.WithFootnoteBacklinkClass` | `[]byte` | a class for footnote backlinks. This defaults to `footnote-backref`. | -| `extension.WithFootnoteBacklinkHTML` | `[]byte` | a class for footnote backlinks. This defaults to `↩︎`. | +| `extension.WithFootnoteLinkTitle` | `[]byte \| string` | an optional title attribute for footnote links.| +| `extension.WithFootnoteBacklinkTitle` | `[]byte \| string` | an optional title attribute for footnote backlinks. | +| `extension.WithFootnoteLinkClass` | `[]byte \| string` | a class for footnote links. This defaults to `footnote-ref`. | +| `extension.WithFootnoteBacklinkClass` | `[]byte \| string` | a class for footnote backlinks. This defaults to `footnote-backref`. | +| `extension.WithFootnoteBacklinkHTML` | `[]byte \| string` | a class for footnote backlinks. This defaults to `↩︎`. | Some options can have special substitutions. Occurrences of “^^” in the string will be replaced by the corresponding footnote number in the HTML output. Occurrences of “%%” will be replaced by a number for the reference (footnotes can have multiple references). @@ -319,7 +321,7 @@ for _, path := range files { markdown := goldmark.New( goldmark.WithExtensions( NewFootnote( - WithFootnoteIDPrefix([]byte(path)), + WithFootnoteIDPrefix(path), ), ), ) @@ -379,7 +381,7 @@ This extension provides additional options for CJK users. | Functional option | Type | Description | | ----------------- | ---- | ----------- | -| `extension.WithEastAsianLineBreaks` | `...extension.EastAsianLineBreaksStyle` | Soft line breaks are rendered as a newline. Some asian users will see it as an unnecessary space. With this option, soft line breaks between east asian wide characters will be ignored. | +| `extension.WithEastAsianLineBreaks` | `...extension.EastAsianLineBreaksStyle` | Soft line breaks are rendered as a newline. Some asian users will see it as an unnecessary space. With this option, soft line breaks between east asian wide characters will be ignored. This defaults to `EastAsianLineBreaksStyleSimple`. | | `extension.WithEscapedSpace` | `-` | Without spaces around an emphasis started with east asian punctuations, it is not interpreted as an emphasis(as defined in CommonMark spec). With this option, you can avoid this inconvenient behavior by putting 'not rendered' spaces around an emphasis like `太郎は\ **「こんにちわ」**\ といった`. | #### Styles of Line Breaking @@ -467,6 +469,7 @@ As you can see, goldmark's performance is on par with cmark's. Extensions -------------------- +### List of extensions - [goldmark-meta](https://github.com/yuin/goldmark-meta): A YAML metadata extension for the goldmark Markdown parser. @@ -490,6 +493,14 @@ Extensions - [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-enclave](https://github.com/quail-ink/goldmark-enclave): Adds support for embedding youtube/bilibili video, X's [oembed tweet](https://publish.twitter.com/), [tradingview](https://www.tradingview.com/widget/)'s chart, [quail](https://quail.ink)'s widget into the document. +- [goldmark-wiki-table](https://github.com/movsb/goldmark-wiki-table): Adds support for embedding Wiki Tables. +- [goldmark-tgmd](https://github.com/Mad-Pixels/goldmark-tgmd): A Telegram markdown renderer that can be passed to `goldmark.WithRenderer()`. + +### Loading extensions at runtime +[goldmark-dynamic](https://github.com/yuin/goldmark-dynamic) allows you to write a goldmark extension in Lua and load it at runtime without re-compilation. + +Please refer to [goldmark-dynamic](https://github.com/yuin/goldmark-dynamic) for details. goldmark internal(for extension developers) diff --git a/vendor/github.com/yuin/goldmark/extension/footnote.go b/vendor/github.com/yuin/goldmark/extension/footnote.go index d1b67aa7..2e225269 100644 --- a/vendor/github.com/yuin/goldmark/extension/footnote.go +++ b/vendor/github.com/yuin/goldmark/extension/footnote.go @@ -382,8 +382,8 @@ func (o *withFootnoteIDPrefix) SetFootnoteOption(c *FootnoteConfig) { } // WithFootnoteIDPrefix is a functional option that is a prefix for the id attributes generated by footnotes. -func WithFootnoteIDPrefix(a []byte) FootnoteOption { - return &withFootnoteIDPrefix{a} +func WithFootnoteIDPrefix[T []byte | string](a T) FootnoteOption { + return &withFootnoteIDPrefix{[]byte(a)} } const optFootnoteIDPrefixFunction renderer.OptionName = "FootnoteIDPrefixFunction" @@ -420,8 +420,8 @@ func (o *withFootnoteLinkTitle) SetFootnoteOption(c *FootnoteConfig) { } // WithFootnoteLinkTitle is a functional option that is an optional title attribute for footnote links. -func WithFootnoteLinkTitle(a []byte) FootnoteOption { - return &withFootnoteLinkTitle{a} +func WithFootnoteLinkTitle[T []byte | string](a T) FootnoteOption { + return &withFootnoteLinkTitle{[]byte(a)} } const optFootnoteBacklinkTitle renderer.OptionName = "FootnoteBacklinkTitle" @@ -439,8 +439,8 @@ func (o *withFootnoteBacklinkTitle) SetFootnoteOption(c *FootnoteConfig) { } // WithFootnoteBacklinkTitle is a functional option that is an optional title attribute for footnote backlinks. -func WithFootnoteBacklinkTitle(a []byte) FootnoteOption { - return &withFootnoteBacklinkTitle{a} +func WithFootnoteBacklinkTitle[T []byte | string](a T) FootnoteOption { + return &withFootnoteBacklinkTitle{[]byte(a)} } const optFootnoteLinkClass renderer.OptionName = "FootnoteLinkClass" @@ -458,8 +458,8 @@ func (o *withFootnoteLinkClass) SetFootnoteOption(c *FootnoteConfig) { } // WithFootnoteLinkClass is a functional option that is a class for footnote links. -func WithFootnoteLinkClass(a []byte) FootnoteOption { - return &withFootnoteLinkClass{a} +func WithFootnoteLinkClass[T []byte | string](a T) FootnoteOption { + return &withFootnoteLinkClass{[]byte(a)} } const optFootnoteBacklinkClass renderer.OptionName = "FootnoteBacklinkClass" @@ -477,8 +477,8 @@ func (o *withFootnoteBacklinkClass) SetFootnoteOption(c *FootnoteConfig) { } // WithFootnoteBacklinkClass is a functional option that is a class for footnote backlinks. -func WithFootnoteBacklinkClass(a []byte) FootnoteOption { - return &withFootnoteBacklinkClass{a} +func WithFootnoteBacklinkClass[T []byte | string](a T) FootnoteOption { + return &withFootnoteBacklinkClass{[]byte(a)} } const optFootnoteBacklinkHTML renderer.OptionName = "FootnoteBacklinkHTML" @@ -496,8 +496,8 @@ func (o *withFootnoteBacklinkHTML) SetFootnoteOption(c *FootnoteConfig) { } // WithFootnoteBacklinkHTML is an HTML content for footnote backlinks. -func WithFootnoteBacklinkHTML(a []byte) FootnoteOption { - return &withFootnoteBacklinkHTML{a} +func WithFootnoteBacklinkHTML[T []byte | string](a T) FootnoteOption { + return &withFootnoteBacklinkHTML{[]byte(a)} } // FootnoteHTMLRenderer is a renderer.NodeRenderer implementation that diff --git a/vendor/github.com/yuin/goldmark/extension/linkify.go b/vendor/github.com/yuin/goldmark/extension/linkify.go index 0f23e907..ad88933a 100644 --- a/vendor/github.com/yuin/goldmark/extension/linkify.go +++ b/vendor/github.com/yuin/goldmark/extension/linkify.go @@ -66,10 +66,12 @@ func (o *withLinkifyAllowedProtocols) SetLinkifyOption(p *LinkifyConfig) { // WithLinkifyAllowedProtocols is a functional option that specify allowed // protocols in autolinks. Each protocol must end with ':' like // 'http:' . -func WithLinkifyAllowedProtocols(value [][]byte) LinkifyOption { - return &withLinkifyAllowedProtocols{ - value: value, +func WithLinkifyAllowedProtocols[T []byte | string](value []T) LinkifyOption { + opt := &withLinkifyAllowedProtocols{} + for _, v := range value { + opt.value = append(opt.value, []byte(v)) } + return opt } type withLinkifyURLRegexp struct { diff --git a/vendor/github.com/yuin/goldmark/extension/typographer.go b/vendor/github.com/yuin/goldmark/extension/typographer.go index 259c4f72..44c15ebf 100644 --- a/vendor/github.com/yuin/goldmark/extension/typographer.go +++ b/vendor/github.com/yuin/goldmark/extension/typographer.go @@ -115,10 +115,10 @@ func (o *withTypographicSubstitutions) SetTypographerOption(p *TypographerConfig // WithTypographicSubstitutions is a functional otpion that specify replacement text // for punctuations. -func WithTypographicSubstitutions(values map[TypographicPunctuation][]byte) TypographerOption { +func WithTypographicSubstitutions[T []byte | string](values map[TypographicPunctuation]T) TypographerOption { replacements := newDefaultSubstitutions() for k, v := range values { - replacements[k] = v + replacements[k] = []byte(v) } return &withTypographicSubstitutions{replacements} diff --git a/vendor/github.com/yuin/goldmark/parser/html_block.go b/vendor/github.com/yuin/goldmark/parser/html_block.go index bf0258b5..09dc21f4 100644 --- a/vendor/github.com/yuin/goldmark/parser/html_block.go +++ b/vendor/github.com/yuin/goldmark/parser/html_block.go @@ -61,8 +61,8 @@ var allowedBlockTags = map[string]bool{ "option": true, "p": true, "param": true, + "search": true, "section": true, - "source": true, "summary": true, "table": true, "tbody": true, diff --git a/vendor/github.com/yuin/goldmark/parser/raw_html.go b/vendor/github.com/yuin/goldmark/parser/raw_html.go index 2b3dbc23..1d582a7f 100644 --- a/vendor/github.com/yuin/goldmark/parser/raw_html.go +++ b/vendor/github.com/yuin/goldmark/parser/raw_html.go @@ -58,47 +58,38 @@ var closeProcessingInstruction = []byte("?>") var openCDATA = []byte("") var closeDecl = []byte(">") -var emptyComment = []byte("") -var invalidComment1 = []byte("") -var invalidComment2 = []byte("") +var emptyComment1 = []byte("") +var emptyComment2 = []byte("") var openComment = []byte("") -var doubleHyphen = []byte("--") func (s *rawHTMLParser) parseComment(block text.Reader, pc Context) ast.Node { savedLine, savedSegment := block.Position() node := ast.NewRawHTML() line, segment := block.PeekLine() - if bytes.HasPrefix(line, emptyComment) { - node.Segments.Append(segment.WithStop(segment.Start + len(emptyComment))) - block.Advance(len(emptyComment)) + if bytes.HasPrefix(line, emptyComment1) { + node.Segments.Append(segment.WithStop(segment.Start + len(emptyComment1))) + block.Advance(len(emptyComment1)) return node } - if bytes.HasPrefix(line, invalidComment1) || bytes.HasPrefix(line, invalidComment2) { - return nil + if bytes.HasPrefix(line, emptyComment2) { + node.Segments.Append(segment.WithStop(segment.Start + len(emptyComment2))) + block.Advance(len(emptyComment2)) + return node } offset := len(openComment) line = line[offset:] for { - hindex := bytes.Index(line, doubleHyphen) - if hindex > -1 { - hindex += offset - } - index := bytes.Index(line, closeComment) + offset - if index > -1 && hindex == index { - if index == 0 || len(line) < 2 || line[index-offset-1] != '-' { - node.Segments.Append(segment.WithStop(segment.Start + index + len(closeComment))) - block.Advance(index + len(closeComment)) - return node - } - } - if hindex > 0 { - break + index := bytes.Index(line, closeComment) + if index > -1 { + node.Segments.Append(segment.WithStop(segment.Start + offset + index + len(closeComment))) + block.Advance(offset + index + len(closeComment)) + return node } + offset = 0 node.Segments.Append(segment) block.AdvanceLine() line, segment = block.PeekLine() - offset = 0 if line == nil { break } diff --git a/vendor/github.com/yuin/goldmark/renderer/html/html.go b/vendor/github.com/yuin/goldmark/renderer/html/html.go index 8738c2a1..75ac6dbf 100644 --- a/vendor/github.com/yuin/goldmark/renderer/html/html.go +++ b/vendor/github.com/yuin/goldmark/renderer/html/html.go @@ -786,7 +786,14 @@ func RenderAttributes(w util.BufWriter, node ast.Node, filter util.BytesFilter) _, _ = w.Write(attr.Name) _, _ = w.WriteString(`="`) // TODO: convert numeric values to strings - _, _ = w.Write(util.EscapeHTML(attr.Value.([]byte))) + var value []byte + switch typed := attr.Value.(type) { + case []byte: + value = typed + case string: + value = util.StringToReadOnlyBytes(typed) + } + _, _ = w.Write(util.EscapeHTML(value)) _ = w.WriteByte('"') } } diff --git a/vendor/github.com/yuin/goldmark/util/util.go b/vendor/github.com/yuin/goldmark/util/util.go index 9bf09adf..e2c92c6b 100644 --- a/vendor/github.com/yuin/goldmark/util/util.go +++ b/vendor/github.com/yuin/goldmark/util/util.go @@ -808,7 +808,7 @@ func IsPunct(c byte) bool { // IsPunctRune returns true if the given rune is a punctuation, otherwise false. func IsPunctRune(r rune) bool { - return int32(r) <= 256 && IsPunct(byte(r)) || unicode.IsPunct(r) + return unicode.IsSymbol(r) || unicode.IsPunct(r) } // IsSpace returns true if the given character is a space, otherwise false. diff --git a/vendor/modules.txt b/vendor/modules.txt index 82a8d30f..65f64034 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -359,8 +359,8 @@ github.com/vmihailenco/msgpack/v5/msgpcode github.com/vmihailenco/tagparser/v2 github.com/vmihailenco/tagparser/v2/internal github.com/vmihailenco/tagparser/v2/internal/parser -# github.com/yuin/goldmark v1.6.0 -## explicit; go 1.18 +# github.com/yuin/goldmark v1.7.1 +## explicit; go 1.19 github.com/yuin/goldmark github.com/yuin/goldmark/ast github.com/yuin/goldmark/extension