Hello,

James Harkins <jamshar...@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

Reply via email to