Eric Schulte <eric.schu...@gmx.com> writes:

> Luis Anaya <papoan...@hotmail.com> writes:
>
>> Eric Schulte <eric.schu...@gmx.com> writes:
>>
>> Please, provide the option to not create the PDF file at the end for
>> those poor people that use Groff to create documents in which will barf
>> on a PDF file.
>>
>> Thanks,
>>
>> Luis
>
> Good idea,
>
> The attached version makes this change.  If someone can confirm that
> this patch works I can apply it.
>
> Thanks,

with the attachment :)

>From 014fa9fd68a6476df2da32c590781788672a0f1a Mon Sep 17 00:00:00 2001
From: Eric Schulte <eric.schu...@gmx.com>
Date: Thu, 13 Sep 2012 08:58:31 -0600
Subject: [PATCH] adding :eps header argument to ditaa code blocks

Use of this header argument will change the back-end engine from
ditaa.jar to a combination of DitaaEps.jar and epstopdf.

This patch is based off of ob-ditaa-eps.el sent to the mailing list by
Arne Babenhauserheide (IMK).
---
 lisp/ob-ditaa.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-ditaa.el b/lisp/ob-ditaa.el
index 1c6c712..d97af14 100644
--- a/lisp/ob-ditaa.el
+++ b/lisp/ob-ditaa.el
@@ -57,6 +57,9 @@
   :group 'org-babel
   :type 'string)
 
+(defcustom org-ditaa-eps-jar-path
+  (expand-file-name "DitaaEps.jar" (file-name-nondirectory org-ditaa-jar-path)))
+
 (defcustom org-ditaa-jar-option "-jar"
   "Option for the ditaa jar file.
 Do not leave leading or trailing spaces in this string."
@@ -76,16 +79,25 @@ This function is called by `org-babel-execute-src-block'."
 	 (cmdline (cdr (assoc :cmdline params)))
 	 (java (cdr (assoc :java params)))
 	 (in-file (org-babel-temp-file "ditaa-"))
+	 (eps (cdr (assoc :eps params)))
 	 (cmd (concat "java " java " " org-ditaa-jar-option " "
 		      (shell-quote-argument
-		       (expand-file-name org-ditaa-jar-path))
+		       (expand-file-name
+			(if eps org-ditaa-eps-jar-path org-ditaa-jar-path)))
 		      " " cmdline
 		      " " (org-babel-process-file-name in-file)
-		      " " (org-babel-process-file-name out-file))))
+		      " " (org-babel-process-file-name out-file)))
+	 (pdf-cmd (when (and (or (string= (file-name-extension out-file) "pdf")
+				 (cdr (assoc :pdf params))))
+		    (concat
+		     "epstopdf"
+		     " " (org-babel-process-file-name (concat in-file ".eps"))
+		     " -o=" (org-babel-process-file-name out-file)))))
     (unless (file-exists-p org-ditaa-jar-path)
       (error "Could not find ditaa.jar at %s" org-ditaa-jar-path))
     (with-temp-file in-file (insert body))
     (message cmd) (shell-command cmd)
+    (when pdf-cmd (message pdf-cmd) (shell-command pdf-cmd))
     nil)) ;; signal that output has already been written to file
 
 (defun org-babel-prep-session:ditaa (session params)
-- 
1.7.12

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

Reply via email to