]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
deps: Udpate to github.com/alecthomas/chroma/v2
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 26 May 2022 10:17:10 +0000 (12:17 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Tue, 14 Jun 2022 12:08:40 +0000 (14:08 +0200)
Fixes #9932
Fixes #9931

commands/genchromastyles.go
go.mod
go.sum
helpers/docshelper.go
hugolib/page__per_output.go
hugolib/testhelpers_test.go
markup/goldmark/codeblocks/render.go
markup/highlight/config.go
markup/highlight/highlight.go
tpl/transform/transform.go

index a2476ffdff0defffe5009f229a2615b0085ccca2..4dfa77d2e2ccf94bb7e8a933f522b170e7ef5891 100644 (file)
@@ -16,9 +16,9 @@ package commands
 import (
        "os"
 
-       "github.com/alecthomas/chroma"
-       "github.com/alecthomas/chroma/formatters/html"
-       "github.com/alecthomas/chroma/styles"
+       "github.com/alecthomas/chroma/v2"
+       "github.com/alecthomas/chroma/v2/formatters/html"
+       "github.com/alecthomas/chroma/v2/styles"
        "github.com/spf13/cobra"
 )
 
diff --git a/go.mod b/go.mod
index 68374b42787117898486d4ed7d496da3249095fd..4e42c9a3212df03dae91bcb2605c30caec64235f 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/gohugoio/hugo
 require (
        github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69
        github.com/PuerkitoBio/purell v1.1.1
-       github.com/alecthomas/chroma v0.10.0
+       github.com/alecthomas/chroma/v2 v2.1.0
        github.com/armon/go-radix v1.0.0
        github.com/aws/aws-sdk-go v1.43.5
        github.com/bep/clock v0.3.0
@@ -42,7 +42,7 @@ require (
        github.com/mitchellh/hashstructure v1.1.0
        github.com/mitchellh/mapstructure v1.5.0
        github.com/muesli/smartcrop v0.3.0
-       github.com/niklasfasching/go-org v1.6.2
+       github.com/niklasfasching/go-org v1.6.5
        github.com/olekukonko/tablewriter v0.0.5
        github.com/pelletier/go-toml/v2 v2.0.1
        github.com/rogpeppe/go-internal v1.8.1
@@ -60,7 +60,7 @@ require (
        go.uber.org/atomic v1.9.0
        gocloud.dev v0.24.0
        golang.org/x/image v0.0.0-20211028202545-6944b10bf410
-       golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
+       golang.org/x/net v0.0.0-20220607020251-c690dde0001d
        golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
        golang.org/x/text v0.3.7
        golang.org/x/tools v0.1.10
@@ -114,7 +114,7 @@ require (
        go.opencensus.io v0.23.0 // indirect
        golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect
        golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
-       golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
+       golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
        golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
        google.golang.org/appengine v1.6.7 // indirect
        google.golang.org/genproto v0.0.0-20220426171045-31bebdecfb46 // indirect
diff --git a/go.sum b/go.sum
index 0f4724cd15f02e3d7970891b2ced659a04aca121..9fee7267285bfa25594b4a70ede4cc2eaa9b57b3 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -131,8 +131,9 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN
 github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
 github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
-github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
-github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
+github.com/alecthomas/chroma/v2 v2.1.0 h1:ZG9L5/RsxO/xIONrBy8Cgo+5si3d9x3osweXc4VHl0o=
+github.com/alecthomas/chroma/v2 v2.1.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
+github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY=
 github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
 github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
 github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
@@ -459,8 +460,8 @@ github.com/muesli/smartcrop v0.3.0/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78Rwc
 github.com/neurosnap/sentences v1.0.6/go.mod h1:pg1IapvYpWCJJm/Etxeh0+gtMf1rI1STY9S7eUCPbDc=
 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
-github.com/niklasfasching/go-org v1.6.2 h1:kQBIZlfL4oRNApJCrBgaeNBfzxWzP6XlC7/b744Polk=
-github.com/niklasfasching/go-org v1.6.2/go.mod h1:wn76Xgu4/KRe43WZhsgZjxYMaloSrl3BSweGV74SwHs=
+github.com/niklasfasching/go-org v1.6.5 h1:5YAIqNTdl6lAOb7lD2AyQ1RuFGPVrAKvUexphk8PGbo=
+github.com/niklasfasching/go-org v1.6.5/go.mod h1:ybv0eGDnxylFUfFE+ySaQc734j/L3+/ChKZ/h63a2wM=
 github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
@@ -643,8 +644,8 @@ golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su
 golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
-golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
-golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
+golang.org/x/net v0.0.0-20220607020251-c690dde0001d h1:4SFsTMi4UahlKoloni7L4eYzhFRifURQLw+yv0QDCx8=
+golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -742,8 +743,8 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
-golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
+golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
index e7c7fbe5bfa37217e6c594467bcd3b4c10fa9f66..35d07d366ffe51a73ac8296177931e683de16503 100644 (file)
@@ -1,11 +1,9 @@
 package helpers
 
 import (
-       "path/filepath"
        "sort"
-       "strings"
 
-       "github.com/alecthomas/chroma/lexers"
+       "github.com/alecthomas/chroma/v2/lexers"
        "github.com/gohugoio/hugo/docshelper"
 )
 
@@ -14,33 +12,18 @@ func init() {
        docsProvider := func() docshelper.DocProvider {
                var chromaLexers []any
 
-               sort.Sort(lexers.Registry.Lexers)
+               sort.Sort(lexers.GlobalLexerRegistry.Lexers)
 
-               for _, l := range lexers.Registry.Lexers {
+               for _, l := range lexers.GlobalLexerRegistry.Lexers {
 
                        config := l.Config()
 
-                       var filenames []string
-                       filenames = append(filenames, config.Filenames...)
-                       filenames = append(filenames, config.AliasFilenames...)
-
-                       aliases := config.Aliases
-
-                       for _, filename := range filenames {
-                               alias := strings.TrimSpace(strings.TrimPrefix(filepath.Ext(filename), "."))
-                               if alias != "" {
-                                       aliases = append(aliases, alias)
-                               }
-                       }
-
-                       aliases = UniqueStringsSorted(aliases)
-
                        lexerEntry := struct {
                                Name    string
                                Aliases []string
                        }{
                                config.Name,
-                               aliases,
+                               config.Aliases,
                        }
 
                        chromaLexers = append(chromaLexers, lexerEntry)
index e69d32e27a6f041016449a108c324ab768b29faf..de70047c9f789e8e31ab72f2955f5e7f9d442c5e 100644 (file)
@@ -36,7 +36,7 @@ import (
 
        "github.com/gohugoio/hugo/markup/converter"
 
-       "github.com/alecthomas/chroma/lexers"
+       "github.com/alecthomas/chroma/v2/lexers"
        "github.com/gohugoio/hugo/lazy"
 
        bp "github.com/gohugoio/hugo/bufferpool"
index 1a2c423f75531f2a4afc672377c1eece3eb5dc02..46fa35debffefe09c6b8443bbc8b1614b978d1c8 100644 (file)
@@ -853,7 +853,7 @@ func (th testHelper) assertFileContentRegexp(filename string, matches ...string)
                r := regexp.MustCompile(match)
                matches := r.MatchString(content)
                if !matches {
-                       fmt.Println(match+":\n", content)
+                       fmt.Println("Expected to match regexp:\n"+match+"\nGot:\n", content)
                }
                th.Assert(matches, qt.Equals, true)
        }
index d56667ceba832032262f34b3b2022ef529e1ae4a..e245688e7e6c34834719df2c3ced624ced9ed600 100644 (file)
@@ -18,7 +18,7 @@ import (
        "fmt"
        "sync"
 
-       "github.com/alecthomas/chroma/lexers"
+       "github.com/alecthomas/chroma/v2/lexers"
        "github.com/gohugoio/hugo/common/herrors"
        htext "github.com/gohugoio/hugo/common/text"
        "github.com/gohugoio/hugo/markup/converter/hooks"
index 08c1bca1ad4b65530b92a2043b3874486de00834..80991f21bce51db8f23699114d8dcf1d25dedeaf 100644 (file)
@@ -19,7 +19,7 @@ import (
        "strconv"
        "strings"
 
-       "github.com/alecthomas/chroma/formatters/html"
+       "github.com/alecthomas/chroma/v2/formatters/html"
        "github.com/spf13/cast"
 
        "github.com/gohugoio/hugo/config"
index 8e7f6ee30cd4b9755fe7cc9cea29550bddfa0897..7e5704132804cfedb02a22828d62fcd93499f241 100644 (file)
@@ -20,10 +20,10 @@ import (
        "io"
        "strings"
 
-       "github.com/alecthomas/chroma"
-       "github.com/alecthomas/chroma/formatters/html"
-       "github.com/alecthomas/chroma/lexers"
-       "github.com/alecthomas/chroma/styles"
+       "github.com/alecthomas/chroma/v2"
+       "github.com/alecthomas/chroma/v2/formatters/html"
+       "github.com/alecthomas/chroma/v2/lexers"
+       "github.com/alecthomas/chroma/v2/styles"
        "github.com/gohugoio/hugo/common/hugio"
        "github.com/gohugoio/hugo/common/text"
        "github.com/gohugoio/hugo/identity"
index 69ab98a9a7a09edffdc205bb65855c7a0aa4d477..36508c4284eda5ba4ca9b9469cf400cce30f0447 100644 (file)
@@ -18,7 +18,7 @@ import (
        "html"
        "html/template"
 
-       "github.com/alecthomas/chroma/lexers"
+       "github.com/alecthomas/chroma/v2/lexers"
        "github.com/gohugoio/hugo/cache/namedmemcache"
        "github.com/gohugoio/hugo/markup/converter/hooks"
        "github.com/gohugoio/hugo/markup/highlight"