emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] new LaTeX exporter hook


From: Nicolas Goaziou
Subject: Re: [O] new LaTeX exporter hook
Date: Wed, 23 May 2012 14:32:02 +0200

Hello,

Jambunathan K <address@hidden> writes:

> Andreas Leha <address@hidden> writes:
>
>> the new LaTeX exporter does not seem to "run" the
>> org-export-latex-final-hook.  Is there an equivalent?
>
> You are looking for `:filter-final-output' within
> `org-export-filters-alist'.
>
> I have defcustom that runs indent-region on final html output.  Here is
> the relevant sections from org-e-html together with it's final section.
>
> Adopt this example to e-latex case.
>
> (defconst org-e-html-filters-alist
>   '((:filter-final-output . org-e-html-final-function))
>   "Alist between filters keywords and back-end specific filters.
> See `org-export-filters-alist' for more information.")
>
> (defun org-e-html-final-function (contents backend info)
>   (if (not org-e-html-pretty-output) contents
>     (with-temp-buffer
>       (nxml-mode)
>       (insert contents)
>       (indent-region (point-min) (point-max))
>       (buffer-substring-no-properties (point-min) (point-max)))))
>
> (defcustom org-e-html-pretty-output nil
>   "Enable this to generate pretty HTML."
>   :group 'org-export-e-html
>   :type 'boolean)

Jambunathan is right.  Though, for completeness, I'll add that, as an
end-user, you shouldn't mess with `org-e-html-filters-alist'.  You can
add your filter to `org-export-filter-final-output-functions' instead.

Since this variable is back-end agnostic, your filter will probably have
to check the back-end first. Also, remember this is the functional
counterpart of hooks: the return value of your function will be used as
the new output. Thus, be sure it doesn't return nil.

Example follows:

#+begin_src emacs-lisp
(defun my-e-latex-final-filter (contents backend info)
  (if (not (eq backend 'e-latex)) contents
    ...
    modify contents
    ...
    new-contents))
#+end_src


Regards,

-- 
Nicolas Goaziou



reply via email to

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