\\n\\n\"], :nextjournal/viewer {:name :html, :render-fn #viewer-fn identity, :hash \"5dqwbRQVFnHkdooT8QV8nfPHBGVWtj\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value [:div.viewer-markdown [\"h2\" {:id \"shell_script\"} [:span \"Shell script\"]] [:p [:span \"Along side the INX file we need a shell script to invoke bb, inkscape has support for a limited set of languages but shell being one we can send to babashka, would be nice to see native support here.\"]]], :nextjournal/viewer {:name :html-, :render-fn #viewer-fn identity, :hash \"5dsKyVZX2dPvsyoeg6dNrfeuqAh5UK\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value [:pre \"# Probably worth expanding to check bb exists\\n# The echo below is just for grabbing the params when developing\\n# we can interactively develop our plugin using these params\\necho $@ > /tmp/inkscape-plugin-params.dump\\nbb -i bb_inkscape_example.clj $@\\n\"], :nextjournal/viewer {:name :html, :render-fn #viewer-fn identity, :hash \"5dqwbRQVFnHkdooT8QV8nfPHBGVWtj\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value [:div.viewer-markdown [\"h2\" {:id \"functions_for_a_simple_babashka_script\"} [:span \"Functions for a simple Babashka script\"]]], :nextjournal/viewer {:name :html-, :render-fn #viewer-fn identity, :hash \"5dsKyVZX2dPvsyoeg6dNrfeuqAh5UK\"}} {:nextjournal/value \"(def cli-options\\n [[\\\"-i\\\" \\\"--id ID\\\" \\\"Port number\\\"]\\n [\\\"-h\\\" \\\"--help\\\"]])\", :nextjournal/opts {:loc {:line 31, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value [{:path [0], :nextjournal/value [{:path [0 0], :nextjournal/value \"-i\", :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-quoted-string, :opening-paren \"\\\"\", :closing-paren (\"\\\"\"), :page-size 80, :hash \"5dsc8hKzdYc787YrnnWStEqLBFykdE\"}} {:path [0 1], :nextjournal/value \"--id ID\", :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-quoted-string, :opening-paren \"\\\"\", :closing-paren (\"\\\"\"), :page-size 80, :hash \"5dsc8hKzdYc787YrnnWStEqLBFykdE\"}} {:path [0 2], :nextjournal/value \"Port number\", :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-quoted-string, :opening-paren \"\\\"\", :closing-paren (\"\\\"\" \"]\"), :page-size 80, :hash \"5dsc8hKzdYc787YrnnWStEqLBFykdE\"}}], :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-coll, :opening-paren \"[\", :page-size 20, :hash \"5dsKpRYUuGnwVK3BPfAoiJqkhVbPzH\"}} {:path [1], :nextjournal/value [{:path [1 0], :nextjournal/value \"-h\", :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-quoted-string, :opening-paren \"\\\"\", :closing-paren (\"\\\"\"), :page-size 80, :hash \"5dsc8hKzdYc787YrnnWStEqLBFykdE\"}} {:path [1 1], :nextjournal/value \"--help\", :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-quoted-string, :opening-paren \"\\\"\", :closing-paren (\"\\\"\" \"]\" \"]\"), :page-size 80, :hash \"5dsc8hKzdYc787YrnnWStEqLBFykdE\"}}], :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-coll, :opening-paren \"[\", :page-size 20, :hash \"5dsKpRYUuGnwVK3BPfAoiJqkhVbPzH\"}}], :nextjournal/viewer {:render-fn #viewer-fn nextjournal.clerk.render/render-coll, :opening-paren \"[\", :page-size 20, :hash \"5dsKpRYUuGnwVK3BPfAoiJqkhVbPzH\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value \"(defn node->str [node]\\n (with-out-str (pprint node)))\", :nextjournal/opts {:loc {:line 35, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value \"#object[bb_inkscape_example$node__GT_str 0x23015be4 \\\"bb_inkscape_example$node__GT_str@23015be4\\\"]\", :nextjournal/viewer {:name :read+inspect, :render-fn #viewer-fn (fn [x] (try [nextjournal.clerk.render/inspect (read-string x)] (catch js/Error _e (nextjournal.clerk.render/render-unreadable-edn x)))), :hash \"5dsz4kKE7PV6DTEm3Gff8moaCRdjiv\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value \"(defn fetch-document->xml\\n \\\"Load an xml document and parse to an xml sequence\\n set :namespace-aware to false so we don't get \\\"\\n [document-file]\\n (->>\\n (xml/parse-str (slurp document-file) {:namespace-aware false})\\n (xml-seq)))\", :nextjournal/opts {:loc {:line 38, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value \"#object[bb_inkscape_example$fetch_document__GT_xml 0x5fe45792 \\\"bb_inkscape_example$fetch_document__GT_xml@5fe45792\\\"]\", :nextjournal/viewer {:name :read+inspect, :render-fn #viewer-fn (fn [x] (try [nextjournal.clerk.render/inspect (read-string x)] (catch js/Error _e (nextjournal.clerk.render/render-unreadable-edn x)))), :hash \"5dsz4kKE7PV6DTEm3Gff8moaCRdjiv\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value \"(defn remove-node-by-id\\n \\\"filter the sequence looking for a specific element id attribute value\\\"\\n [node-id xml-tree]\\n (filterv #(not= (-> % :attrs :id) node-id) xml-tree))\", :nextjournal/opts {:loc {:line 46, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value \"#object[bb_inkscape_example$remove_node_by_id 0x7d9d59df \\\"bb_inkscape_example$remove_node_by_id@7d9d59df\\\"]\", :nextjournal/viewer {:name :read+inspect, :render-fn #viewer-fn (fn [x] (try [nextjournal.clerk.render/inspect (read-string x)] (catch js/Error _e (nextjournal.clerk.render/render-unreadable-edn x)))), :hash \"5dsz4kKE7PV6DTEm3Gff8moaCRdjiv\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value \"(defn fetch-node-by-id\\n \\\"filter the sequence looking for a specific element id attribute value\\\"\\n [node-id xml-tree]\\n (filterv #(= (-> % :attrs :id) node-id) xml-tree))\", :nextjournal/opts {:loc {:line 51, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value \"#object[bb_inkscape_example$fetch_node_by_id 0x761f241f \\\"bb_inkscape_example$fetch_node_by_id@761f241f\\\"]\", :nextjournal/viewer {:name :read+inspect, :render-fn #viewer-fn (fn [x] (try [nextjournal.clerk.render/inspect (read-string x)] (catch js/Error _e (nextjournal.clerk.render/render-unreadable-edn x)))), :hash \"5dsz4kKE7PV6DTEm3Gff8moaCRdjiv\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value \"(defn dump-fetched-node->file\\n \\\"Pass in the matched node and dump as xml to a tmp file.\\\"\\n [element]\\n (spit \\\"/tmp/inkscape-selected-element.svg\\\" (str element)))\", :nextjournal/opts {:loc {:line 56, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value \"#object[bb_inkscape_example$dump_fetched_node__GT_file 0x5fe88f43 \\\"bb_inkscape_example$dump_fetched_node__GT_file@5fe88f43\\\"]\", :nextjournal/viewer {:name :read+inspect, :render-fn #viewer-fn (fn [x] (try [nextjournal.clerk.render/inspect (read-string x)] (catch js/Error _e (nextjournal.clerk.render/render-unreadable-edn x)))), :hash \"5dsz4kKE7PV6DTEm3Gff8moaCRdjiv\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value [:div.viewer-markdown [\"h1\" {:id \"clerk_simple_examples\"} [:span \"Clerk simple examples\"]] [:p [:span \"These have been adjusted to use an svg in this repo, the filename and id inkscape give is specific to your running instance,\"] [#viewer-eval nextjournal.clerk.render/inspect-presented {:nextjournal/value [:span \" \"], :nextjournal/viewer {:name :html, :render-fn #viewer-fn identity, :hash \"5dqwbRQVFnHkdooT8QV8nfPHBGVWtj\"}}] [:span \"Also I needed the below hacky-svgify to render in clerk\"]]], :nextjournal/viewer {:name :html-, :render-fn #viewer-fn identity, :hash \"5dsKyVZX2dPvsyoeg6dNrfeuqAh5UK\"}} {:nextjournal/value \"(defn hacky-svgify\\n \\\"This is just a quick hacky function to render in clerk\\n emit-str append \\\" (str/replace-first\\n element\\n #\\\"^.*?>\\\" \\\"\\\") \\\"\\\"))\", :nextjournal/opts {:loc {:line 65, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value \"#object[bb_inkscape_example$hacky_svgify 0x22cd1beb \\\"bb_inkscape_example$hacky_svgify@22cd1beb\\\"]\", :nextjournal/viewer {:name :read+inspect, :render-fn #viewer-fn (fn [x] (try [nextjournal.clerk.render/inspect (read-string x)] (catch js/Error _e (nextjournal.clerk.render/render-unreadable-edn x)))), :hash \"5dsz4kKE7PV6DTEm3Gff8moaCRdjiv\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value [:div.viewer-markdown [\"h2\" {:id \"load_the_xml_document\"} [:span \"Load the xml document\"]]], :nextjournal/viewer {:name :html-, :render-fn #viewer-fn identity, :hash \"5dsKyVZX2dPvsyoeg6dNrfeuqAh5UK\"}} {:nextjournal/value \"(clerk/html\\n (hacky-svgify\\n (xml/emit-str\\n (fetch-document->xml \\\"src/clojure_logo.svg\\\"))))\", :nextjournal/opts {:loc {:line 75, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value [:div {:dangerouslySetInnerHTML {:__html \"\\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n \\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n image/svg+xmlimage/svg+xml\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\"}}], :nextjournal/viewer {:name :html, :render-fn #viewer-fn identity, :hash \"5dqwbRQVFnHkdooT8QV8nfPHBGVWtj\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value [:div.viewer-markdown [\"h2\" {:id \"find_node_by_id_and_return_only_that_node\"} [:span \"Find node by id and return only that node\"]] [:p [:span \"Inkscape gives us the selected node so we can find it in this way\"]]], :nextjournal/viewer {:name :html-, :render-fn #viewer-fn identity, :hash \"5dsKyVZX2dPvsyoeg6dNrfeuqAh5UK\"}} {:nextjournal/value \"(clerk/html\\n (->> (fetch-document->xml \\\"src/clojure_logo.svg\\\")\\n (fetch-node-by-id \\\"path12\\\")\\n (mapv #(xml/emit-str %))\\n (first)\\n (hacky-svgify)))\", :nextjournal/opts {:loc {:line 82, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value [:div {:dangerouslySetInnerHTML {:__html \"\"}}], :nextjournal/viewer {:name :html, :render-fn #viewer-fn identity, :hash \"5dqwbRQVFnHkdooT8QV8nfPHBGVWtj\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value [:div.viewer-markdown [\"h2\" {:id \"filter_out_a_node_by_id_using_postwalk\"} [:span \"Filter out a node by id using postwalk\"]]], :nextjournal/viewer {:name :html-, :render-fn #viewer-fn identity, :hash \"5dsKyVZX2dPvsyoeg6dNrfeuqAh5UK\"}} {:nextjournal/value \"(clerk/html\\n (let [xml-data (fetch-document->xml \\\"src/clojure_logo.svg\\\")]\\n (->> (clojure.walk/postwalk\\n (fn [v]\\n (cond\\n ;; match id return nil to remove\\n (= (-> v :attrs :id) \\\"path18\\\") nil\\n ;; no match so return element as normal\\n :else v))\\n xml-data)\\n (xml/emit-str)\\n (str/join \\\"\\\")\\n (hacky-svgify))))\", :nextjournal/opts {:loc {:line 90, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value [:div {:dangerouslySetInnerHTML {:__html \"\\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n \\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n \\n \\n image/svg+xml\\n \\n \\n \\n image/svg+xmlimage/svg+xml\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n\"}}], :nextjournal/viewer {:name :html, :render-fn #viewer-fn identity, :hash \"5dqwbRQVFnHkdooT8QV8nfPHBGVWtj\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}} {:nextjournal/value \"(comment (clerk/serve! {:browse? true})\\n (clerk/show! \\\"src/bb_inkscape_example.clj\\\"))\", :nextjournal/opts {:loc {:line 104, :column 1}}, :nextjournal/viewer {:name :code, :render-fn #viewer-fn nextjournal.clerk.render/render-code, :hash \"5duGVW4Xoi1QoW73J5wMRghqm9uVoW\"}} {:path [], :nextjournal/value {:nextjournal/presented {:path [], :nextjournal/value nil, :nextjournal/viewer {:render-fn #viewer-fn (fn [_] [:span.cmt-default.inspected-value \"nil\"]), :hash \"5dtdvcg6dEskz748fRgbqd59sbHbNA\"}}}, :nextjournal/viewer {:name :clerk/result, :render-fn #viewer-fn nextjournal.clerk.render/render-result, :hash \"5drtBjvRGKwhUFrDTtWvTAduWDETV1\"}}], :css-class nil}, :nextjournal/viewer {:name :clerk/notebook, :render-fn #viewer-fn nextjournal.clerk.render/render-notebook, :hash \"5dt1qwFEn2BQwdEM84VqwY4LR6p4YV\"}}}, :index \"src/bb_inkscape_example.clj\", :browse? false, :git/url \"https://github.com/olymk2/clerk_inkscape_svg\", :paths [\"src/bb_inkscape_example.clj\"], :current-path \"src/bb_inkscape_example.clj\", :bundle? false, :git/sha \"65f5aa8483b7aa29ffb5fb31eb34f65ab2fa838a\", :path->url {\"src/bb_inkscape_example.clj\" \"\"}, :expanded-paths [\"src/bb_inkscape_example.clj\"], :report-fn #object[nextjournal.clerk.builder$stdout_reporter 0x25ad5498 \"nextjournal.clerk.builder$stdout_reporter@25ad5498\"]}") app.init(opts)