emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: "T.F. Torrey" <tftorrey@tftorrey.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Macro expansion in new exporter
Date: Tue, 12 Feb 2013 18:56:36 +0100	[thread overview]
Message-ID: <8738x1ct63.fsf@gmail.com> (raw)
In-Reply-To: <8738x1x355.fsf@lapcat.tftorrey.com> (T. F. Torrey's message of "Tue, 12 Feb 2013 03:00:54 -0700")

Hello,

tftorrey@tftorrey.com (T.F. Torrey) writes:

> Nicolas Goaziou <n.goaziou@gmail.com> 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	other threads:[~2013-02-12 17:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 23:08 Macro expansion in new exporter T.F. Torrey
2013-02-09  8:04 ` Nicolas Goaziou
2013-02-12 10:00   ` T.F. Torrey
2013-02-12 17:56     ` Nicolas Goaziou [this message]
2013-02-12 20:30       ` T.F. Torrey
2013-02-13 16:36         ` Nicolas Goaziou
2013-02-15 10:21           ` T.F. Torrey
2013-02-15 13:05             ` Nicolas Goaziou
2013-02-15 20:42               ` T.F. Torrey
2013-02-15 21:17                 ` Nicolas Goaziou
2013-02-15 22:37                   ` T.F. Torrey
2013-02-15 21:26                 ` Nick Dokos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8738x1ct63.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tftorrey@tftorrey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public 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).