Created
December 14, 2016 23:07
-
-
Save honzabrecka/d8859e1fa3562f9ced6d61279e639cd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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