From: Charles Berry <ccberry@ucsd.edu>
To: emacs-orgmode@gnu.org
Subject: Re: Custom export backend based on HTML: how to implement own blocks?
Date: Sun, 23 Nov 2014 19:17:22 +0000 (UTC) [thread overview]
Message-ID: <loom.20141123T193818-596@post.gmane.org> (raw)
In-Reply-To: 87sih9q5u3.fsf@wmi.amu.edu.pl
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
prev parent reply other threads:[~2014-11-23 19:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-23 15:44 Custom export backend based on HTML: how to implement own blocks? Marcin Borkowski
2014-11-23 17:28 ` Richard Lawrence
2014-11-23 19:17 ` Charles Berry [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20141123T193818-596@post.gmane.org \
--to=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).