loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request 'fix: normalize guessed languages from enry' (#6084) from gusted/forgejo-f#-or-fsharp into forgejo

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6084
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>

+15
+9
modules/highlight/highlight.go
··· 134 134 return template.HTML(strings.TrimSuffix(htmlbuf.String(), "\n")) 135 135 } 136 136 137 + // For the case where Enry recognizes the language, but doesn't use the naming 138 + // that Chroma expects. 139 + var normalizeEnryToChroma = map[string]string{ 140 + "F#": "FSharp", 141 + } 142 + 137 143 // File returns a slice of chroma syntax highlighted HTML lines of code and the matched lexer name 138 144 func File(fileName, language string, code []byte) ([]template.HTML, string, error) { 139 145 NewContext() ··· 162 168 163 169 if lexer == nil { 164 170 guessLanguage := analyze.GetCodeLanguage(fileName, code) 171 + if normalizedGuessLanguage, ok := normalizeEnryToChroma[guessLanguage]; ok { 172 + guessLanguage = normalizedGuessLanguage 173 + } 165 174 166 175 lexer = lexers.Get(guessLanguage) 167 176 if lexer == nil {
+6
modules/highlight/highlight_test.go
··· 115 115 want: lines(""), 116 116 lexerName: "ObjectPascal", 117 117 }, 118 + { 119 + name: "test.fs", 120 + code: "module Crypt = let generateCryptTable: array<uint32> =", 121 + 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>`), 122 + lexerName: "FSharp", 123 + }, 118 124 } 119 125 120 126 for _, tt := range tests {