emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Macro expansion in new exporter


From: Nicolas Goaziou
Subject: Re: [O] Macro expansion in new exporter
Date: Tue, 12 Feb 2013 18:56:36 +0100

Hello,

address@hidden (T.F. Torrey) writes:

> Nicolas Goaziou <address@hidden> writes:
>
>> On that topic, the main difference with the previous exporter is that
>> macros are now required to be in a context that can be parsed. Thus, for
>> example, the following is not a macro:
>>
>>   ~{{{title}}}~
>
> What is meant by "a context that can be parsed"?

Anywhere but in verbatim areas like:

  - example blocks
  - src blocks, inline src-blocks
  - fixed-width area
  - keywords (excepted CAPTION, DATE, TITLE, AUTHOR, EMAIL and MACRO).
  - verbatim and code emphasis.
  - block boundaries

> In my work, it has been very useful to use macros for snippets of
> text.  Then, instead of changing the text everywhere when I want a
> change, I would just change the macro.  So...
>
> For instance, I used to be able to do this:
>
> #+MACRO: status Draft
> #+HTML: <p class="status">{{{status}}}</p>
>
> And on export to HTML, I would get what you would expect:
> <p class="status">Draft</p>
>
> With the new exporter, the macro is left unexpanded in the output:
> <p class="status">{{{status}}}</p>

Because the macro is in a keyword that means: "do not parse this
contents, it is for the html back-end only".

> Of course, I could also put the {{{status}}} in any ordinary text and
> have it there as well.
>
> In extensive experiments, I have not found any combination of input that
> would produce the old output using macros.

It's possible, macros are not exactly the same. Some of their old
functionalities are meant to be reached through Babel now. It may sounds
bad, but it allows a better control on macro expansion.

> The old behavior had an elegant, one-line solution.  Perhaps the
> functionality could be duplicated with babel, but surely not as simply
> and directly as with the old macro system.
>
> Is there a way to replicate the old behavior in the new export engine?

I didn't check thoroughly, but I would say this kind of feature requires
some Babel code.

> Also, in your response to Carsten's question about macros, you suggested
> this:
>
> #+MACRO: thumbright @@html:<img src="./Content/$2/thumb.jpg" 
> style="float:right;width:$1;margin:0px 20px 0px 20px;" 
> alt="./Content/$2/thumb.jpg" />@@
>
> The "@@" syntax looks new to me.  Can you tell me what the function of
> the "@@" is?  Is this documented somewhere?

It is called an export-snippet. @@html:...@@ syntax is to #+begin_html
blocks what =...= is to #+begin_example blocks. It replaces old @<...>
syntax, which was HTML only. Now you can have @@latex:...@@ or
@@beamer:...@@ syntax.


Regards,

-- 
Nicolas Goaziou



reply via email to

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