On Tue, May 28, 2013 at 05:01:56PM +0200, Suvayu Ali wrote:
>
> PS: Actually on second thought it is probably possible to handle this
> with filters although I failed to find the appropriate filter.
>
> So you could try:
>
> #+MACRO: ruby <cookie><$1><$2></cookie>
>
> And the filter can translate the cookie to the appropriate backend
> specific expansion.
Maybe this will work (untested): org-export-filter-paragraph-functions. The
assumption is you will use the macro by itself in a paragraph and not on
structural elements like headlines.
(defun sa-latex-subscript (contents backend info)
(when (eq backend 'latex)
(replace-regexp-in-string "<cookie><\\([^>]+\\)><\\([^>]+\\)></cookie>"
"\\\\ruby{\\1}{\\2}" contents))
(when (eq backend 'html)
(replace-regexp-in-string "<cookie><\\([^>]+\\)><\\([^>]+\\)></cookie>"
"<ruby>\\1<rp>(</rp><rt>\\2</rt><rp>)</rp>
<\ruby>"
contents)))
I did not check the regular expressions at all, so please test and let us know.
Cheers,
--
Suvayu
Open source is the future. It sets us free.