[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [New exporter] custom emphasis in org-emphasis-alist
From: |
Nicolas Goaziou |
Subject: |
Re: [O] [New exporter] custom emphasis in org-emphasis-alist |
Date: |
Sun, 10 Feb 2013 10:45:37 +0100 |
Completing myself,
> On the other hand, you may be able to parse custom markup with the help
> of a filter:
>
> #+begin_src emacs-lisp
> (defun my-special-markup (text backend info)
> (when (and (org-export-derived-backend-p backend 'html)
> (string-match "\\([ ('\"{]\\|^\\)\\(\\([?!#]\\)\\([^
> ,\"']\\|[^
> ,\"'].*?\\(?:
> .*?\\)\\{0,1\\}[^
> ,\"']\\)\\3\\)\\([- .,:!?;'\")}\\]\\|$\\)"
> text))
> (format (cond ((equal (match-string 3 text) "?")
> "<span class=\"org-question\">%s</span>")
> ((equal (match-string 3 text) "#") "<!--%s-->")
> (t "<span class=\"org-exclamation\">%s</span>"))
> (match-string 4 text))))
> (add-to-list 'org-export-filter-plain-text-functions 'my-special-markup)
> #+end_src
This solution will not work but in the simplest cases (no special
markup allowed within the tags).
For additional syntax, a better option would be to define a macro:
#+MACRO: excl @@html:<span class="org-exclamation">@@$1@@html:</span>@@
Then use it within the buffer:
A paragraph and {{{excl(some *bold* text within a special
container)}}}.
This allow for some flexibility. You can even define a babel block and
call it within a paragraph for more complicated (i.e. conditional)
stuff.
Regards,
--
Nicolas Goaziou