emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] org-exp-block patch and Graphviz Demo


From: Eric Schulte
Subject: Re: [Orgmode] org-exp-block patch and Graphviz Demo
Date: Wed, 10 Jun 2009 10:12:24 -0700
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.92 (darwin)

Russell Adams <address@hidden> writes:

> On Wed, Jun 10, 2009 at 09:06:09AM -0700, Eric Schulte wrote:
>> Really it would probably be much easier to do this with a new block
>> type... what do the commands look like when you do this by hand?
>> 
>> Cheers -- Eric
>
> dot -Teps -o file.eps file.dot
> epstopdf file.eps
>
> Quick and simple.
>

I just posted a patch to org-exp-blocks.el that fixes a small typo/bug.

After that patch is applied, the code below[1] can be used to add a new
block type which will automatically process blocks with dot then eps.
For example the following block specification will create out-w-eps.eps
and org-w-eps.pdf files on export.

#+begin_dot-and-eps out-w-eps
digraph test {
a -> { b c d e };
e -> { f g h i };
};
#+end_dot-and-eps

Cheers -- Eric

[1]
(defun org-export-blocks-format-dot-and-eps (body &rest headers)
  "Pass block BODY to the dot graphing utility creating an eps
file which is then processed by eps to create a pdf.  Specify the
path at which the final pdf image should be created as the first
element of headers, any additional elements of headers will be
passed to the dot utility as command line arguments.

#+begin_dot_and_eps duh
digraph test {
a -> { b c d e };
e -> { f g h i };
};
#+end_dot"
  (message "dot-and-eps-formatting...")
  (let ((out-file (if headers (car headers)))
        (args (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))
        (data-file (make-temp-file "org-dot")))
    (cond
     ((or htmlp latexp docbookp)
      (with-temp-file data-file (insert body))
      (shell-command (message (concat "dot -Teps " data-file " " args " -o " 
out-file ".eps")))
      (shell-command (message (concat "epstopdf " out-file ".eps")))
      (format "\n[[file:%s.pdf]]\n" out-file))
     (t (concat
         "\n#+BEGIN_EXAMPLE\n"
         body (if (string-match "\n$" body) "" "\n")
         "#+END_EXAMPLE\n")))))

(org-export-blocks-add-block '(dot-and-eps org-export-blocks-format-dot-and-eps 
nil))




reply via email to

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