summaryrefslogtreecommitdiff
path: root/src/highlight.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/highlight.clj')
-rw-r--r--src/highlight.clj20
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]]))