emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Macros and HTML new exporter


From: Nicolas Goaziou
Subject: Re: [O] Macros and HTML new exporter
Date: Sun, 13 Jan 2013 14:15:29 +0100

Hello,

Fabrice Popineau <address@hidden> writes:

> I need some clarficiation here.
>
> I tried the following :
>
> ...
> #+MACRO: internal #+BEGIN_HTML\n<div class="move">\n<a href="#"
> onclick="toggleContainer('Home', '$1');"> $2 </a>\n</div>\n#+END_HTML
> ...
> * Some title
> [2013-01-13 dim. 09:31]
>
> {{{internal(2, 'foo')}}}
> ...
>
> The I call org-e-publish and the html file produced has the macro inlined
> in the html output :
>
> <p>
> #+BEGIN_HTML\n&lt;div class="move"&gt;\n&lt;a href="#"
> onclick="toggleContainer('Home', '2');"&gt; 'foo'
> &lt;/a&gt;\n&lt;/div&gt;\n#+END_HTML
> </p>
>
>
> However with this :
>
> #+MACRO: internal @@e-html:<div class="move"><a href="#"
>  onclick="toggleContainer('Home', $1);"> $2 </a></div>@@
>
> the result obtained is as expected.
> Why is it this way ? I would have expected the first version to also
> work.

That's because macros are single line objects. Your first example, when
expanded, will generate:

  #+BEGIN_HTML\n<div class="move">\n<a href="#" 
onclick="toggleContainer('Home', '2');"> 'foo' </a>\n</div>\n#+END_HTML

with literal "\n".

> Incidentally, there is a potential difficulty with macro arguments and
> quoting.
> Arguments to macros are not quoted and seems to be split wlong with commas.
> Maybe a quoting mechanism would be needed (how to pass an argument with a
> comma ?)

Macros are a simple answer to simple problems. If you want to construct
something more elaborate, I highly suggest to use Babel.


Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]