emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] filter for svg latex-export


From: John Kitchin
Subject: Re: [O] filter for svg latex-export
Date: Mon, 08 Jan 2018 22:34:06 -0500
User-agent: mu4e 0.9.19; emacs 25.2.1

If all you are doing is replacing includesvg with simplesvg, then you
might try this:

#+BEGIN_SRC emacs-lisp
(let ((org-export-filter-link-functions  '((lambda (txt _ _)
                                             (replace-regexp-in-string 
"includesvg" "simplesvg" txt)))))
  (org-latex-export-as-latex))
#+END_SRC

If you are doing more than that (it looks like you are adding options?)
then one alternative option is just put a copy of your modified function
in your init file after you load org, and then it will shadow the
ox-latex function and you might not have to change anything when you
update as long as no incompatible changes are in the update. I know,
that is hacky, but it works in cases like this.



address@hidden writes:

> Hello,
>
> I once tried to create a filter (is that the name?) to modify the
> function which exports SVG files. Verdict: I suck! Thus, I keep
> modifying the ox-latex.el every time that I upgrade (see attached).
> Would someone please tell me what is the right way to achieve that
> (without modifying the code, please? Thanks!
>
> -------------------------------------------------
>
> ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the 
> NSA's hands!
> $24.95 ONETIME Lifetime accounts with Privacy Features!
> 15GB disk! No bandwidth quotas!
> Commercial and Bulk Mail Options!  *** org-20180103/ox-latex.el       
> 2018-01-07 16:53:43.477464348 -0700
> --- plugins/ox-latex.el       2018-01-07 16:39:52.117462098 -0700
> ***************
> *** 2425,2434 ****
>                         (t (format "[%s]" options)))
>                   path))
>         (when (equal filetype "svg")
> !     (setq image-code (replace-regexp-in-string "^\\\\includegraphics"
> !                                                "\\includesvg"
> !                                                image-code
> !                                                nil t))
>       (setq image-code (replace-regexp-in-string "\\.svg}"
>                                                  "}"
>                                                  image-code
> --- 2425,2437 ----
>                         (t (format "[%s]" options)))
>                   path))
>         (when (equal filetype "svg")
> !         (setq image-code
> !               (format "\\simplesvg%s{%s}"
> !                       (cond ((not (org-string-nw-p options)) "")
> !                             ((string-prefix-p "," options)
> !                              (format "{%s}" (substring options 1)))
> !                             (t (format "{%s}" options)))
> !                       path))
>       (setq image-code (replace-regexp-in-string "\\.svg}"
>                                                  "}"
>                                                  image-code


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

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