web frontend for git repositories, written in Go git.pocka.jp/legit.git
3

Configure Feed

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

Change syntaxHighlight option from string to boolean

Since replacing templates, syntax highlighting no longer uses supplied
style.

Shota FUJI (Mar 24, 2025, 4:01 PM +0900) b8430efe 6fbc5cd1

+10 -11
+4
config.yaml
··· 45 45 # Website's description. 46 46 description: "web frontend for git repositories, written in Go" 47 47 48 + # Whether highlight repository's text file. 49 + # NOTE: This applies only to blob page. Code blocks inside README will be untouched. 50 + syntaxHighlight: true 51 + 48 52 server: 49 53 # legit uses this strings for clone URL. 50 54 # `https://<name>/<directory>`
+1 -1
config/config.go
··· 23 23 Meta struct { 24 24 Title string `yaml:"title"` 25 25 Description string `yaml:"description"` 26 - SyntaxHighlight string `yaml:"syntaxHighlight"` 26 + SyntaxHighlight bool `yaml:"syntaxHighlight"` 27 27 } `yaml:"meta"` 28 28 Server struct { 29 29 Name string `yaml:"name,omitempty"`
+1 -1
demo/config.yaml
··· 38 38 meta: 39 39 title: legit Demo 40 40 description: Test legit features with real repositories. 41 - syntaxHighlight: monokailight 41 + syntaxHighlight: true 42 42 43 43 server: 44 44 name: example.com
+2 -2
routes/routes.go
··· 309 309 LineNumbers: lines, 310 310 } 311 311 312 - if d.c.Meta.SyntaxHighlight != "" { 313 - highlighted, err := highlightCode(treePath, contents, d.c.Meta.SyntaxHighlight) 312 + if d.c.Meta.SyntaxHighlight { 313 + highlighted, err := highlightCode(treePath, contents) 314 314 if err != nil { 315 315 log.Println(err) 316 316 } else {
+2 -7
routes/util.go
··· 90 90 } 91 91 } 92 92 93 - func highlightCode(fileName string, code string, styleQuery string) (template.HTML, error) { 93 + func highlightCode(fileName string, code string) (template.HTML, error) { 94 94 lexer := lexers.Get(fileName) 95 95 96 96 // Do not process if no appropriate highlighter was found. ··· 98 98 return "", nil 99 99 } 100 100 101 - style := styles.Get(styleQuery) 102 - if style == nil { 103 - return "", fmt.Errorf("No chroma style found for '%s'", styleQuery) 104 - } 105 - 106 101 formatter := html.New(html.WithClasses(true), html.ClassPrefix("chroma-")) 107 102 108 103 iter, err := lexer.Tokenise(nil, code) ··· 111 106 } 112 107 113 108 var output bytes.Buffer 114 - err = formatter.Format(&output, style, iter) 109 + err = formatter.Format(&output, styles.Fallback, iter) 115 110 if err != nil { 116 111 return "", fmt.Errorf("Failed to highlight code: %s", err) 117 112 }