diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-08-12 14:29:25 -0400 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-08-12 14:29:25 -0400 |
| commit | 71a4c2823a41febd0778c7170eb3b12b293b4f49 (patch) | |
| tree | e1800b6fca9cfe122221a7a490e580118c818769 /src/highlight.clj | |
| parent | e7583ac9782b006139188ebe6a3c2d33b980bf33 (diff) | |
Add code block support
Diffstat (limited to 'src/highlight.clj')
| -rw-r--r-- | src/highlight.clj | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/highlight.clj b/src/highlight.clj new file mode 100644 index 0000000..0bd1335 --- /dev/null +++ b/src/highlight.clj @@ -0,0 +1,20 @@ +(ns highlight + (:require [clojure.java.shell :as shell] + [borkdude.html :refer [html]])) + +(defn highlight [lang src] + (let [result (shell/sh "pygmentize" "-l" lang "-f" "html" :in src)] + (:out result))) + +(defmacro highlight-clj [& body] + `(highlight "clojure" ~(apply str (map pr-str body)))) + +(defn highlight-styles [style] + (let [result (shell/sh "pygmentize" "-S" style "-f" "html" "-a" ".code")] + (:out result))) + +(defn code [v] + (html + [:div + {:class "code"} + [:$ v]])) |
