Commit 55f7708

Daniel Axtens <dja@axtens.net>
2026-10-19 00:37:01
Force classes over styles for CSP support
1 parent 98eb84f
Changed files (3)
pkg/templates/list.gohtml
@@ -2,6 +2,7 @@
 {{ define "head" }}
     <link rel="stylesheet" href="{{ .LayoutParams.RootHref }}assets/list.css">
     <link rel="stylesheet" href="{{ .LayoutParams.RootHref }}assets/markdownBody.css">
+    <link rel="stylesheet" href="{{ .LayoutParams.RootHref }}assets/code.css">
 {{ end }}
 
 {{ define "body" }}
pkg/templates/markdown.gohtml
@@ -2,6 +2,7 @@
 {{ define "head" }}
     <link rel="stylesheet" href="{{ .LayoutParams.RootHref }}assets/markdown.css">
     <link rel="stylesheet" href="{{ .LayoutParams.RootHref }}assets/markdownBody.css">
+    <link rel="stylesheet" href="{{ .LayoutParams.RootHref }}assets/code.css">
 {{ end }}
 
 {{ define "body" }}
markdown.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+	chromahtml "github.com/alecthomas/chroma/v2/formatters/html"
 	"github.com/yuin/goldmark"
 	highlighting "github.com/yuin/goldmark-highlighting/v2"
 	"github.com/yuin/goldmark/extension"
@@ -17,6 +18,9 @@ func createMarkdown(style string) goldmark.Markdown {
 				// This assumes that the classes stay the same,
 				// regardless of style, which should be true
 				highlighting.WithStyle(style),
+				highlighting.WithFormatOptions(
+					chromahtml.WithClasses(true),
+				),
 			),
 		),
 		goldmark.WithParserOptions(