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: Fri, 15 Feb 2013 14:05:03 +0100

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

> Perhaps.  We still know of no easy/straightforward way at all to
> replicate using babel the behavior I had (creating '<p
> class="foo">bar</p>' with a macro), let alone in a pair of single
> lines.

Here is an example. Babel specialists can help you further.

--8<---------------cut here---------------start------------->8---
Define your Babel macro.

#+name: html-foo
#+begin_src org :exports none :results raw :var data=""
,#+HTML: <p class="foo">$data</p>
#+end_src

Now, use it anywhere in the code, any number of times.

#+CALL: html-foo(data="bar") :results raw
--8<---------------cut here---------------end--------------->8---

There are many, often shorter, other ways to do it.

> Macros are so straightforward compared to babel, I wonder how much
> trouble they /could/ generate.

Not as much as Babel, obviously. But since blank lines are significant
in Org, allowing blank lines in macros could change structure.

> I wonder if an entry in the (underused) Library of Babel could replicate
> the macro functionality and eliminate the need for macros as separate
> things.  I will have to look into that when I have more time.

You can install the example given above in you Library of Babel.

> I'm pretty sure I could replicate (and even expand) the old macro
> functionality by hooking an expansion function into
> org-export-before-parsing-hook.  Maybe I will write an extension to
> try.

I'd rather have users use macros for short replacements, which is where
they really shine, and Babel for programmable ones. Your extension
wouldn't help at that. But that's your call, obviously.

For the record, I have had to rewrite the macro code two times. This is
to say it is difficult to get them right, if possible at all.


Regards,

-- 
Nicolas Goaziou



reply via email to

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