Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[prismatic/plumbing "0.5.4"]
[org.clojure/math.numeric-tower "0.0.4"]
[org.clojure/data.priority-map "0.0.7"]
[org.clojure/data.xml "0.2.0-alpha5"]
[net.cgrand/xforms "0.9.3"]
[cheshire "5.7.1"]
[com.taoensso/timbre "4.10.0"]
Expand Down
9 changes: 4 additions & 5 deletions src/huri/plot.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[clojure.java.shell :as shell]
[clojure.walk :as walk]
[gorilla-renderable.core :as render]
[clojure.xml :as xml]
[clojure.data.xml :as xml]
[clj-time.core :as t])
(:import org.joda.time.DateTime
java.io.File
Expand Down Expand Up @@ -85,11 +85,11 @@
This function is a workaround for that. It takes an SVG string and replaces
the ids with globally unique ids, returning a string."
[svg]
(let [svg (xml/parse (java.io.ByteArrayInputStream. (.getBytes svg)))
(let [svg (xml/parse-str svg)
smap (fresh-ids svg)
mangle (fn [x]
(if (map? x)
(into {}
(into (with-meta {} (meta x))
(for [[k v] x]
[k (if (or (= :id k)
(and (string? v)
Expand All @@ -98,8 +98,7 @@
(smap v)
v)]))
x))]
(with-out-str
(xml/emit (walk/prewalk mangle svg)))))
(xml/emit-str (walk/prewalk mangle svg))))

(defn render
([plot-command]
Expand Down