diff options
| author | Arun Isaac | 2026-08-04 01:18:12 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-08-04 13:24:54 +0100 |
| commit | 685db9d6fd90b76a8314a21328217039932b6070 (patch) | |
| tree | f26b5795631487c122dc84b41ae6654158d08827 | |
| parent | 321bfd3891c23fceba2660ff68a17febb6083465 (diff) | |
| download | guix-forge-685db9d6fd90b76a8314a21328217039932b6070.tar.gz guix-forge-685db9d6fd90b76a8314a21328217039932b6070.tar.lz guix-forge-685db9d6fd90b76a8314a21328217039932b6070.zip | |
cgit: Switch from Pygments to Chroma.
Chroma is a lot faster than Pygments, probably in part due to it not incurring the Python interpreter startup overhead. Thus, it will perform better as a source filter, and will hold up well to the onslaught of the AI crawlers.
| -rw-r--r-- | doc/forge.skb | 6 | ||||
| -rw-r--r-- | guix/forge/cgit.scm | 21 |
2 files changed, 21 insertions, 6 deletions
diff --git a/doc/forge.skb b/doc/forge.skb index 7a41487..607ef39 100644 --- a/doc/forge.skb +++ b/doc/forge.skb @@ -238,9 +238,9 @@ web. Our cgit service features] (itemize (item [clonable URLs via the smart HTTP protocol through ,(command [git-http-backend])]) - (item [syntax highlighting for a wide variety of -programming languages using ,(ref :url "https://pygments.org/" :text -"Pygments")]) + (item [syntax highlighting for a wide variety of programming +languages using ,(ref :url "https://github.com/alecthomas/chroma" :text +"Chroma")]) (item [rendering markdown, org mode, reStructuredText, man page, HTML or plain text README files in the ,(emph [About]) page]) (item [hiding full email addresses on cgit web pages]) diff --git a/guix/forge/cgit.scm b/guix/forge/cgit.scm index 94a62ee..529d4a6 100644 --- a/guix/forge/cgit.scm +++ b/guix/forge/cgit.scm @@ -25,6 +25,7 @@ #:use-module (forge socket) #:use-module ((gnu packages emacs) #:select (emacs-minimal)) #:use-module ((gnu packages mail) #:select (mailcap)) + #:use-module ((gnu packages golang-apps) #:select (go-chroma)) #:use-module ((gnu packages version-control) #:select (cgit-pink git-minimal)) #:use-module (gnu services) @@ -70,6 +71,21 @@ "README.txt" "README"))) +(define %cgit-chroma-syntax-highlight-gexp + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils) + (ice-9 match)) + + (match (command-line) + ((_ file) + (invoke #$(file-append go-chroma "/bin/chroma") + "--style" "pastie" + "--html" + "--html-only" + "--html-inline-styles" + "--filename" file)))))) + (define-record-type* <cgit-configuration> cgit-configuration make-cgit-configuration cgit-configuration? @@ -99,9 +115,8 @@ (email-filter cgit-configuration-email-filter (default #f)) (source-filter cgit-configuration-source-filter - (default (file-append (cgit-configuration-cgit - this-cgit-configuration) - "/lib/cgit/filters/syntax-highlighting.py")) + (default (program-file "cgit-chroma-syntax-highlight" + %cgit-chroma-syntax-highlight-gexp)) (thunked)) (mimetype-file cgit-configuration-mimetype-file (default (file-append mailcap "/etc/mime.types"))) |
