feat: highlight Gradle Kotlin as Kotlin

- Grade Kotlin is almost the as Kotlin syntax, so render it as such.
- Resolves #6138
- Unit test added.
This commit is contained in:
Gusted 2024-12-04 22:06:33 +01:00
parent 4df855f37c
commit 9bcf9502ef
No known key found for this signature in database
GPG key ID: FD821B732837125F
2 changed files with 8 additions and 1 deletions

View file

@ -138,6 +138,7 @@ func CodeFromLexer(lexer chroma.Lexer, code string) template.HTML {
// that Chroma expects.
var normalizeEnryToChroma = map[string]string{
"F#": "FSharp",
"Gradle Kotlin DSL": "Kotlin",
}
// File returns a slice of chroma syntax highlighted HTML lines of code and the matched lexer name

View file

@ -121,6 +121,12 @@ c=2
want: lines(`<span class="k">module</span> <span class="nn">Crypt</span> <span class="o">=</span> <span class="k">let</span> <span class="nv">generateCryptTable</span><span class="o">:</span> <span class="n">array</span><span class="o">&lt;</span><span class="kt">uint32</span><span class="o">&gt;</span> <span class="o">=</span>`),
lexerName: "FSharp",
},
{
name: "test.gradle.kts",
code: "@file:Suppress(\"UnstableApiUsage\")",
want: lines("<span class=\"nd\">@file</span><span class=\"p\">:</span><span class=\"n\">Suppress</span><span class=\"p\">(</span><span class=\"s2\">&#34;</span><span class=\"s2\">UnstableApiUsage</span><span class=\"s2\">&#34;</span><span class=\"p\">)</span>"),
lexerName: "Kotlin",
},
}
for _, tt := range tests {