From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Berry Subject: Re: Custom export backend based on HTML: how to implement own blocks? Date: Sun, 23 Nov 2014 19:17:22 +0000 (UTC) Message-ID: References: <87sih9q5u3.fsf@wmi.amu.edu.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XscfI-0004IU-S7 for emacs-orgmode@gnu.org; Sun, 23 Nov 2014 14:17:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XscfC-0004sO-Iw for emacs-orgmode@gnu.org; Sun, 23 Nov 2014 14:17:44 -0500 Received: from plane.gmane.org ([80.91.229.3]:47255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XscfC-0004sD-CP for emacs-orgmode@gnu.org; Sun, 23 Nov 2014 14:17:38 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1XscfA-0007SS-Qi for emacs-orgmode@gnu.org; Sun, 23 Nov 2014 20:17:37 +0100 Received: from 137.110.39.109 ([137.110.39.109]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Nov 2014 20:17:36 +0100 Received: from ccberry by 137.110.39.109 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Nov 2014 20:17:36 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Marcin Borkowski 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 > > underlined > > and > > _underlined|with variant_ > > to > > underlinedwith > variant > > 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