emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Brett Viren <bv@bnl.gov>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Overriding org-html-headline or other export functions?
Date: Mon, 29 May 2017 13:35:42 -0700	[thread overview]
Message-ID: <alpine.OSX.2.20.1705291316280.1332@charles-berrys-macbook.local> (raw)
In-Reply-To: <86poer1q4t.fsf@bnl.gov>

On Mon, 29 May 2017, Brett Viren wrote:

> "Charles C. Berry" <ccberry@ucsd.edu> writes:
>
>> You do have that wrong.  This is exactly what export filters and
>> derived backends are for.  In fact, you can use both.  For an example,
>> see
>>
>> http://orgmode.org/worg/exporters/filter-markup.html
>>
>> You will want to change `latex' to `html' in the
>>
>> 	`(org-export-define-derived-backend ...)'
>>
>> call and delete all filters except for `:filter-headline'.  And revise
>> `ox-mrkup-filter-headline' accordingly.
>
> Thanks for checking me on this, but I still don't see it.
>
> If I understand, a derived HTML backend with my own filter-headline
> would let me add my own extra HTML *outside* the "<h1>...</h1>",
> "<h2>...</h2>", etc, HTML that is generated by the base
> org-html-headline filter.  But for the output I want I need to add my
> extra HTML *inside* the contents of the "<hN>...</hN>" tags.  And I
> don't see an export filter for this "..." part.
>
> Or, maybe you suggest I do direct "surgery" on the TEXT argument that
> gets passed in to the filter and insert the "..." that way?  I guess it
> could work to find the end of the "<hN...>" opening tag and then insert
> my "..." part.  I'll try this approach.
>
Yeah. You can use one or two `replace-regexp-in-string' calls I think.

You get that if the underlying code in ox-html changes in a way that is 
incompatible with your headline transcoder, you will have to start over. 
OTOH, since you only change one line it would not be the end of the world 
unless lots of others depend on that code and you were enjoying a 
wilderness vacation.  I would guess that such changes would be few at 
this late date.

If this is something you only use for personal work, then

#+BEGIN_SRC emacs-lisp
(org-export-define-derived-backend 'bv 'html
   :translate-alist '((headline . org-bv-headline)))
(defun org-bv-headline <your function here>)
#+END_SRC

finishes the job without a lot of fuss.

HTH,

Chuck

  parent reply	other threads:[~2017-05-29 20:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29 12:22 Overriding org-html-headline or other export functions? Brett Viren
2017-05-29 17:38 ` Charles C. Berry
2017-05-29 18:20   ` Brett Viren
2017-05-29 20:34     ` Brett Viren
2017-05-29 20:35     ` Charles C. Berry [this message]
2017-05-29 18:33 ` Marcin Borkowski
2017-05-29 19:14   ` Brett Viren

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=alpine.OSX.2.20.1705291316280.1332@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=bv@bnl.gov \
    --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).