diff --git a/go.mod b/go.mod
index 0e6ca5c..7096450 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module seedno.de/seednode/roulette
go 1.22
require (
- github.com/alecthomas/chroma/v2 v2.12.0
+ github.com/alecthomas/chroma/v2 v2.13.0
github.com/julienschmidt/httprouter v1.3.0
github.com/klauspost/compress v1.17.7
github.com/spf13/cobra v1.8.0
diff --git a/go.sum b/go.sum
index bb4fffc..16e3f80 100644
--- a/go.sum
+++ b/go.sum
@@ -1,9 +1,9 @@
-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/chroma/v2 v2.12.0 h1:Wh8qLEgMMsN7mgyG8/qIpegky2Hvzr4By6gEF7cmWgw=
-github.com/alecthomas/chroma/v2 v2.12.0/go.mod h1:4TQu7gdfuPjSh76j78ietmqh9LiurGF0EpseFXdKMBw=
-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/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
+github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
+github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
+github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
+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/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
diff --git a/vendor/github.com/alecthomas/chroma/v2/.editorconfig b/vendor/github.com/alecthomas/chroma/v2/.editorconfig
index d80374e..cfb2c66 100644
--- a/vendor/github.com/alecthomas/chroma/v2/.editorconfig
+++ b/vendor/github.com/alecthomas/chroma/v2/.editorconfig
@@ -11,3 +11,7 @@ insert_final_newline = true
indent_style = space
indent_size = 2
insert_final_newline = false
+
+[*.yml]
+indent_style = space
+indent_size = 2
diff --git a/vendor/github.com/alecthomas/chroma/v2/.golangci.yml b/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
index 120ea71..668be37 100644
--- a/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
+++ b/vendor/github.com/alecthomas/chroma/v2/.golangci.yml
@@ -49,6 +49,8 @@ linters:
- nosnakecase
- testableexamples
- musttag
+ - depguard
+ - goconst
linters-settings:
govet:
diff --git a/vendor/github.com/alecthomas/chroma/v2/README.md b/vendor/github.com/alecthomas/chroma/v2/README.md
index 6c347a0..775d3af 100644
--- a/vendor/github.com/alecthomas/chroma/v2/README.md
+++ b/vendor/github.com/alecthomas/chroma/v2/README.md
@@ -8,75 +8,72 @@ highlighted HTML, ANSI-coloured text, etc.
Chroma is based heavily on [Pygments](http://pygments.org/), and includes
translators for Pygments lexers and styles.
-
-
## Table of Contents
-1. [Table of Contents](#table-of-contents)
-2. [Supported languages](#supported-languages)
-3. [Try it](#try-it)
-4. [Using the library](#using-the-library)
+1. [Supported languages](#supported-languages)
+2. [Try it](#try-it)
+3. [Using the library](#using-the-library)
1. [Quick start](#quick-start)
2. [Identifying the language](#identifying-the-language)
3. [Formatting the output](#formatting-the-output)
4. [The HTML formatter](#the-html-formatter)
-5. [More detail](#more-detail)
+4. [More detail](#more-detail)
1. [Lexers](#lexers)
2. [Formatters](#formatters)
3. [Styles](#styles)
-6. [Command-line interface](#command-line-interface)
-7. [Testing lexers](#testing-lexers)
-8. [What's missing compared to Pygments?](#whats-missing-compared-to-pygments)
+5. [Command-line interface](#command-line-interface)
+6. [Testing lexers](#testing-lexers)
+7. [What's missing compared to Pygments?](#whats-missing-compared-to-pygments)
-
-
## 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, 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, 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, Julia, Jungle |
-| K | Kotlin |
-| L | Lighttpd configuration file, LLVM, Lua |
-| M | Makefile, Mako, markdown, Mason, Mathematica, Matlab, mcfunction, Meson, Metal, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL |
-| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix |
-| 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, properties, Protocol Buffer, PRQL, PSL, Puppet, Python, Python 2 |
-| Q | QBasic, QML |
-| R | R, Racket, Ragel, Raku, react, ReasonML, reg, reStructuredText, Rexx, Ruby, Rust |
-| S | SAS, Sass, Scala, Scheme, Scilab, SCSS, Sed, Sieve, Smali, Smalltalk, Smarty, 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 |
-| 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, 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, 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, Julia, Jungle |
+| K | Kotlin |
+| L | Lighttpd configuration file, LLVM, Lua |
+| M | Makefile, Mako, markdown, Mason, Materialize SQL dialect, Mathematica, Matlab, mcfunction, Meson, Metal, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL |
+| N | NASM, Natural, Newspeak, Nginx configuration file, Nim, Nix |
+| 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, 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 |
+| 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 |
_I will attempt to keep this section up to date, but an authoritative list can be
displayed with `chroma --list`._
-
-
## Try it
Try out various languages and styles on the [Chroma Playground](https://swapoff.org/chroma/playground/).
-
-
## Using the library
+This is version 2 of Chroma, use the import path:
+
+```go
+import "github.com/alecthomas/chroma/v2"
+```
+
Chroma, like Pygments, has the concepts of
[lexers](https://github.com/alecthomas/chroma/tree/master/lexers),
[formatters](https://github.com/alecthomas/chroma/tree/master/formatters) and
@@ -95,8 +92,6 @@ In all cases, if a lexer, formatter or style can not be determined, `nil` will
be returned. In this situation you may want to default to the `Fallback`
value in each respective package, which provides sane defaults.
-
-
### Quick start
A convenience function exists that can be used to simply format some source
@@ -106,8 +101,6 @@ text, without any effort:
err := quick.Highlight(os.Stdout, someSourceCode, "go", "html", "monokai")
```
-
-
### Identifying the language
To highlight code, you'll first have to identify what language the code is
@@ -147,8 +140,6 @@ token types into a single token:
lexer = chroma.Coalesce(lexer)
```
-
-
### Formatting the output
Once a language is identified you will need to pick a formatter and a style (theme).
@@ -177,8 +168,6 @@ And finally, format the tokens from the iterator:
err := formatter.Format(w, style, iterator)
```
-
-
### The HTML formatter
By default the `html` registered formatter generates standalone HTML with
@@ -203,12 +192,8 @@ formatter := html.New(html.WithClasses(true))
err := formatter.WriteCSS(w, style)
```
-
-
## More detail
-
-
### Lexers
See the [Pygments documentation](http://pygments.org/docs/lexerdevelopment/)
@@ -228,8 +213,6 @@ python3 _tools/pygments2chroma_xml.py \
See notes in [pygments-lexers.txt](https://github.com/alecthomas/chroma/blob/master/pygments-lexers.txt)
for a list of lexers, and notes on some of the issues importing them.
-
-
### Formatters
Chroma supports HTML output, as well as terminal output in 8 colour, 256 colour, and true-colour.
@@ -237,8 +220,6 @@ Chroma supports HTML output, as well as terminal output in 8 colour, 256 colour,
A `noop` formatter is included that outputs the token text only, and a `tokens`
formatter outputs raw tokens. The latter is useful for debugging lexers.
-
-
### Styles
Chroma styles are defined in XML. The style entries use the
@@ -262,8 +243,6 @@ Also, token types in a style file are hierarchical. For instance, when `CommentS
For a quick overview of the available styles and how they look, check out the [Chroma Style Gallery](https://xyproto.github.io/splash/docs/).
-
-
## Command-line interface
A command-line interface to Chroma is included.
@@ -288,10 +267,6 @@ on under the hood for easy integration with [lesspipe shipping with
Debian and derivatives](https://manpages.debian.org/lesspipe#USER_DEFINED_FILTERS);
for that setup the `chroma` executable can be just symlinked to `~/.lessfilter`.
-
-
-
-
## Testing lexers
If you edit some lexers and want to try it, open a shell in `cmd/chromad` and run:
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 0ad6b31..92d784c 100644
--- a/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
+++ b/vendor/github.com/alecthomas/chroma/v2/formatters/html/html.go
@@ -5,7 +5,9 @@ import (
"html"
"io"
"sort"
+ "strconv"
"strings"
+ "sync"
"github.com/alecthomas/chroma/v2"
)
@@ -132,6 +134,7 @@ func New(options ...Option) *Formatter {
baseLineNumber: 1,
preWrapper: defaultPreWrapper,
}
+ f.styleCache = newStyleCache(f)
for _, option := range options {
option(f)
}
@@ -188,6 +191,7 @@ var (
// Formatter that generates HTML.
type Formatter struct {
+ styleCache *styleCache
standalone bool
prefix string
Classes bool // Exported field to detect when classes are being used
@@ -220,12 +224,7 @@ func (f *Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Ite
//
// OTOH we need to be super careful about correct escaping...
func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.Token) (err error) { // nolint: gocyclo
- css := f.styleToCSS(style)
- if !f.Classes {
- for t, style := range css {
- css[t] = compressStyle(style)
- }
- }
+ css := f.styleCache.get(style, true)
if f.standalone {
fmt.Fprint(w, "\n")
if f.Classes {
@@ -243,7 +242,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 +250,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 +272,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 +322,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")
@@ -419,7 +418,7 @@ func (f *Formatter) tabWidthStyle() string {
// WriteCSS writes CSS style definitions (without any surrounding HTML).
func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error {
- css := f.styleToCSS(style)
+ 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 {
return err
@@ -562,3 +561,63 @@ func compressStyle(s string) string {
}
return strings.Join(out, ";")
}
+
+const styleCacheLimit = 32
+
+type styleCacheEntry struct {
+ style *chroma.Style
+ compressed bool
+ cache map[chroma.TokenType]string
+}
+
+type styleCache struct {
+ mu sync.Mutex
+ // LRU cache of compiled (and possibly compressed) styles. This is a slice
+ // because the cache size is small, and a slice is sufficiently fast for
+ // small N.
+ cache []styleCacheEntry
+ f *Formatter
+}
+
+func newStyleCache(f *Formatter) *styleCache {
+ return &styleCache{f: f}
+}
+
+func (l *styleCache) get(style *chroma.Style, compress bool) map[chroma.TokenType]string {
+ l.mu.Lock()
+ defer l.mu.Unlock()
+
+ // Look for an existing entry.
+ for i := len(l.cache) - 1; i >= 0; i-- {
+ entry := l.cache[i]
+ if entry.style == style && entry.compressed == compress {
+ // Top of the cache, no need to adjust the order.
+ if i == len(l.cache)-1 {
+ return entry.cache
+ }
+ // Move this entry to the end of the LRU
+ copy(l.cache[i:], l.cache[i+1:])
+ l.cache[len(l.cache)-1] = entry
+ return entry.cache
+ }
+ }
+
+ // No entry, create one.
+ cached := l.f.styleToCSS(style)
+ if !l.f.Classes {
+ for t, style := range cached {
+ cached[t] = compressStyle(style)
+ }
+ }
+ if compress {
+ for t, style := range cached {
+ cached[t] = compressStyle(style)
+ }
+ }
+ // Evict the oldest entry.
+ if len(l.cache) >= styleCacheLimit {
+ l.cache = l.cache[0:copy(l.cache, l.cache[1:])]
+ }
+ l.cache = append(l.cache, styleCacheEntry{style: style, cache: cached, compressed: compress})
+ return cached
+}
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go b/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go
index 9100efa..82a7efa 100644
--- a/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/caddyfile.go
@@ -4,52 +4,82 @@ import (
. "github.com/alecthomas/chroma/v2" // nolint
)
+// Matcher token stub for docs, or
+// Named matcher: @name, or
+// Path matcher: /foo, or
+// Wildcard path matcher: *
+// nolint: gosec
+var caddyfileMatcherTokenRegexp = `(\[\
\]|@[^\s]+|/[^\s]+|\*)`
+
+// Comment at start of line, or
+// Comment preceded by whitespace
+var caddyfileCommentRegexp = `(^|\s+)#.*\n`
+
// caddyfileCommon are the rules common to both of the lexer variants
func caddyfileCommonRules() Rules {
return Rules{
"site_block_common": {
+ Include("site_body"),
+ // Any other directive
+ {`[^\s#]+`, Keyword, Push("directive")},
+ Include("base"),
+ },
+ "site_body": {
// Import keyword
- {`(import)(\s+)([^\s]+)`, ByGroups(Keyword, Text, NameVariableMagic), nil},
+ {`\b(import|invoke)\b( [^\s#]+)`, ByGroups(Keyword, Text), Push("subdirective")},
// Matcher definition
{`@[^\s]+(?=\s)`, NameDecorator, Push("matcher")},
// Matcher token stub for docs
{`\[\\]`, NameDecorator, Push("matcher")},
// These cannot have matchers but may have things that look like
// matchers in their arguments, so we just parse as a subdirective.
- {`try_files`, Keyword, Push("subdirective")},
+ {`\b(try_files|tls|log|bind)\b`, Keyword, Push("subdirective")},
// These are special, they can nest more directives
- {`handle_errors|handle|route|handle_path|not`, Keyword, Push("nested_directive")},
- // Any other directive
- {`[^\s#]+`, Keyword, Push("directive")},
- Include("base"),
+ {`\b(handle_errors|handle_path|handle_response|replace_status|handle|route)\b`, Keyword, Push("nested_directive")},
+ // uri directive has special syntax
+ {`\b(uri)\b`, Keyword, Push("uri_directive")},
},
"matcher": {
{`\{`, Punctuation, Push("block")},
// Not can be one-liner
{`not`, Keyword, Push("deep_not_matcher")},
+ // Heredoc for CEL expression
+ Include("heredoc"),
+ // Backtick for CEL expression
+ {"`", StringBacktick, Push("backticks")},
// Any other same-line matcher
{`[^\s#]+`, Keyword, Push("arguments")},
// Terminators
- {`\n`, Text, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
{`\}`, Punctuation, Pop(1)},
Include("base"),
},
"block": {
{`\}`, Punctuation, Pop(2)},
+ // Using double quotes doesn't stop at spaces
+ {`"`, StringDouble, Push("double_quotes")},
+ // Using backticks doesn't stop at spaces
+ {"`", StringBacktick, Push("backticks")},
// Not can be one-liner
{`not`, Keyword, Push("not_matcher")},
- // Any other subdirective
+ // Directives & matcher definitions
+ Include("site_body"),
+ // Any directive
{`[^\s#]+`, Keyword, Push("subdirective")},
Include("base"),
},
"nested_block": {
{`\}`, Punctuation, Pop(2)},
- // Matcher definition
- {`@[^\s]+(?=\s)`, NameDecorator, Push("matcher")},
- // Something that starts with literally < is probably a docs stub
- {`\<[^#]+\>`, Keyword, Push("nested_directive")},
- // Any other directive
- {`[^\s#]+`, Keyword, Push("nested_directive")},
+ // Using double quotes doesn't stop at spaces
+ {`"`, StringDouble, Push("double_quotes")},
+ // Using backticks doesn't stop at spaces
+ {"`", StringBacktick, Push("backticks")},
+ // Not can be one-liner
+ {`not`, Keyword, Push("not_matcher")},
+ // Directives & matcher definitions
+ Include("site_body"),
+ // Any other subdirective
+ {`[^\s#]+`, Keyword, Push("directive")},
Include("base"),
},
"not_matcher": {
@@ -66,69 +96,97 @@ func caddyfileCommonRules() Rules {
},
"directive": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("matcher_token"),
- Include("comments_pop_1"),
- {`\n`, Text, Pop(1)},
+ {caddyfileMatcherTokenRegexp, NameDecorator, Push("arguments")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
"nested_directive": {
{`\{(?=\s)`, Punctuation, Push("nested_block")},
- Include("matcher_token"),
- Include("comments_pop_1"),
- {`\n`, Text, Pop(1)},
+ {caddyfileMatcherTokenRegexp, NameDecorator, Push("nested_arguments")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
"subdirective": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("comments_pop_1"),
- {`\n`, Text, Pop(1)},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
Include("base"),
},
"arguments": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("comments_pop_2"),
+ {caddyfileCommentRegexp, CommentSingle, Pop(2)},
{`\\\n`, Text, nil}, // Skip escaped newlines
- {`\n`, Text, Pop(2)},
+ {`\s*\n`, Text, Pop(2)},
+ Include("base"),
+ },
+ "nested_arguments": {
+ {`\{(?=\s)`, Punctuation, Push("nested_block")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(2)},
+ {`\\\n`, Text, nil}, // Skip escaped newlines
+ {`\s*\n`, Text, Pop(2)},
Include("base"),
},
"deep_subdirective": {
{`\{(?=\s)`, Punctuation, Push("block")},
- Include("comments_pop_3"),
- {`\n`, Text, Pop(3)},
+ {caddyfileCommentRegexp, CommentSingle, Pop(3)},
+ {`\s*\n`, Text, Pop(3)},
Include("base"),
},
- "matcher_token": {
- {`@[^\s]+`, NameDecorator, Push("arguments")}, // Named matcher
- {`/[^\s]+`, NameDecorator, Push("arguments")}, // Path matcher
- {`\*`, NameDecorator, Push("arguments")}, // Wildcard path matcher
- {`\[\\]`, NameDecorator, Push("arguments")}, // Matcher token stub for docs
+ "uri_directive": {
+ {`\{(?=\s)`, Punctuation, Push("block")},
+ {caddyfileMatcherTokenRegexp, NameDecorator, nil},
+ {`(strip_prefix|strip_suffix|replace|path_regexp)`, NameConstant, Push("arguments")},
+ {caddyfileCommentRegexp, CommentSingle, Pop(1)},
+ {`\s*\n`, Text, Pop(1)},
+ Include("base"),
},
- "comments": {
- {`^#.*\n`, CommentSingle, nil}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, nil}, // Comment preceded by whitespace
+ "double_quotes": {
+ Include("placeholder"),
+ {`\\"`, StringDouble, nil},
+ {`[^"]`, StringDouble, nil},
+ {`"`, StringDouble, Pop(1)},
},
- "comments_pop_1": {
- {`^#.*\n`, CommentSingle, Pop(1)}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, Pop(1)}, // Comment preceded by whitespace
+ "backticks": {
+ Include("placeholder"),
+ {"\\\\`", StringBacktick, nil},
+ {"[^`]", StringBacktick, nil},
+ {"`", StringBacktick, Pop(1)},
},
- "comments_pop_2": {
- {`^#.*\n`, CommentSingle, Pop(2)}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, Pop(2)}, // Comment preceded by whitespace
+ "optional": {
+ // Docs syntax for showing optional parts with [ ]
+ {`\[`, Punctuation, Push("optional")},
+ Include("name_constants"),
+ {`\|`, Punctuation, nil},
+ {`[^\[\]\|]+`, String, nil},
+ {`\]`, Punctuation, Pop(1)},
},
- "comments_pop_3": {
- {`^#.*\n`, CommentSingle, Pop(3)}, // Comment at start of line
- {`\s+#.*\n`, CommentSingle, Pop(3)}, // Comment preceded by whitespace
+ "heredoc": {
+ {`(<<([a-zA-Z0-9_-]+))(\n(.*|\n)*)(\s*)(\2)`, ByGroups(StringHeredoc, nil, String, String, String, StringHeredoc), nil},
+ },
+ "name_constants": {
+ {`\b(most_recently_modified|largest_size|smallest_size|first_exist|internal|disable_redirects|ignore_loaded_certs|disable_certs|private_ranges|first|last|before|after|on|off)\b(\||(?=\]|\s|$))`, ByGroups(NameConstant, Punctuation), nil},
+ },
+ "placeholder": {
+ // Placeholder with dots, colon for default value, brackets for args[0:]
+ {`\{[\w+.\[\]\:\$-]+\}`, StringEscape, nil},
+ // Handle opening brackets with no matching closing one
+ {`\{[^\}\s]*\b`, String, nil},
},
"base": {
- Include("comments"),
- {`(on|off|first|last|before|after|internal|strip_prefix|strip_suffix|replace)\b`, NameConstant, nil},
- {`(https?://)?([a-z0-9.-]+)(:)([0-9]+)`, ByGroups(Name, Name, Punctuation, LiteralNumberInteger), nil},
- {`[a-z-]+/[a-z-+]+`, LiteralString, nil},
- {`[0-9]+[km]?\b`, LiteralNumberInteger, nil},
- {`\{[\w+.\$-]+\}`, LiteralStringEscape, nil}, // Placeholder
- {`\[(?=[^#{}$]+\])`, Punctuation, nil},
- {`\]|\|`, Punctuation, nil},
- {`[^\s#{}$\]]+`, LiteralString, nil},
+ {caddyfileCommentRegexp, CommentSingle, nil},
+ {`\[\\]`, NameDecorator, nil},
+ Include("name_constants"),
+ Include("heredoc"),
+ {`(https?://)?([a-z0-9.-]+)(:)([0-9]+)([^\s]*)`, ByGroups(Name, Name, Punctuation, NumberInteger, Name), nil},
+ {`\[`, Punctuation, Push("optional")},
+ {"`", StringBacktick, Push("backticks")},
+ {`"`, StringDouble, Push("double_quotes")},
+ Include("placeholder"),
+ {`[a-z-]+/[a-z-+]+`, String, nil},
+ {`[0-9]+([smhdk]|ns|us|µs|ms)?\b`, NumberInteger, nil},
+ {`[^\s\n#\{]+`, String, nil},
{`/[^\s#]*`, Name, nil},
{`\s+`, Text, nil},
},
@@ -149,27 +207,29 @@ var Caddyfile = Register(MustNewLexer(
func caddyfileRules() Rules {
return Rules{
"root": {
- Include("comments"),
+ {caddyfileCommentRegexp, CommentSingle, nil},
// Global options block
{`^\s*(\{)\s*$`, ByGroups(Punctuation), Push("globals")},
+ // Top level import
+ {`(import)(\s+)([^\s]+)`, ByGroups(Keyword, Text, NameVariableMagic), nil},
// Snippets
- {`(\([^\s#]+\))(\s*)(\{)`, ByGroups(NameVariableAnonymous, Text, Punctuation), Push("snippet")},
+ {`(&?\([^\s#]+\))(\s*)(\{)`, ByGroups(NameVariableAnonymous, Text, Punctuation), Push("snippet")},
// Site label
{`[^#{(\s,]+`, GenericHeading, Push("label")},
// Site label with placeholder
- {`\{[\w+.\$-]+\}`, LiteralStringEscape, Push("label")},
+ {`\{[\w+.\[\]\:\$-]+\}`, StringEscape, Push("label")},
{`\s+`, Text, nil},
},
"globals": {
{`\}`, Punctuation, Pop(1)},
- {`[^\s#]+`, Keyword, Push("directive")},
+ // Global options are parsed as subdirectives (no matcher)
+ {`[^\s#]+`, Keyword, Push("subdirective")},
Include("base"),
},
"snippet": {
{`\}`, Punctuation, Pop(1)},
- // Matcher definition
- {`@[^\s]+(?=\s)`, NameDecorator, Push("matcher")},
- // Any directive
+ Include("site_body"),
+ // Any other directive
{`[^\s#]+`, Keyword, Push("directive")},
Include("base"),
},
@@ -179,7 +239,7 @@ func caddyfileRules() Rules {
{`,\s*\n?`, Text, nil},
{` `, Text, nil},
// Site label with placeholder
- {`\{[\w+.\$-]+\}`, LiteralStringEscape, nil},
+ Include("placeholder"),
// Site label
{`[^#{(\s,]+`, GenericHeading, nil},
// Comment after non-block label (hack because comments end in \n)
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml
index 801a954..f1e21db 100644
--- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/c#.xml
@@ -19,10 +19,10 @@
-
+
-
+
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml
index 16d7387..d6c3ea7 100644
--- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/cue.xml
@@ -49,7 +49,7 @@
-
+
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/desktop_entry.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/desktop_entry.xml
new file mode 100644
index 0000000..ad71ad4
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/desktop_entry.xml
@@ -0,0 +1,17 @@
+
+
+ Desktop file
+ desktop
+ desktop_entry
+ *.desktop
+ application/x-desktop
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml
index 6dc6912..5f805d6 100644
--- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/haskell.xml
@@ -86,7 +86,7 @@
-
+
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml
index bbe10b1..3473cfd 100644
--- a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/json.xml
@@ -3,6 +3,7 @@
JSON
json
*.json
+ *.avsc
application/json
true
true
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/materialize_sql_dialect.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/materialize_sql_dialect.xml
new file mode 100644
index 0000000..7b22a46
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/materialize_sql_dialect.xml
@@ -0,0 +1,155 @@
+
+
+ Materialize SQL dialect
+ materialize
+ mzsql
+ text/x-materializesql
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+ 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 12
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/ndisasm.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/ndisasm.xml
new file mode 100644
index 0000000..74d443b
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/ndisasm.xml
@@ -0,0 +1,123 @@
+
+
+ NDISASM
+ ndisasm
+ text/x-disasm
+ true
+ 0.5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/promela.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/promela.xml
new file mode 100644
index 0000000..84558c3
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/promela.xml
@@ -0,0 +1,119 @@
+
+
+
+ Promela
+ promela
+ *.pml
+ *.prom
+ *.prm
+ *.promela
+ *.pr
+ *.pm
+ text/x-promela
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rego.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rego.xml
new file mode 100644
index 0000000..517b713
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rego.xml
@@ -0,0 +1,94 @@
+
+
+ Rego
+ rego
+ *.rego
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rpm_spec.xml b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rpm_spec.xml
new file mode 100644
index 0000000..8362772
--- /dev/null
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/embedded/rpm_spec.xml
@@ -0,0 +1,58 @@
+
+
+
+ RPMSpec
+ spec
+ *.spec
+ text/x-rpm-spec
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/vendor/github.com/alecthomas/chroma/v2/lexers/go.go b/vendor/github.com/alecthomas/chroma/v2/lexers/go.go
index 77bc225..266289b 100644
--- a/vendor/github.com/alecthomas/chroma/v2/lexers/go.go
+++ b/vendor/github.com/alecthomas/chroma/v2/lexers/go.go
@@ -55,7 +55,7 @@ func goRules() Rules {
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`(<<=|>>=|<<|>>|<=|>=|&\^=|&\^|\+=|-=|\*=|/=|%=|&=|\|=|&&|\|\||<-|\+\+|--|==|!=|:=|\.\.\.|[+\-*/%&])`, Operator, nil},
{`([a-zA-Z_]\w*)(\s*)(\()`, ByGroups(NameFunction, UsingSelf("root"), Punctuation), nil},
- {`[|^<>=!()\[\]{}.,;:]`, Punctuation, nil},
+ {`[|^<>=!()\[\]{}.,;:~]`, Punctuation, nil},
{`[^\W\d]\w*`, NameOther, nil},
},
}
diff --git a/vendor/github.com/alecthomas/chroma/v2/renovate.json5 b/vendor/github.com/alecthomas/chroma/v2/renovate.json5
index 897864b..77c7b01 100644
--- a/vendor/github.com/alecthomas/chroma/v2/renovate.json5
+++ b/vendor/github.com/alecthomas/chroma/v2/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,
+ },
+ ],
}
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 08eb42a..0adf1ba 100644
--- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-frappe.xml
@@ -5,7 +5,7 @@
-
+
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 3d51074..3ea767f 100644
--- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-latte.xml
@@ -5,7 +5,7 @@
-
+
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 5d96f59..6b50028 100644
--- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-macchiato.xml
@@ -5,7 +5,7 @@
-
+
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 e17866d..9a40191 100644
--- a/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/styles/catppuccin-mocha.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml b/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml
index 0adb775..711aeaf 100644
--- a/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml
+++ b/vendor/github.com/alecthomas/chroma/v2/styles/github-dark.xml
@@ -1,6 +1,6 @@
+
\ No newline at end of file
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 81d8608..3b0f463 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,4 +1,4 @@
-# github.com/alecthomas/chroma/v2 v2.12.0
+# github.com/alecthomas/chroma/v2 v2.13.0
## explicit; go 1.19
github.com/alecthomas/chroma/v2
github.com/alecthomas/chroma/v2/formatters/html