emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Macros and HTML new exporter
@ 2013-01-13 12:37 Fabrice Popineau
  2013-01-13 13:15 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Fabrice Popineau @ 2013-01-13 12:37 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

Hi all,

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.

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 ?)

Thanks in advance,

Fabrice

[-- Attachment #2: Type: text/html, Size: 1873 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Macros and HTML new exporter
  2013-01-13 12:37 Macros and HTML new exporter Fabrice Popineau
@ 2013-01-13 13:15 ` Nicolas Goaziou
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2013-01-13 13:15 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: emacs-orgmode

Hello,

Fabrice Popineau <fabrice.popineau@gmail.com> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-13 13:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-13 12:37 Macros and HTML new exporter Fabrice Popineau
2013-01-13 13:15 ` Nicolas Goaziou

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).