From 71a4c2823a41febd0778c7170eb3b12b293b4f49 Mon Sep 17 00:00:00 2001 From: Jake Zerrer Date: Tue, 12 Aug 2025 14:29:25 -0400 Subject: Add code block support --- src/highlight.clj | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/highlight.clj (limited to 'src/highlight.clj') 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]])) -- cgit v1.2.3