Marcin Borkowski <mbork <at> wmi.amu.edu.pl> writes: > > Hello, > > I'd like to (ab)use the "underline" syntax for something else. > Basically, I'd like to translate > > _underlined_ > > to > > <span class="my-own"><variant>underlined<variant></span> > > and > > _underlined|with variant_ > > to > > <span class="my own"><variant>underlined</variant><variant>with > variant</variant></span> > > but only if the underlining is between > > #+BEGIN_MYBLOCK > ... > #+END_MYBLOCK > > How to achieve this? In particular, I'd like to know: > > 1. How can I know (in org-html-underline, for instance) whether I am in > a MYBLOCK or not? >
You do not need to know this directly. See below: > 2. How do I best translate the "|" syntax into "variants"? More > specifically: is it a good idea to do it in org-my-html-underline, by > analysing the "underlined" text (as a string) or maybe it's better to > write a filter? (I guess the former idea is better.) > Define two derived backends: backend 1) Use 'html as the parent. Add 'MYBLOCK' to the `:export-block' list and define your own `org-backend1-export-block' transcoder with a fallback to the parent backend for HTML blocks. You will have access to the :value of MYBLOCK as a string. You can use `org-export-string-as' to process that value according to an arbitrary backend - in this case you use `backend2'. backend 2) Use html as the parent of this backend and define `org-backend2-underline' to use the rules you outline above. You can parse the `contents' arg for the `|' etc. There might be a case for making `backend2' anonymous since you only replace one transcoder of the parent. There is an example in ` org-html--format-toc-headline'. HTH, Chuck