summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2026-01-30 20:27:55 -0700
committermo khan <mo@mokhan.ca>2026-01-30 20:27:55 -0700
commit94476e4f0e154677d6fd536a3103379e5d51e2f6 (patch)
tree585e042d6443572a829ed07cfdabe1fd696eaffb /cmd
parentf51476f56bd40660d51aea9df6f5f31d36fa59dc (diff)
feat: add command to generate css files
Diffstat (limited to 'cmd')
-rw-r--r--cmd/css/main.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmd/css/main.go b/cmd/css/main.go
new file mode 100644
index 0000000..367e1b8
--- /dev/null
+++ b/cmd/css/main.go
@@ -0,0 +1,41 @@
+package main
+
+import (
+ "os"
+ "path/filepath"
+ "runtime"
+ "strings"
+
+ "github.com/alecthomas/chroma/v2/formatters/html"
+ "github.com/alecthomas/chroma/v2/styles"
+)
+
+func main() {
+ _, file, _, _ := runtime.Caller(0)
+ cssDir := filepath.Join(filepath.Dir(file), "../../internal/templates/css")
+
+ formatter := html.New(
+ html.WithLineNumbers(true),
+ html.WithLinkableLineNumbers(true, "L"),
+ html.WithClasses(true),
+ )
+
+ lightStyle := styles.Get("github")
+ darkStyle := styles.Get("github-dark")
+
+ var light, dark strings.Builder
+ _ = formatter.WriteCSS(&light, lightStyle)
+ _ = formatter.WriteCSS(&dark, darkStyle)
+
+ light.WriteString(".chroma .gi { display: block; }\n")
+ light.WriteString(".chroma .gd { display: block; }\n")
+ dark.WriteString(".chroma .gi { display: block; }\n")
+ dark.WriteString(".chroma .gd { display: block; }\n")
+
+ if err := os.WriteFile(filepath.Join(cssDir, "syntax_light.css"), []byte(light.String()), 0o644); err != nil {
+ panic(err)
+ }
+ if err := os.WriteFile(filepath.Join(cssDir, "syntax_dark.css"), []byte(dark.String()), 0o644); err != nil {
+ panic(err)
+ }
+}