From: Nicolas Goaziou <n.goaziou@gmail.com>
To: James Harkins <jamshark70@gmail.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: Problem writing my first export filter
Date: Wed, 21 Aug 2013 09:48:51 +0200 [thread overview]
Message-ID: <87y57v8ows.fsf@gmail.com> (raw)
In-Reply-To: <871u5nst7x.wl%jamshark70@dewdrop-world.net> (James Harkins's message of "Wed, 21 Aug 2013 09:55:30 +0800")
Hello,
James Harkins <jamshark70@gmail.com> writes:
> I just tried the following, so that I could maintain a list of special cases where org's default latex export doesn't do what I want.
>
> (setq hjh-org-latex-macros '(("`em" "'em")))
>
> (defun hjh-latex-filter-macros (text backend info)
> "hjh: Replace special cases listed in hjh-org-latex-macros."
> (when (org-export-derived-backend-p backend 'latex)
> (dolist (element hjh-org-latex-macros)
> (replace-regexp-in-string (car element) (car (cdr element)) text))))
>
> First I tried
>
> (setq org-export-filter-plain-text-functions '(hjh-latex-filter-macros))
>
> -- no result: `em passes through unchanged. So then I tried clearing plain-text-functions and using final-output-functions instead. Same thing: the filter didn't do anything.
>
> I suppose I'm missing something simple.
Your filter returns nil (due to the `dolist') and is therefore ignored.
You have to make sure it returns the new string:
(defun hjh-latex-filter-macros (text backend info)
"hjh: Replace special cases listed in hjh-org-latex-macros."
(when (org-export-derived-backend-p backend 'latex)
(dolist (element hjh-org-latex-macros text)
(setq text
(replace-regexp-in-string (car element) (nth 1 element) text)))))
Regards,
--
Nicolas Goaziou
prev parent reply other threads:[~2013-08-21 7:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 1:55 Problem writing my first export filter James Harkins
2013-08-21 7:48 ` Nicolas Goaziou [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=87y57v8ows.fsf@gmail.com \
--to=n.goaziou@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=jamshark70@gmail.com \
/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).