build(deps): migrate to goldmark v2

This commit is contained in:
ayn2op 2026-10-16 00:13:26 -04:00
parent 2d698f0c7e
commit 3b28429a37
5 changed files with 32 additions and 32 deletions

6
go.mod
View file

@ -14,7 +14,7 @@ replace github.com/bogdanfinn/fhttp => github.com/ayn2op/fhttp v0.6.10-0.2026101
require ( require (
github.com/BurntSushi/toml v1.6.0 github.com/BurntSushi/toml v1.6.0
github.com/alecthomas/chroma/v2 v2.27.0 github.com/alecthomas/chroma/v2 v2.27.0
github.com/ayn2op/arikawa/v3 v3.0.0-20261014035141-32b58d8f3755 github.com/ayn2op/arikawa/v3 v3.0.0-20261016043052-54a68a54e42e
github.com/ayn2op/ningen/v3 v3.0.1-0.20261014035153-5e43590a1426 github.com/ayn2op/ningen/v3 v3.0.1-0.20261014035153-5e43590a1426
github.com/ayn2op/tview v0.0.0-20261015233535-ab884c65f4fe github.com/ayn2op/tview v0.0.0-20261015233535-ab884c65f4fe
github.com/bogdanfinn/fhttp v0.6.9 github.com/bogdanfinn/fhttp v0.6.9
@ -30,7 +30,7 @@ require (
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/thomas-vilte/dave-go v0.5.1 github.com/thomas-vilte/dave-go v0.5.1
github.com/tphakala/go-opus v1.2.1 github.com/tphakala/go-opus v1.2.1
github.com/yuin/goldmark v1.8.6 github.com/yuin/goldmark/v2 v2.1.6
github.com/zalando/go-keyring v0.2.8 github.com/zalando/go-keyring v0.2.8
golang.design/x/clipboard v0.11.0 golang.design/x/clipboard v0.11.0
golang.org/x/image v0.47.0 golang.org/x/image v0.47.0
@ -50,7 +50,7 @@ require (
github.com/danieljoos/wincred v1.2.3 // indirect github.com/danieljoos/wincred v1.2.3 // indirect
github.com/dchest/jsmin v1.0.0 // indirect github.com/dchest/jsmin v1.0.0 // indirect
github.com/disgoorg/godave v0.3.0 // indirect github.com/disgoorg/godave v0.3.0 // indirect
github.com/dlclark/regexp2/v2 v2.8.4 // indirect github.com/dlclark/regexp2/v2 v2.9.0 // indirect
github.com/ebitengine/purego v0.11.1 // indirect github.com/ebitengine/purego v0.11.1 // indirect
github.com/gdamore/encoding v1.0.1 // indirect github.com/gdamore/encoding v1.0.1 // indirect
github.com/godbus/dbus/v5 v5.2.4 // indirect github.com/godbus/dbus/v5 v5.2.4 // indirect

12
go.sum
View file

@ -10,8 +10,8 @@ github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/andybalholm/brotli v1.2.6 h1:ftYnfj6usCp+UGV5kSJ3+chpMQgU+gJf/AxsUQ52REI= github.com/andybalholm/brotli v1.2.6 h1:ftYnfj6usCp+UGV5kSJ3+chpMQgU+gJf/AxsUQ52REI=
github.com/andybalholm/brotli v1.2.6/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY= github.com/andybalholm/brotli v1.2.6/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/ayn2op/arikawa/v3 v3.0.0-20261014035141-32b58d8f3755 h1:XHo9kizImaAEtJJky4GZOBTalze42GIVDViqirjuPBY= github.com/ayn2op/arikawa/v3 v3.0.0-20261016043052-54a68a54e42e h1:jYi14tMaIrOr8/IydOmHcpEWz4keWH8zJoK8eKYF/lI=
github.com/ayn2op/arikawa/v3 v3.0.0-20261014035141-32b58d8f3755/go.mod h1:YARcqZmk7hDjXB+lexlXX4wDFHULafbGnF0gsD0tuNw= github.com/ayn2op/arikawa/v3 v3.0.0-20261016043052-54a68a54e42e/go.mod h1:h2k8uDqPkJ8oQmBe5brLwuBaJWMSglq9sZ5B1TjmTdo=
github.com/ayn2op/fhttp v0.6.10-0.20261016015330-2d5e34c6b935 h1:oVxkY1/nVsVQ8Cn/hxJckflbBEUkd5PBLOELAeAhGLA= github.com/ayn2op/fhttp v0.6.10-0.20261016015330-2d5e34c6b935 h1:oVxkY1/nVsVQ8Cn/hxJckflbBEUkd5PBLOELAeAhGLA=
github.com/ayn2op/fhttp v0.6.10-0.20261016015330-2d5e34c6b935/go.mod h1:7phoj3f/q54WuiTnCTlAhEoaVcdlruKkSzCSD47LzHk= github.com/ayn2op/fhttp v0.6.10-0.20261016015330-2d5e34c6b935/go.mod h1:7phoj3f/q54WuiTnCTlAhEoaVcdlruKkSzCSD47LzHk=
github.com/ayn2op/ningen/v3 v3.0.1-0.20261014035153-5e43590a1426 h1:0ndRWpAiSSgR0z9b7K+pwMlCHEk3VzQeS5ls+zWtbr0= github.com/ayn2op/ningen/v3 v3.0.1-0.20261014035153-5e43590a1426 h1:0ndRWpAiSSgR0z9b7K+pwMlCHEk3VzQeS5ls+zWtbr0=
@ -42,8 +42,8 @@ github.com/dchest/jsmin v1.0.0 h1:Y2hWXmGZiRxtl+VcTksyucgTlYxnhPzTozCwx9gy9zI=
github.com/dchest/jsmin v1.0.0/go.mod h1:AVBIund7Mr7lKXT70hKT2YgL3XEXUaUk5iw9DZ8b0Uc= github.com/dchest/jsmin v1.0.0/go.mod h1:AVBIund7Mr7lKXT70hKT2YgL3XEXUaUk5iw9DZ8b0Uc=
github.com/disgoorg/godave v0.3.0 h1:37F3ZuiMd8/EXeoCtTeE8iP2eT2nWsfEa4/ITwoKfe4= github.com/disgoorg/godave v0.3.0 h1:37F3ZuiMd8/EXeoCtTeE8iP2eT2nWsfEa4/ITwoKfe4=
github.com/disgoorg/godave v0.3.0/go.mod h1:OreAC3hpabr39bMVA+jwOVDq1EUPXH5A0XUBiZaDI1Y= github.com/disgoorg/godave v0.3.0/go.mod h1:OreAC3hpabr39bMVA+jwOVDq1EUPXH5A0XUBiZaDI1Y=
github.com/dlclark/regexp2/v2 v2.8.4 h1:yfDDXTn4oxyLDC10/ieOBNDCCdIVWS9WbT6ddVXsPKI= github.com/dlclark/regexp2/v2 v2.9.0 h1:kKj+BlRuUhZzJk8B3yOBxWKxDFnx2Ilq4e7KNdq/Mxk=
github.com/dlclark/regexp2/v2 v2.8.4/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU= github.com/dlclark/regexp2/v2 v2.9.0/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=
github.com/ebitengine/purego v0.11.1 h1:2zpWRSQNVKN4eKsKO9eM1ILDgWfYMY9GwqRmK6XeQ/0= github.com/ebitengine/purego v0.11.1 h1:2zpWRSQNVKN4eKsKO9eM1ILDgWfYMY9GwqRmK6XeQ/0=
github.com/ebitengine/purego v0.11.1/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ= github.com/ebitengine/purego v0.11.1/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ=
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw= github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
@ -103,8 +103,8 @@ github.com/twmb/murmur3 v1.2.1/go.mod h1:LVqs/avIy0flspVtmBd4VSbogDepFl6Wkj0i0To
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.8.6 h1:d0VcaP1sx9GkFVkoW+KtggpGi2KZ965i14b0+bDQST4= github.com/yuin/goldmark/v2 v2.1.6 h1:igy0q9JcqovoFXFx/XjtU8sHVhcUHavPj2sA3EoKJUE=
github.com/yuin/goldmark v1.8.6/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg= github.com/yuin/goldmark/v2 v2.1.6/go.mod h1:G6M4/qOFtfn01/o14BU1UR2Lo5N3S9Qo7xCuz/sHjGQ=
github.com/zalando/go-keyring v0.2.8 h1:6sD/Ucpl7jNq10rM2pgqTs0sZ9V3qMrqfIIy5YPccHs= github.com/zalando/go-keyring v0.2.8 h1:6sD/Ucpl7jNq10rM2pgqTs0sZ9V3qMrqfIIy5YPccHs=
github.com/zalando/go-keyring v0.2.8/go.mod h1:tsMo+VpRq5NGyKfxoBVjCuMrG47yj8cmakZDO5QGii0= github.com/zalando/go-keyring v0.2.8/go.mod h1:tsMo+VpRq5NGyKfxoBVjCuMrG47yj8cmakZDO5QGii0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=

View file

@ -12,7 +12,7 @@ import (
"github.com/ayn2op/tview" "github.com/ayn2op/tview"
"github.com/ayn2op/tview/richtext" "github.com/ayn2op/tview/richtext"
"github.com/gdamore/tcell/v3" "github.com/gdamore/tcell/v3"
"github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/v2/ast"
) )
type Renderer struct { type Renderer struct {
@ -61,7 +61,7 @@ func (r *Renderer) RenderText(source []byte, node ast.Node, base tview.Style) ri
} }
case *ast.Text: case *ast.Text:
if entering { if entering {
builder.Write(string(node.Segment.Value(source)), currentStyle()) builder.Write(string(node.Value.Bytes(source)), currentStyle())
switch { switch {
case node.HardLineBreak(): case node.HardLineBreak():
builder.NewLine() builder.NewLine()
@ -70,20 +70,20 @@ func (r *Renderer) RenderText(source []byte, node ast.Node, base tview.Style) ri
builder.NewLine() builder.NewLine()
} }
} }
case *ast.FencedCodeBlock: case *ast.CodeBlock:
if entering { if entering {
builder.NewLine() builder.NewLine()
r.renderFencedCodeBlock(builder, source, node, currentStyle()) r.renderCodeBlock(builder, source, node, currentStyle())
} }
case *ast.AutoLink: case *ast.AutoLink:
if entering { if entering {
url := string(node.URL(source)) url := string(node.Destination.Bytes(source))
style := tview.MergeStyle(currentStyle(), theme.URLStyle.Style).Url(url) style := tview.MergeStyle(currentStyle(), theme.URLStyle.Style).Url(url)
builder.Write(url, style) builder.Write(url, style)
} }
case *ast.Link: case *ast.Link:
if entering { if entering {
url := string(node.Destination) url := string(node.Destination.Bytes(source))
linkDepth++ linkDepth++
pushStyle(tview.MergeStyle(currentStyle(), theme.URLStyle.Style).Url(url)) pushStyle(tview.MergeStyle(currentStyle(), theme.URLStyle.Style).Url(url))
} else { } else {
@ -145,15 +145,15 @@ func (r *Renderer) RenderText(source []byte, node ast.Node, base tview.Style) ri
return builder.Finish() return builder.Finish()
} }
func (r *Renderer) renderFencedCodeBlock(builder *richtext.Builder, source []byte, node *ast.FencedCodeBlock, base tview.Style) { func (r *Renderer) renderCodeBlock(builder *richtext.Builder, source []byte, node *ast.CodeBlock, base tview.Style) {
var code strings.Builder var code strings.Builder
lines := node.Lines() lines := node.Value.Segments()
for i := range lines.Len() { for _, line := range lines {
line := lines.At(i) code.Write(line.Bytes(source))
code.Write(line.Value(source))
} }
language := strings.TrimSpace(string(node.Language(source))) language, _ := node.Language(source)
language = strings.TrimSpace(language)
lexer := lexers.Get(language) lexer := lexers.Get(language)
declaredLanguageSupported := lexer != nil declaredLanguageSupported := lexer != nil
@ -186,9 +186,8 @@ func (r *Renderer) renderFencedCodeBlock(builder *richtext.Builder, source []byt
iterator, err := lexer.Tokenise(nil, code.String()) iterator, err := lexer.Tokenise(nil, code.String())
if err != nil { if err != nil {
for i := range lines.Len() { for _, line := range lines {
line := lines.At(i) builder.Write(codeBlockIndent+string(line.Bytes(source)), base)
builder.Write(codeBlockIndent+string(line.Value(source)), base)
} }
return return
} }

View file

@ -32,7 +32,7 @@ import (
"github.com/ayn2op/tview/textarea" "github.com/ayn2op/tview/textarea"
"github.com/gdamore/tcell/v3" "github.com/gdamore/tcell/v3"
"github.com/rivo/uniseg" "github.com/rivo/uniseg"
"github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/v2/ast"
"golang.design/x/clipboard" "golang.design/x/clipboard"
) )
@ -363,15 +363,16 @@ func (m Model) processText(channel *discord.Channel, src []byte) string {
_ = ast.Walk(md.Parse(src), func(node ast.Node, enter bool) (ast.WalkStatus, error) { _ = ast.Walk(md.Parse(src), func(node ast.Node, enter bool) (ast.WalkStatus, error) {
switch node := node.(type) { switch node := node.(type) {
case *ast.CodeBlock, *ast.FencedCodeBlock: case *ast.CodeBlock:
canMention = !enter canMention = !enter
case *md.Inline: case *md.Inline:
if (node.Attr & md.AttrMonospace) != 0 { if (node.Attr & md.AttrMonospace) != 0 {
canMention = !enter canMention = !enter
} }
case *ast.Text: case *ast.Text:
if enter && canMention { if enter && canMention && !node.Value.IsOwned() {
ranges = append(ranges, [2]int{node.Segment.Start, node.Segment.Stop}) index := node.Value.Index()
ranges = append(ranges, [2]int{index.Start, index.Stop})
} }
} }
return ast.WalkContinue, nil return ast.WalkContinue, nil

View file

@ -43,7 +43,7 @@ import (
"github.com/gdamore/tcell/v3" "github.com/gdamore/tcell/v3"
"github.com/gdamore/tcell/v3/color" "github.com/gdamore/tcell/v3/color"
"github.com/rivo/uniseg" "github.com/rivo/uniseg"
"github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/v2/ast"
) )
type messageItem struct { type messageItem struct {
@ -614,7 +614,7 @@ func (m Model) drawContent(builder *richtext.Builder, message discord.Message, b
startsWithCodeBlock := false startsWithCodeBlock := false
if root != nil { if root != nil {
if first := root.FirstChild(); first != nil { if first := root.FirstChild(); first != nil {
_, startsWithCodeBlock = first.(*ast.FencedCodeBlock) _, startsWithCodeBlock = first.(*ast.CodeBlock)
} }
} }
@ -1239,9 +1239,9 @@ func urlsFromAST(node ast.Node, src []byte) []string {
if entering { if entering {
switch n := n.(type) { switch n := n.(type) {
case *ast.AutoLink: case *ast.AutoLink:
urls = append(urls, string(n.URL(src))) urls = append(urls, string(n.Destination.Bytes(src)))
case *ast.Link: case *ast.Link:
urls = append(urls, string(n.Destination)) urls = append(urls, string(n.Destination.Bytes(src)))
} }
} }