diff --git a/project.clj b/project.clj index 283c94e..a884512 100644 --- a/project.clj +++ b/project.clj @@ -3,6 +3,7 @@ ;; :main marginalia.main :dependencies [[org.clojure/clojure "1.5.1"] + [org.clojure/clojurescript "0.0-2138"] [org.clojure/tools.namespace "0.1.1"] [org.clojure/tools.cli "0.2.1"] [org.markdownj/markdownj "0.3.0-1.0.2b4"] diff --git a/src/marginalia/parser.clj b/src/marginalia/parser.clj index 6cd8125..730ff3c 100644 --- a/src/marginalia/parser.clj +++ b/src/marginalia/parser.clj @@ -4,7 +4,8 @@ (ns marginalia.parser "Provides the parsing facilities for Marginalia." (:refer-clojure :exclude [replace]) - (:use [clojure [string :only (join replace)]])) + (:use [clojure [string :only (join replace lower-case)]] + [cljs.tagged-literals :only [*cljs-data-readers*]])) ;; Extracted from clojure.contrib.reflect @@ -355,5 +356,12 @@ (set-keyword-reader nil) (throw e))))) +(defn cljs-file? [filepath] + (.endsWith (lower-case filepath) "cljs")) + (defn parse-file [file] - (parse (slurp file))) + (let [readers (if (cljs-file? file) + (->> default-data-readers (merge *cljs-data-readers*)) + default-data-readers)] + (binding [*data-readers* readers] + (parse (slurp file)))))