* Problem writing my first export filter
@ 2013-08-21 1:55 James Harkins
2013-08-21 7:48 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: James Harkins @ 2013-08-21 1:55 UTC (permalink / raw)
To: orgmode
Referring to [1]:
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.
Thanks in advance for advice,
hjh
[1] http://article.gmane.org/gmane.emacs.orgmode/75607
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problem writing my first export filter
2013-08-21 1:55 Problem writing my first export filter James Harkins
@ 2013-08-21 7:48 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2013-08-21 7:48 UTC (permalink / raw)
To: James Harkins; +Cc: orgmode
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-21 7:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-21 1:55 Problem writing my first export filter James Harkins
2013-08-21 7:48 ` Nicolas Goaziou
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).