Here is a crazy idea I had. https://gist.github.com/thheller/ad7dc6234f205cf4a53f
Basically it slurps the .clj file of the current namespace, then looks at the form metadata to skip to the line where the (example ...) starts. It then takes the next row as the title, then reads all rows until it find one that ends in ;; END. All lines are then joined and tada you got your function body with all indentation. If you want to do more advanced parsing you leave the ;; END bit out but I just wanted to test the concept. ;) Maybe this works for you. Cheers, /thomas On Sunday, January 4, 2015 4:57:14 PM UTC+1, Stefan Kamphausen wrote: > > Hi, > > > Currently, I am trying to write a presentation using ring and reveal.js. > For the code samples, I'd like to write "real" clojure code, i.e. no > strings or the like. > > Then, I want to turn that into a suitable hiccup vector which will create > the correct reveal.js/highlight.js syntax. > > I wrote a trvial macro: > > (defmacro example [& body] > `[:pre > [:code ~(apply str body)]]) > > The problem is, that it looses all formatting, because the Clojure reader > already had its fun with the code. So, > > (example > "A string literal" > (defn a-function [x y] > ;; concat x and y as strings > (str x y))) > > macro-expands to > > [:pre [:code "A string literal(defn a-function [x y] (str x y))"]] > > which is pretty useless. > > I already thought about using &form but this too has been read already. > > > Any ideas? > > > Kind regards, > stefan > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.