Skip to content

Instantly share code, notes, and snippets.

@honzabrecka
Created December 14, 2016 23:07
Show Gist options
  • Save honzabrecka/d8859e1fa3562f9ced6d61279e639cd7 to your computer and use it in GitHub Desktop.
Save honzabrecka/d8859e1fa3562f9ced6d61279e639cd7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env planck
(ns honza.svg2rn
(:require [planck.core :as core]
[clojure.string :as s]))
(defn camel-case [s]
(let [[a & ab] (s/split s #"-")]
(reduce #(str %1 (s/capitalize %2)) a ab)))
(defn replace [s]
(-> s
(s/replace #"<(\/)?([a-z]+)" (fn [[_ closing tag]] (str "<" closing (s/capitalize tag))))
(s/replace #" ([a-z\-]+)=\"" (fn [[_ p]] (str " " (camel-case p) "=\"")))))
(defn convert [file]
(->> file
(core/slurp)
(replace)
(core/spit (str file ".o"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment