emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Problem writing my first export filter


From: Nicolas Goaziou
Subject: Re: [O] Problem writing my first export filter
Date: Wed, 21 Aug 2013 09:48:51 +0200

Hello,

James Harkins <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]