Suvayu Ali <fatkasuvayu+li...@gmail.com> writes: > On Tue, May 28, 2013 at 03:00:40PM +0200, Torsten Wagner wrote: >> >> However, I believe that for many users, the special cases are not very >> frequent and complex. Might it be possible to create a very simple syntax >> for exporting rules which could be either in those above modules or >> directly within the file written by the user themself? >> >> #+HTML_USER_RULE \ruby{$1}{$2}, <ruby> $1 >> <rp>(</rp><rt>$2</rt><rp>)</rp> <\ruby> > > Isn't this very similar to a #+MACRO definition but with a different > syntax and only for the HTML backend? > > Maybe we could allow backend specific macro expansion definitions. > Something like: > > #+HTML_MACRO: ruby <ruby> $1 <rp>(</rp><rt>$2</rt><rp>)</rp> <\ruby> > #+LATEX_MACRO: ruby \ruby{$1}{$2} > > Then {{{ruby(東,ひがし)}}} will be expanded appropriately for > different backends. > > What do you think? > > Cheers, > > 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.
Another option would be a link: (org-add-link-type "ruby" nil (lambda (path desc format) (cond ((eq format 'html) (format "<ruby> %s <rp>(</rp><rt>%s</rt><rp>)</rp> <\ruby>" path desc)) ((memq format '(beamer latex)) (format "\\ruby{%s}{%s}" path desc))))) [[ruby:東][ひがし]] (untested) All the best, Tom -- Thomas S. Dye http://www.tsdye.com