diff --git a/go.mod b/go.mod index d1df2eefe1..e2db6db489 100644 --- a/go.mod +++ b/go.mod @@ -322,7 +322,7 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.3.1 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/alecthomas/chroma/v2 v2.19.0 + github.com/alecthomas/chroma/v2 v2.20.0 github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect diff --git a/go.sum b/go.sum index 66c1aba624..8a87611ddb 100644 --- a/go.sum +++ b/go.sum @@ -165,12 +165,12 @@ github.com/Workiva/go-datastructures v1.1.5/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5 github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= -github.com/alecthomas/chroma/v2 v2.19.0 h1:Im+SLRgT8maArxv81mULDWN8oKxkzboH07CHesxElq4= -github.com/alecthomas/chroma/v2 v2.19.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk= +github.com/alecthomas/chroma/v2 v2.20.0 h1:sfIHpxPyR07/Oylvmcai3X/exDlE8+FA820NTz+9sGw= +github.com/alecthomas/chroma/v2 v2.20.0/go.mod h1:e7tViK0xh/Nf4BYHl00ycY6rV7b8iXBksI9E359yNmA= github.com/alecthomas/kingpin/v2 v2.4.0 h1:f48lwail6p8zpO1bC4TxtqACaGqHYA22qkHjHpqDjYY= github.com/alecthomas/kingpin/v2 v2.4.0/go.mod h1:0gyi0zQnjuFk8xrkNKamJoyUo382HRL7ATRpFZCw6tE= -github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= -github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/repr v0.5.1 h1:E3G4t2QbHTSNpPKBgMTln5KLkZHLOcU7r37J4pXBuIg= +github.com/alecthomas/repr v0.5.1/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= diff --git a/vendor/github.com/alecthomas/chroma/v2/Dockerfile b/vendor/github.com/alecthomas/chroma/v2/Dockerfile new file mode 100644 index 0000000000..e2a1531331 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/Dockerfile @@ -0,0 +1,65 @@ +# Multi-stage Dockerfile for chromad Go application using Hermit-managed tools + +# Build stage +FROM ubuntu:24.04 AS builder + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + curl \ + git \ + make \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /app + +# Copy the entire project (including bin directory with Hermit tools) +COPY . . + +# Make Hermit tools executable and add to PATH +ENV PATH="/app/bin:${PATH}" + +# Set Go environment variables for static compilation +ENV CGO_ENABLED=0 +ENV GOOS=linux +ENV GOARCH=amd64 + +# Build the application using make +RUN make build/chromad + +# Runtime stage +FROM alpine:3.22 AS runtime + +# Install ca-certificates for HTTPS requests +RUN apk --no-cache add ca-certificates curl + +# Create a non-root user +RUN addgroup -g 1001 chromad && \ + adduser -D -s /bin/sh -u 1001 -G chromad chromad + +# Set working directory +WORKDIR /app + +# Copy the binary from build stage +COPY --from=builder /app/build/chromad /app/chromad + +# Change ownership to non-root user +RUN chown chromad:chromad /app/chromad + +# Switch to non-root user +USER chromad + +# Expose port (default is 8080, but can be overridden via PORT env var) +EXPOSE 8080 + +# Set default environment variables +ENV PORT=8080 +ENV CHROMA_CSRF_KEY="testtest" + +# Health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD curl -fsSL http://127.0.0.1:8080/ > /dev/null + +# Run the application +CMD ["sh", "-c", "./chromad --csrf-key=$CHROMA_CSRF_KEY --bind=0.0.0.0:$PORT"] diff --git a/vendor/github.com/alecthomas/chroma/v2/Makefile b/vendor/github.com/alecthomas/chroma/v2/Makefile index 3fc57db8d8..ca89f7cb06 100644 --- a/vendor/github.com/alecthomas/chroma/v2/Makefile +++ b/vendor/github.com/alecthomas/chroma/v2/Makefile @@ -6,12 +6,16 @@ export GOARCH ?= amd64 all: README.md tokentype_string.go -README.md: lexers/*/*.go - ./table.py +README.md: lexers/*.go lexers/embedded/*.xml + GOOS= GOARCH= ./table.py tokentype_string.go: types.go go generate +.PHONY: format-js +format-js: + biome format --write cmd/chromad/static/{index.js,chroma.js} + .PHONY: chromad chromad: build/chromad @@ -26,8 +30,12 @@ build/chromad: $(shell find cmd/chromad -name '*.go' -o -name '*.html' -o -name cmd/chromad/static/wasm_exec.js: $(shell tinygo env TINYGOROOT)/targets/wasm_exec.js install -m644 $< $@ -cmd/chromad/static/chroma.wasm: cmd/libchromawasm/main.go - tinygo build -no-debug -target wasm -o $@ $< +cmd/chromad/static/chroma.wasm: $(shell git ls-files | grep '\.go|\.xml') + if type tinygo > /dev/null; then \ + tinygo build -no-debug -target wasm -o $@ cmd/libchromawasm/main.go; \ + else \ + GOOS=js GOARCH=wasm go build -o $@ cmd/libchromawasm/main.go; \ + fi upload: build/chromad scp build/chromad root@swapoff.org: && \ diff --git a/vendor/github.com/alecthomas/chroma/v2/README.md b/vendor/github.com/alecthomas/chroma/v2/README.md index bc9f470a9a..b65c325235 100644 --- a/vendor/github.com/alecthomas/chroma/v2/README.md +++ b/vendor/github.com/alecthomas/chroma/v2/README.md @@ -34,33 +34,34 @@ translators for Pygments lexers and styles. ## Supported languages -| Prefix | Language | -| :----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Agda, AL, Alloy, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, ArmAsm, AutoHotkey, AutoIt, Awk | -| B | Ballerina, Bash, Bash Session, Batchfile, BibTeX, Bicep, BlitzBasic, BNF, BQN, Brainfuck | -| C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Crystal, CSS, Cython | -| D | D, Dart, Dax, Desktop Entry, Diff, Django/Jinja, dns, Docker, DTD, Dylan | -| E | EBNF, Elixir, Elm, EmacsLisp, Erlang | -| F | Factor, Fennel, Fish, Forth, Fortran, FortranFixed, FSharp | -| G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, Gherkin, Gleam, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groff, Groovy | -| H | Handlebars, Hare, Haskell, Haxe, HCL, Hexdump, HLB, HLSL, HolyC, HTML, HTTP, Hy | -| I | Idris, Igor, INI, Io, ISCdhcpd | -| J | J, Java, JavaScript, JSON, Jsonnet, Julia, Jungle | -| K | Kotlin | -| L | Lean, Lighttpd configuration file, LLVM, Lua | -| M | Makefile, Mako, markdown, Mason, Materialize SQL dialect, Mathematica, Matlab, MCFunction, Meson, Metal, MiniZinc, MLIR, Modula-2, Mojo, MonkeyC, MorrowindScript, Myghty, MySQL | -| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix, NSIS | -| O | Objective-C, OCaml, Octave, Odin, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode | -| P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Plutus Core, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerQuery, PowerShell, Prolog, PromQL, Promela, properties, Protocol Buffer, PRQL, PSL, Puppet, Python, Python 2 | -| Q | QBasic, QML | -| R | R, Racket, Ragel, Raku, react, ReasonML, reg, Rego, reStructuredText, Rexx, RPMSpec, Ruby, Rust | -| S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, SNBT, Snobol, Solidity, SourcePawn, SPARQL, SQL, SquidConf, Standard ML, stas, Stylus, Svelte, Swift, SYSTEMD, systemverilog | -| T | TableGen, Tal, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData, Typst | -| V | V, V shell, Vala, VB.net, verilog, VHDL, VHS, VimL, vue | -| W | WDTE, WebGPU Shading Language, Whiley | -| X | XML, Xorg | -| Y | YAML, YANG | -| Z | Z80 Assembly, Zed, Zig | +| Prefix | Language +| :----: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +| A | ABAP, ABNF, ActionScript, ActionScript 3, Ada, Agda, AL, Alloy, Angular2, ANTLR, ApacheConf, APL, AppleScript, ArangoDB AQL, Arduino, ArmAsm, ATL, AutoHotkey, AutoIt, Awk +| B | Ballerina, Bash, Bash Session, Batchfile, Beef, BibTeX, Bicep, BlitzBasic, BNF, BQN, Brainfuck +| C | C, C#, C++, Caddyfile, Caddyfile Directives, Cap'n Proto, Cassandra CQL, Ceylon, CFEngine3, cfstatement, ChaiScript, Chapel, Cheetah, Clojure, CMake, COBOL, CoffeeScript, Common Lisp, Coq, Core, Crystal, CSS, CSV, CUE, Cython +| D | D, Dart, Dax, Desktop file, Diff, Django/Jinja, dns, Docker, DTD, Dylan +| E | EBNF, Elixir, Elm, EmacsLisp, Erlang +| F | Factor, Fennel, Fish, Forth, Fortran, FortranFixed, FSharp +| G | GAS, GDScript, GDScript3, Gemtext, Genshi, Genshi HTML, Genshi Text, Gherkin, Gleam, GLSL, Gnuplot, Go, Go HTML Template, Go Template, Go Text Template, GraphQL, Groff, Groovy +| H | Handlebars, Hare, Haskell, Haxe, HCL, Hexdump, HLB, HLSL, HolyC, HTML, HTTP, Hy +| I | Idris, Igor, INI, Io, ISCdhcpd +| J | J, Janet, Java, JavaScript, JSON, JSONata, Jsonnet, Julia, Jungle +| K | Kotlin +| L | Lean4, Lighttpd configuration file, LLVM, lox, Lua +| M | Makefile, Mako, markdown, Mason, Materialize SQL dialect, Mathematica, Matlab, MCFunction, Meson, Metal, MiniZinc, MLIR, Modula-2, Mojo, MonkeyC, MoonScript, MorrowindScript, Myghty, MySQL +| N | NASM, Natural, NDISASM, Newspeak, Nginx configuration file, Nim, Nix, NSIS, Nu +| O | Objective-C, ObjectPascal, OCaml, Octave, Odin, OnesEnterprise, OpenEdge ABL, OpenSCAD, Org Mode +| P | PacmanConf, Perl, PHP, PHTML, Pig, PkgConfig, PL/pgSQL, plaintext, Plutus Core, Pony, PostgreSQL SQL dialect, PostScript, POVRay, PowerQuery, PowerShell, Prolog, Promela, PromQL, properties, Protocol Buffer, PRQL, PSL, Puppet, Python, Python 2 +| Q | QBasic, QML +| R | R, Racket, Ragel, Raku, react, ReasonML, reg, Rego, reStructuredText, Rexx, RPGLE, RPMSpec, Ruby, Rust +| S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, SNBT, Snobol, Solidity, SourcePawn, SPARQL, SQL, SquidConf, Standard ML, stas, Stylus, Svelte, Swift, SYSTEMD, systemverilog +| T | TableGen, Tal, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData, Typst +| U | ucode +| V | V, V shell, Vala, VB.net, verilog, VHDL, VHS, VimL, vue +| W | WDTE, WebGPU Shading Language, WebVTT, Whiley +| X | XML, Xorg +| Y | YAML, YANG +| Z | Z80 Assembly, Zed, Zig _I will attempt to keep this section up to date, but an authoritative list can be displayed with `chroma --list`._ diff --git a/vendor/github.com/alecthomas/chroma/v2/biome.json b/vendor/github.com/alecthomas/chroma/v2/biome.json new file mode 100644 index 0000000000..a5bec2e194 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/biome.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.0.5/schema.json", + "formatter": { + "indentStyle": "space" + } +} diff --git a/vendor/github.com/alecthomas/chroma/v2/delegate.go b/vendor/github.com/alecthomas/chroma/v2/delegate.go index f848194f68..298f2dbbd1 100644 --- a/vendor/github.com/alecthomas/chroma/v2/delegate.go +++ b/vendor/github.com/alecthomas/chroma/v2/delegate.go @@ -24,6 +24,15 @@ func DelegatingLexer(root Lexer, language Lexer) Lexer { } } +func (d *delegatingLexer) SetTracing(enable bool) { + if l, ok := d.language.(TracingLexer); ok { + l.SetTracing(enable) + } + if l, ok := d.root.(TracingLexer); ok { + l.SetTracing(enable) + } +} + func (d *delegatingLexer) AnalyseText(text string) float32 { return d.root.AnalyseText(text) } diff --git a/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go b/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go index 92d784c245..c1c8875b2d 100644 --- a/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go +++ b/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go @@ -34,6 +34,9 @@ func WithCustomCSS(css map[chroma.TokenType]string) Option { } } +// WithCSSComments adds prefixe comments to the css classes. Defaults to true. +func WithCSSComments(b bool) Option { return func(f *Formatter) { f.writeCSSComments = b } } + // TabWidth sets the number of characters for a tab. Defaults to 8. func TabWidth(width int) Option { return func(f *Formatter) { f.tabWidth = width } } @@ -131,8 +134,9 @@ func BaseLineNumber(n int) Option { // New HTML formatter. func New(options ...Option) *Formatter { f := &Formatter{ - baseLineNumber: 1, - preWrapper: defaultPreWrapper, + baseLineNumber: 1, + preWrapper: defaultPreWrapper, + writeCSSComments: true, } f.styleCache = newStyleCache(f) for _, option := range options { @@ -197,6 +201,7 @@ type Formatter struct { Classes bool // Exported field to detect when classes are being used allClasses bool customCSS map[chroma.TokenType]string + writeCSSComments bool preWrapper PreWrapper inlineCode bool preventSurroundingPre bool @@ -416,21 +421,37 @@ func (f *Formatter) tabWidthStyle() string { return "" } +func (f *Formatter) writeCSSRule(w io.Writer, comment string, selector string, styles string) error { + if styles == "" { + return nil + } + if f.writeCSSComments && comment != "" { + if _, err := fmt.Fprintf(w, "/* %s */ ", comment); err != nil { + return err + } + } + if _, err := fmt.Fprintf(w, "%s { %s }\n", selector, styles); err != nil { + return err + } + return nil +} + // WriteCSS writes CSS style definitions (without any surrounding HTML). func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error { css := f.styleCache.get(style, false) + // Special-case background as it is mapped to the outer ".chroma" class. - if _, err := fmt.Fprintf(w, "/* %s */ .%sbg { %s }\n", chroma.Background, f.prefix, css[chroma.Background]); err != nil { + if err := f.writeCSSRule(w, chroma.Background.String(), fmt.Sprintf(".%sbg", f.prefix), css[chroma.Background]); err != nil { return err } // Special-case PreWrapper as it is the ".chroma" class. - if _, err := fmt.Fprintf(w, "/* %s */ .%schroma { %s }\n", chroma.PreWrapper, f.prefix, css[chroma.PreWrapper]); err != nil { + if err := f.writeCSSRule(w, chroma.PreWrapper.String(), fmt.Sprintf(".%schroma", f.prefix), css[chroma.PreWrapper]); err != nil { return err } // Special-case code column of table to expand width. if f.lineNumbers && f.lineNumbersInTable { - if _, err := fmt.Fprintf(w, "/* %s */ .%schroma .%s:last-child { width: 100%%; }", - chroma.LineTableTD, f.prefix, f.class(chroma.LineTableTD)); err != nil { + selector := fmt.Sprintf(".%schroma .%s:last-child", f.prefix, f.class(chroma.LineTableTD)) + if err := f.writeCSSRule(w, chroma.LineTableTD.String(), selector, "width: 100%;"); err != nil { return err } } @@ -438,7 +459,11 @@ func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error { if f.lineNumbers || f.lineNumbersInTable { targetedLineCSS := StyleEntryToCSS(style.Get(chroma.LineHighlight)) for _, tt := range []chroma.TokenType{chroma.LineNumbers, chroma.LineNumbersTable} { - fmt.Fprintf(w, "/* %s targeted by URL anchor */ .%schroma .%s:target { %s }\n", tt, f.prefix, f.class(tt), targetedLineCSS) + comment := fmt.Sprintf("%s targeted by URL anchor", tt) + selector := fmt.Sprintf(".%schroma .%s:target", f.prefix, f.class(tt)) + if err := f.writeCSSRule(w, comment, selector, targetedLineCSS); err != nil { + return err + } } } tts := []int{} @@ -456,8 +481,7 @@ func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error { if class == "" { continue } - styles := css[tt] - if _, err := fmt.Fprintf(w, "/* %s */ .%schroma .%s { %s }\n", tt, f.prefix, class, styles); err != nil { + if err := f.writeCSSRule(w, tt.String(), fmt.Sprintf(".%schroma .%s", f.prefix, class), css[tt]); err != nil { return err } } diff --git a/vendor/github.com/alecthomas/chroma/v2/lexer.go b/vendor/github.com/alecthomas/chroma/v2/lexer.go index eb027bf698..602db1c4f0 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexer.go +++ b/vendor/github.com/alecthomas/chroma/v2/lexer.go @@ -130,6 +130,23 @@ type Lexer interface { AnalyseText(text string) float32 } +// Trace is the trace of a tokenisation process. +type Trace struct { + Lexer string `json:"lexer"` + State string `json:"state"` + Rule int `json:"rule"` + Pattern string `json:"pattern"` + Pos int `json:"pos"` + Length int `json:"length"` + Elapsed float64 `json:"elapsedMs"` // Elapsed time spent matching for this rule. +} + +// TracingLexer is a Lexer that can trace its tokenisation process. +type TracingLexer interface { + Lexer + SetTracing(enable bool) +} + // Lexers is a slice of lexers sortable by name. type Lexers []Lexer diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/css.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/css.xml index 6e370c763e..5491fe4643 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/css.xml +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/css.xml @@ -191,7 +191,7 @@ - + @@ -320,4 +320,4 @@ - \ No newline at end of file + diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/docker.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/docker.xml index c335188580..261834f425 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/docker.xml +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/docker.xml @@ -3,10 +3,14 @@ Docker docker dockerfile + containerfile Dockerfile Dockerfile.* *.Dockerfile *.docker + Containerfile + Containerfile.* + *.Containerfile text/x-dockerfile-config true @@ -40,9 +44,16 @@ - + + + + + + diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/lox.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/lox.xml new file mode 100644 index 0000000000..602885a205 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/lox.xml @@ -0,0 +1,83 @@ + + + lox + *.lox + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nu.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nu.xml new file mode 100644 index 0000000000..326558086c --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/nu.xml @@ -0,0 +1,121 @@ + + + Nu + nu + *.nu + text/plain + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/objectpascal.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/objectpascal.xml index 12af64b9df..0b7213121b 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/objectpascal.xml +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/objectpascal.xml @@ -31,12 +31,9 @@ - - - - - - + + + diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/toml.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/toml.xml index 9c98ba534c..87bd19df4b 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/toml.xml +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/toml.xml @@ -5,6 +5,7 @@ *.toml Pipfile poetry.lock + uv.lock text/x-toml diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/gemtext.go b/vendor/github.com/alecthomas/chroma/v2/lexers/gemtext.go new file mode 100644 index 0000000000..2fed8d62f6 --- /dev/null +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/gemtext.go @@ -0,0 +1,37 @@ +package lexers + +import ( + . "github.com/alecthomas/chroma/v2" // nolint +) + +// Gemtext lexer. +var Gemtext = Register(MustNewLexer( + &Config{ + Name: "Gemtext", + Aliases: []string{"gemtext", "gmi", "gmni", "gemini"}, + Filenames: []string{"*.gmi", "*.gmni", "*.gemini"}, + MimeTypes: []string{"text/gemini"}, + }, + gemtextRules, +)) + +func gemtextRules() Rules { + return Rules{ + "root": { + {`^(#[^#].+\r?\n)`, ByGroups(GenericHeading), nil}, + {`^(#{2,3}.+\r?\n)`, ByGroups(GenericSubheading), nil}, + {`^(\* )(.+\r?\n)`, ByGroups(Keyword, Text), nil}, + {`^(>)(.+\r?\n)`, ByGroups(Keyword, GenericEmph), nil}, + {"^(```\\r?\\n)([\\w\\W]*?)(^```)(.+\\r?\\n)?", ByGroups(String, Text, String, Comment), nil}, + { + "^(```)(\\w+)(\\r?\\n)([\\w\\W]*?)(^```)(.+\\r?\\n)?", + UsingByGroup(2, 4, String, String, String, Text, String, Comment), + nil, + }, + {"^(```)(.+\\r?\\n)([\\w\\W]*?)(^```)(.+\\r?\\n)?", ByGroups(String, String, Text, String, Comment), nil}, + {`^(=>)(\s*)([^\s]+)(\s*)$`, ByGroups(Keyword, Text, NameAttribute, Text), nil}, + {`^(=>)(\s*)([^\s]+)(\s+)(.+)$`, ByGroups(Keyword, Text, NameAttribute, Text, NameTag), nil}, + {`(.|(?:\r?\n))`, ByGroups(Text), nil}, + }, + } +} diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/go.go b/vendor/github.com/alecthomas/chroma/v2/lexers/go.go index 60b1f71198..c6123b9071 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/go.go +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/go.go @@ -28,10 +28,10 @@ var Go = Register(MustNewLexer( func goRules() Rules { return Rules{ "root": { - {`\n`, Text, nil}, - {`\s+`, Text, nil}, - {`\\\n`, Text, nil}, - {`//[^\n\r]*`, CommentSingle, nil}, + {`\n`, TextWhitespace, nil}, + {`\s+`, TextWhitespace, nil}, + {`//[^\s][^\n\r]*`, CommentPreproc, nil}, + {`//\s+[^\n\r]*`, CommentSingle, nil}, {`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil}, {`(import|package)\b`, KeywordNamespace, nil}, {`(var|func|struct|map|chan|type|interface|const)\b`, KeywordDeclaration, nil}, diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go b/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go index db5a89484f..bcd5b17841 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/markdown.go @@ -5,7 +5,7 @@ import ( ) // Markdown lexer. -var Markdown = Register(DelegatingLexer(HTML, MustNewLexer( +var Markdown = Register(MustNewLexer( &Config{ Name: "markdown", Aliases: []string{"md", "mkd"}, @@ -13,7 +13,7 @@ var Markdown = Register(DelegatingLexer(HTML, MustNewLexer( MimeTypes: []string{"text/x-markdown"}, }, markdownRules, -))) +)) func markdownRules() Rules { return Rules{ @@ -40,7 +40,7 @@ func markdownRules() Rules { {"`[^`]+`", LiteralStringBacktick, nil}, {`[@#][\w/:]+`, NameEntity, nil}, {`(!?\[)([^]]+)(\])(\()([^)]+)(\))`, ByGroups(Text, NameTag, Text, Text, NameAttribute, Text), nil}, - {`.|\n`, Other, nil}, + {`.|\n`, Text, nil}, }, } } diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/raku.go b/vendor/github.com/alecthomas/chroma/v2/lexers/raku.go index 49e03a4d55..da354dce61 100644 --- a/vendor/github.com/alecthomas/chroma/v2/lexers/raku.go +++ b/vendor/github.com/alecthomas/chroma/v2/lexers/raku.go @@ -2,6 +2,7 @@ package lexers import ( "regexp" + "slices" "strings" "unicode/utf8" @@ -1318,16 +1319,6 @@ func indexAt(str []rune, substr []rune, pos int) int { return idx } -// Tells if an array of string contains a string -func contains(s []string, e string) bool { - for _, value := range s { - if value == e { - return true - } - } - return false -} - type rulePosition int const ( @@ -1625,15 +1616,15 @@ func quote(groups []string, state *LexerState) Iterator { var tokenState string switch { - case keyword == "qq" || contains(tokenStates, "qq"): + case keyword == "qq" || slices.Contains(tokenStates, "qq"): tokenState = "qq" - case adverbsStr == "ww" || contains(tokenStates, "ww"): + case adverbsStr == "ww" || slices.Contains(tokenStates, "ww"): tokenState = "ww" - case contains(tokenStates, "Q-closure") && contains(tokenStates, "Q-variable"): + case slices.Contains(tokenStates, "Q-closure") && slices.Contains(tokenStates, "Q-variable"): tokenState = "qq" - case contains(tokenStates, "Q-closure"): + case slices.Contains(tokenStates, "Q-closure"): tokenState = "Q-closure" - case contains(tokenStates, "Q-variable"): + case slices.Contains(tokenStates, "Q-variable"): tokenState = "Q-variable" default: tokenState = "Q" diff --git a/vendor/github.com/alecthomas/chroma/v2/regexp.go b/vendor/github.com/alecthomas/chroma/v2/regexp.go index 8d0bd4a00e..c0e5e10818 100644 --- a/vendor/github.com/alecthomas/chroma/v2/regexp.go +++ b/vendor/github.com/alecthomas/chroma/v2/regexp.go @@ -1,6 +1,7 @@ package chroma import ( + "encoding/json" "fmt" "os" "path/filepath" @@ -135,11 +136,20 @@ func NewLexer(config *Config, rulesFunc func() Rules) (*RegexLexer, error) { } // Trace enables debug tracing. +// +// Deprecated: Use SetTracing instead. func (r *RegexLexer) Trace(trace bool) *RegexLexer { r.trace = trace return r } +// SetTracing enables debug tracing. +// +// This complies with the [TracingLexer] interface. +func (r *RegexLexer) SetTracing(trace bool) { + r.trace = trace +} + // A CompiledRule is a Rule with a pre-compiled regex. // // Note that regular expressions are lazily compiled on first use of the lexer. @@ -185,6 +195,7 @@ func (l *LexerState) Get(key interface{}) interface{} { // Iterator returns the next Token from the lexer. func (l *LexerState) Iterator() Token { // nolint: gocognit + trace := json.NewEncoder(os.Stderr) end := len(l.Text) if l.newlineAdded { end-- @@ -205,14 +216,33 @@ func (l *LexerState) Iterator() Token { // nolint: gocognit } l.State = l.Stack[len(l.Stack)-1] - if l.Lexer.trace { - fmt.Fprintf(os.Stderr, "%s: pos=%d, text=%q\n", l.State, l.Pos, string(l.Text[l.Pos:])) - } selectedRule, ok := l.Rules[l.State] if !ok { panic("unknown state " + l.State) } + var start time.Time + if l.Lexer.trace { + start = time.Now() + } ruleIndex, rule, groups, namedGroups := matchRules(l.Text, l.Pos, selectedRule) + if l.Lexer.trace { + var length int + if groups != nil { + length = len(groups[0]) + } else { + length = -1 + } + _ = trace.Encode(Trace{ //nolint + Lexer: l.Lexer.config.Name, + State: l.State, + Rule: ruleIndex, + Pattern: rule.Pattern, + Pos: l.Pos, + Length: length, + Elapsed: float64(time.Since(start)) / float64(time.Millisecond), + }) + // fmt.Fprintf(os.Stderr, "%s: pos=%d, text=%q, elapsed=%s\n", l.State, l.Pos, string(l.Text[l.Pos:]), time.Since(start)) + } // No match. if groups == nil { // From Pygments :\ diff --git a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml index 0adf1ba9e3..66a361fb71 100644 --- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml +++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml @@ -65,12 +65,12 @@ - + - + @@ -80,4 +80,4 @@ - \ No newline at end of file + diff --git a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml index 3ea767fd4a..c87c8765d0 100644 --- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml +++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml @@ -65,12 +65,12 @@ - + - + @@ -80,4 +80,4 @@ - \ No newline at end of file + diff --git a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml index 6b50028487..5dba9c6474 100644 --- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml +++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml @@ -65,12 +65,12 @@ - + - + @@ -80,4 +80,4 @@ - \ No newline at end of file + diff --git a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml index 9a401912f3..9f9b9152a0 100644 --- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml +++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml @@ -65,12 +65,12 @@ - + - + @@ -80,4 +80,4 @@ - \ No newline at end of file + diff --git a/vendor/modules.txt b/vendor/modules.txt index f10bdd2708..397bf67f1a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -298,7 +298,7 @@ github.com/NYTimes/gziphandler ## explicit; go 1.15 github.com/Workiva/go-datastructures/rangetree github.com/Workiva/go-datastructures/slice -# github.com/alecthomas/chroma/v2 v2.19.0 +# github.com/alecthomas/chroma/v2 v2.20.0 ## explicit; go 1.22 github.com/alecthomas/chroma/v2 github.com/alecthomas/chroma/v2/formatters