emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* filter for svg latex-export
@ 2018-01-08  0:10 edgar
  2018-01-09  3:34 ` John Kitchin
  0 siblings, 1 reply; 5+ messages in thread
From: edgar @ 2018-01-08  0:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

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!  

[-- Attachment #2: ox-latex-svg.diff --]
[-- Type: text/plain, Size: 1036 bytes --]

*** 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filter for svg latex-export
  2018-01-08  0:10 filter for svg latex-export edgar
@ 2018-01-09  3:34 ` John Kitchin
  2018-01-09  3:47   ` edgar
  2018-09-07  1:22   ` edgar
  0 siblings, 2 replies; 5+ messages in thread
From: John Kitchin @ 2018-01-09  3:34 UTC (permalink / raw)
  To: edgar; +Cc: emacs-orgmode

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.



edgar@openmail.cc 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filter for svg latex-export
  2018-01-09  3:34 ` John Kitchin
@ 2018-01-09  3:47   ` edgar
  2018-09-07  1:22   ` edgar
  1 sibling, 0 replies; 5+ messages in thread
From: edgar @ 2018-01-09  3:47 UTC (permalink / raw)
  To: John Kitchin; +Cc: John Kitchin, emacs-orgmode

On 2018-01-09 03:34, John Kitchin wrote:

Thank you, Dr. Kitchin! I will try this

> If all you are doing is replacing includesvg with simplesvg,
> 
> #+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?)

The only real difference in calling it is that I use {} instead of [], 
so I would not expect any problems

> then one alternative option is just put a copy of your modified 
> function
> in your init file after you load org

Yep, I have been trying to avoid this. My init is already huge (not 
really: 2587 lines).

Thank you again!

-------------------------------------------------

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!  

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filter for svg latex-export
  2018-01-09  3:34 ` John Kitchin
  2018-01-09  3:47   ` edgar
@ 2018-09-07  1:22   ` edgar
  1 sibling, 0 replies; 5+ messages in thread
From: edgar @ 2018-09-07  1:22 UTC (permalink / raw)
  To: John Kitchin; +Cc: John Kitchin, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3285 bytes --]

Hi,

I want to report that I can use the new version  of the SVG (2.00b) 
LaTeX directly. The developer (Falk; Bcc) said that there will be a new 
release soon. I attach an example of the strange things that I can 
achieve. I hope that it's useful :) .

Cheers!

On 2018-01-09 03:34, John Kitchin wrote:
> 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.
> 
> 
> 
> edgar@openmail.cc 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


-------------------------------------------------

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!  

[-- Attachment #2: svg-sample.tar.gz --]
[-- Type: application/octet-stream, Size: 40596 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: filter for svg latex-export
@ 2018-09-09 20:03 Falk Hanisch
  0 siblings, 0 replies; 5+ messages in thread
From: Falk Hanisch @ 2018-09-09 20:03 UTC (permalink / raw)
  To: edgar@openmail.cc, John Kitchin; +Cc: John Kitchin, emacs-orgmode@gnu.org

Version v2.02 of package svg was installed on CTAN and is available for Tex Live or MiKTeX

> -----Ursprüngliche Nachricht-----
> Von: edgar@openmail.cc <edgar@openmail.cc>
> Gesendet: Freitag, 7. September 2018 03:23
> An: John Kitchin <jkitchin@andrew.cmu.edu>
> Cc: emacs-orgmode@gnu.org; John Kitchin <johnrkitchin@gmail.com>
> Betreff: Re: [O] filter for svg latex-export
> 
> Hi,
> 
> I want to report that I can use the new version  of the SVG (2.00b)
> LaTeX directly. The developer (Falk; Bcc) said that there will be a new
> release soon. I attach an example of the strange things that I can
> achieve. I hope that it's useful :) .
> 
> Cheers!
> 
> On 2018-01-09 03:34, John Kitchin wrote:
> > 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.
> >
> >
> >
> > edgar@openmail.cc 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
> 
> 
> -------------------------------------------------
> 
> 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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-09 20:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-08  0:10 filter for svg latex-export edgar
2018-01-09  3:34 ` John Kitchin
2018-01-09  3:47   ` edgar
2018-09-07  1:22   ` edgar
  -- strict thread matches above, loose matches on Subject: below --
2018-09-09 20:03 Falk Hanisch

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).