Macros don't have access to formatting. You either need to put it in a
string, or reformat the form afterwards.

- James

On 4 January 2015 at 15:57, Stefan Kamphausen <ska2...@gmail.com> 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.
>

-- 
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.

Reply via email to