diff --git a/.golangci.yml b/.golangci.yml index 120ea7158..668be374a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -49,6 +49,8 @@ linters: - nosnakecase - testableexamples - musttag + - depguard + - goconst linters-settings: govet: diff --git a/bin/.bit-0.0.1.pkg b/bin/.bit-0.4.2.pkg similarity index 100% rename from bin/.bit-0.0.1.pkg rename to bin/.bit-0.4.2.pkg diff --git a/bin/.enumer-1.5.7.pkg b/bin/.enumer-1.5.9.pkg similarity index 100% rename from bin/.enumer-1.5.7.pkg rename to bin/.enumer-1.5.9.pkg diff --git a/bin/.esbuild-0.16.16.pkg b/bin/.esbuild-0.19.8.pkg similarity index 100% rename from bin/.esbuild-0.16.16.pkg rename to bin/.esbuild-0.19.8.pkg diff --git a/bin/.go-1.20.2.pkg b/bin/.go-1.21.5.pkg similarity index 100% rename from bin/.go-1.20.2.pkg rename to bin/.go-1.21.5.pkg diff --git a/bin/.golangci-lint-1.51.2.pkg b/bin/.golangci-lint-1.55.2.pkg similarity index 100% rename from bin/.golangci-lint-1.51.2.pkg rename to bin/.golangci-lint-1.55.2.pkg diff --git a/bin/.goreleaser-1.16.2.pkg b/bin/.goreleaser-1.22.1.pkg similarity index 100% rename from bin/.goreleaser-1.16.2.pkg rename to bin/.goreleaser-1.22.1.pkg diff --git a/bin/.hlb-0.3.pkg b/bin/.hlb-0.4.0.pkg similarity index 100% rename from bin/.hlb-0.3.pkg rename to bin/.hlb-0.4.0.pkg diff --git a/bin/.hyperfine-1.12.0.pkg b/bin/.hyperfine-1.18.0.pkg similarity index 100% rename from bin/.hyperfine-1.12.0.pkg rename to bin/.hyperfine-1.18.0.pkg diff --git a/bin/.svu-1.11.0.pkg b/bin/.svu-1.12.0.pkg similarity index 100% rename from bin/.svu-1.11.0.pkg rename to bin/.svu-1.12.0.pkg diff --git a/bin/bit b/bin/bit index 95e8cd817..23ed3200c 120000 --- a/bin/bit +++ b/bin/bit @@ -1 +1 @@ -.bit-0.0.1.pkg \ No newline at end of file +.bit-0.4.2.pkg \ No newline at end of file diff --git a/bin/enumer b/bin/enumer index 4e25d678c..83e7e9cb9 120000 --- a/bin/enumer +++ b/bin/enumer @@ -1 +1 @@ -.enumer-1.5.7.pkg \ No newline at end of file +.enumer-1.5.9.pkg \ No newline at end of file diff --git a/bin/esbuild b/bin/esbuild index 86d3be0d9..abed66301 120000 --- a/bin/esbuild +++ b/bin/esbuild @@ -1 +1 @@ -.esbuild-0.16.16.pkg \ No newline at end of file +.esbuild-0.19.8.pkg \ No newline at end of file diff --git a/bin/go b/bin/go index daa8ec889..7da550931 120000 --- a/bin/go +++ b/bin/go @@ -1 +1 @@ -.go-1.20.2.pkg \ No newline at end of file +.go-1.21.5.pkg \ No newline at end of file diff --git a/bin/gofmt b/bin/gofmt index daa8ec889..7da550931 120000 --- a/bin/gofmt +++ b/bin/gofmt @@ -1 +1 @@ -.go-1.20.2.pkg \ No newline at end of file +.go-1.21.5.pkg \ No newline at end of file diff --git a/bin/golangci-lint b/bin/golangci-lint index 7d8886c71..5b19a9de5 120000 --- a/bin/golangci-lint +++ b/bin/golangci-lint @@ -1 +1 @@ -.golangci-lint-1.51.2.pkg \ No newline at end of file +.golangci-lint-1.55.2.pkg \ No newline at end of file diff --git a/bin/goreleaser b/bin/goreleaser index 89655c9f5..5c73681be 120000 --- a/bin/goreleaser +++ b/bin/goreleaser @@ -1 +1 @@ -.goreleaser-1.16.2.pkg \ No newline at end of file +.goreleaser-1.22.1.pkg \ No newline at end of file diff --git a/bin/hlb b/bin/hlb index c136244e0..8b142d8ba 120000 --- a/bin/hlb +++ b/bin/hlb @@ -1 +1 @@ -.hlb-0.3.pkg \ No newline at end of file +.hlb-0.4.0.pkg \ No newline at end of file diff --git a/bin/hyperfine b/bin/hyperfine index 0dfeb8042..3fe2eaac1 120000 --- a/bin/hyperfine +++ b/bin/hyperfine @@ -1 +1 @@ -.hyperfine-1.12.0.pkg \ No newline at end of file +.hyperfine-1.18.0.pkg \ No newline at end of file diff --git a/bin/svu b/bin/svu index b97a81573..a1ff073f8 120000 --- a/bin/svu +++ b/bin/svu @@ -1 +1 @@ -.svu-1.11.0.pkg \ No newline at end of file +.svu-1.12.0.pkg \ No newline at end of file diff --git a/cmd/chroma/go.mod b/cmd/chroma/go.mod index 013203a60..9150f8b5e 100644 --- a/cmd/chroma/go.mod +++ b/cmd/chroma/go.mod @@ -5,10 +5,10 @@ go 1.19 replace github.com/alecthomas/chroma/v2 => ../../ require ( - github.com/alecthomas/chroma/v2 v2.0.0-00010101000000-000000000000 - github.com/alecthomas/kong v0.8.0 + github.com/alecthomas/chroma/v2 v2.12.0 + github.com/alecthomas/kong v0.8.1 github.com/mattn/go-colorable v0.1.13 - github.com/mattn/go-isatty v0.0.19 + github.com/mattn/go-isatty v0.0.20 ) require ( diff --git a/cmd/chroma/go.sum b/cmd/chroma/go.sum index 192343585..569197a8b 100644 --- a/cmd/chroma/go.sum +++ b/cmd/chroma/go.sum @@ -1,6 +1,8 @@ github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink= github.com/alecthomas/kong v0.8.0 h1:ryDCzutfIqJPnNn0omnrgHLbAggDQM2VWHikE1xqK7s= github.com/alecthomas/kong v0.8.0/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= +github.com/alecthomas/kong v0.8.1 h1:acZdn3m4lLRobeh3Zi2S2EpnXTd1mOL6U7xVml+vfkY= +github.com/alecthomas/kong v0.8.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -10,6 +12,8 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/cmd/chromad/go.mod b/cmd/chromad/go.mod index 1bb52faa1..9667bf580 100644 --- a/cmd/chromad/go.mod +++ b/cmd/chromad/go.mod @@ -3,18 +3,18 @@ module github.com/alecthomas/chroma/v2/cmd/chromad go 1.19 require ( - github.com/alecthomas/chroma/v2 v2.0.0-00010101000000-000000000000 - github.com/alecthomas/kong v0.8.0 + github.com/alecthomas/chroma/v2 v2.12.0 + github.com/alecthomas/kong v0.8.1 github.com/alecthomas/kong-hcl v1.0.1 - github.com/gorilla/csrf v1.7.1 - github.com/gorilla/handlers v1.5.1 - github.com/gorilla/mux v1.8.0 + github.com/gorilla/csrf v1.7.2 + github.com/gorilla/handlers v1.5.2 + github.com/gorilla/mux v1.8.1 ) require ( github.com/dlclark/regexp2 v1.10.0 // indirect - github.com/felixge/httpsnoop v1.0.1 // indirect - github.com/gorilla/securecookie v1.1.1 // indirect + github.com/felixge/httpsnoop v1.0.3 // indirect + github.com/gorilla/securecookie v1.1.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/pkg/errors v0.9.1 // indirect ) diff --git a/cmd/chromad/go.sum b/cmd/chromad/go.sum index 971fb5278..2020a7408 100644 --- a/cmd/chromad/go.sum +++ b/cmd/chromad/go.sum @@ -2,6 +2,8 @@ github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2 github.com/alecthomas/kong v0.2.16/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= github.com/alecthomas/kong v0.8.0 h1:ryDCzutfIqJPnNn0omnrgHLbAggDQM2VWHikE1xqK7s= github.com/alecthomas/kong v0.8.0/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= +github.com/alecthomas/kong v0.8.1 h1:acZdn3m4lLRobeh3Zi2S2EpnXTd1mOL6U7xVml+vfkY= +github.com/alecthomas/kong v0.8.1/go.mod h1:n1iCIO2xS46oE8ZfYCNDqdR0b0wZNrXAIAqro/2132U= github.com/alecthomas/kong-hcl v1.0.1 h1:f4svdFpEoNUwlpZj57CvfhzSnSfP/KBzMDETlwamd/s= github.com/alecthomas/kong-hcl v1.0.1/go.mod h1:6Y+MaMTZ/KQe9Qme6aSlKtql65FJE0/1O+Mu56C6UgQ= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= @@ -11,14 +13,24 @@ github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= +github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/gorilla/csrf v1.7.1 h1:Ir3o2c1/Uzj6FBxMlAUB6SivgVMy1ONXwYgXn+/aHPE= github.com/gorilla/csrf v1.7.1/go.mod h1:+a/4tCmqhG6/w4oafeAZ9pEa3/NZOWYVbD9fV0FwIQA= +github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI= +github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= +github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= +github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= +github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= +github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= +github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= diff --git a/formatters/html/html.go b/formatters/html/html.go index 0ad6b31ce..6b21a297c 100644 --- a/formatters/html/html.go +++ b/formatters/html/html.go @@ -5,6 +5,7 @@ import ( "html" "io" "sort" + "strconv" "strings" "github.com/alecthomas/chroma/v2" @@ -243,7 +244,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma. wrapInTable := f.lineNumbers && f.lineNumbersInTable lines := chroma.SplitTokensIntoLines(tokens) - lineDigits := len(fmt.Sprintf("%d", f.baseLineNumber+len(lines)-1)) + lineDigits := len(strconv.Itoa(f.baseLineNumber + len(lines) - 1)) highlightIndex := 0 if wrapInTable { @@ -251,7 +252,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma. fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.PreWrapper)) fmt.Fprintf(w, "", f.styleAttr(css, chroma.LineTable)) fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.LineTableTD)) - fmt.Fprintf(w, f.preWrapper.Start(false, f.styleAttr(css, chroma.PreWrapper))) + fmt.Fprintf(w, "%s", f.preWrapper.Start(false, f.styleAttr(css, chroma.PreWrapper))) for index := range lines { line := f.baseLineNumber + index highlight, next := f.shouldHighlight(highlightIndex, line) @@ -273,7 +274,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma. fmt.Fprintf(w, "\n", f.styleAttr(css, chroma.LineTableTD, "width:100%")) } - fmt.Fprintf(w, f.preWrapper.Start(true, f.styleAttr(css, chroma.PreWrapper))) + fmt.Fprintf(w, "%s", f.preWrapper.Start(true, f.styleAttr(css, chroma.PreWrapper))) highlightIndex = 0 for index, tokens := range lines { @@ -323,7 +324,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma. fmt.Fprint(w, ``) // End of Line } } - fmt.Fprintf(w, f.preWrapper.End(true)) + fmt.Fprintf(w, "%s", f.preWrapper.End(true)) if wrapInTable { fmt.Fprint(w, "\n") diff --git a/go.mod b/go.mod index 562d809df..fc363770c 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/alecthomas/chroma/v2 go 1.19 require ( - github.com/alecthomas/assert/v2 v2.2.1 - github.com/alecthomas/repr v0.2.0 + github.com/alecthomas/assert/v2 v2.4.1 + github.com/alecthomas/repr v0.3.0 github.com/dlclark/regexp2 v1.10.0 ) diff --git a/go.sum b/go.sum index 035925735..67778c135 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,11 @@ github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink= github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= +github.com/alecthomas/assert/v2 v2.4.1 h1:mwPZod/d35nlaCppr6sFP0rbCL05WH9fIo7lvsf47zo= +github.com/alecthomas/assert/v2 v2.4.1/go.mod h1:fw5suVxB+wfYJ3291t0hRTqtGzFYdSwstnRQdaQx2DM= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/repr v0.3.0 h1:NeYzUPfjjlqHY4KtzgKJiWd6sVq2eNUPTi34PiFGjY8= +github.com/alecthomas/repr v0.3.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0= github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= diff --git a/lexers/lexers_test.go b/lexers/lexers_test.go index 453207ef8..57ea01916 100644 --- a/lexers/lexers_test.go +++ b/lexers/lexers_test.go @@ -30,10 +30,10 @@ func TestCompileAllRegexes(t *testing.T) { func TestGet(t *testing.T) { t.Run("ByName", func(t *testing.T) { - assert.Equal(t, lexers.Get("xml"), lexers.GlobalLexerRegistry.Get("XML")) + assert.True(t, lexers.Get("xml") == lexers.GlobalLexerRegistry.Get("XML")) }) t.Run("ByAlias", func(t *testing.T) { - assert.Equal(t, lexers.Get("as"), lexers.GlobalLexerRegistry.Get("Actionscript")) + assert.True(t, lexers.Get("as") == lexers.GlobalLexerRegistry.Get("Actionscript")) }) t.Run("ViaFilename", func(t *testing.T) { expected := lexers.Get("XML") diff --git a/renovate.json5 b/renovate.json5 index 897864b85..77c7b016c 100644 --- a/renovate.json5 +++ b/renovate.json5 @@ -1,11 +1,18 @@ { - $schema: "https://docs.renovatebot.com/renovate-schema.json", - extends: [ - "config:recommended", - ":semanticCommits", - ":semanticCommitTypeAll(chore)", - ":semanticCommitScope(deps)", - "group:allNonMajor", - "schedule:earlyMondays", // Run once a week. - ], + $schema: "https://docs.renovatebot.com/renovate-schema.json", + extends: [ + "config:recommended", + ":semanticCommits", + ":semanticCommitTypeAll(chore)", + ":semanticCommitScope(deps)", + "group:allNonMajor", + "schedule:earlyMondays", // Run once a week. + ], + packageRules: [ + { + matchPackageNames: ["golangci-lint"], + matchManagers: ["hermit"], + enabled: false, + }, + ], }