diff options
| author | Jake Zerrer <him@jakezerrer.com> | 2025-11-30 12:31:01 -0500 |
|---|---|---|
| committer | Jake Zerrer <him@jakezerrer.com> | 2025-11-30 17:27:46 -0500 |
| commit | 119cf7f780375187dbe3d064263a9de3a17f538d (patch) | |
| tree | 376d48fc42d19ed49ca3f740e7c0e4c15596d11d /src/highlight.clj | |
| parent | 034e30d70aeac7ce18f34be6a1c211730e9fd7fb (diff) | |
Move from github pages to server
Diffstat (limited to 'src/highlight.clj')
| -rw-r--r-- | src/highlight.clj | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/highlight.clj b/src/highlight.clj deleted file mode 100644 index f229b1a..0000000 --- a/src/highlight.clj +++ /dev/null @@ -1,50 +0,0 @@ -(ns highlight - (:require [clojure.java.shell :as shell] - [borkdude.html :refer [html]] - [zprint.core :as zp] - [clojure.string :refer [join]])) - -(defn highlight [lang src] - (let [result (shell/sh "pygmentize" "-l" lang "-f" "html" :in src)] - (:out result))) - -(defn code [style v] - (html - (let [s style] - [:div - {:class s} - v]))) - -(defmacro highlight-clj [& body] - (let [out (atom []) - _res ;; return value of final form; currently unused - (let [prev-ns *ns* - t #(swap! out conj %)] - (ns example) - (add-tap (bound-fn* t)) - (let [res - (last (map eval body))] - (remove-tap (bound-fn* t)) - (in-ns (ns-name prev-ns)) - res)) - code - (join "\n\n" (map zp/zprint-str body)) - tap-out (join "\n" (map zp/zprint-str @out {:style :backtranslate})) - joined (apply str - (concat code))] - `(html - [:div - {:style {:border-left "5px solid #ddd"}} - [:div {:class "code"} - [:$ - (highlight "clojure" - ~joined)]] - [:p {:style {:padding-left "6px"}} "tap contents:"] - [:div {:class "output"} - [:$ - (highlight "clojure" - ~tap-out)]]]))) - -(defn highlight-styles [k style] - (let [result (shell/sh "pygmentize" "-S" style "-f" "html" "-a" (str "." (name k)))] - (:out result))) |
