summaryrefslogtreecommitdiff
path: root/src/highlight.clj
blob: 0bd13357c5fcca6e5dc4af765b2082f28e8e3cd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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]]))