emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: org-exp-block patch and Graphviz Demo
Date: Wed, 10 Jun 2009 10:12:24 -0700	[thread overview]
Message-ID: <m2y6s057yf.fsf@gmail.com> (raw)
In-Reply-To: <20090610162240.GB11193@thinkpad.adamsinfoserv.com> (Russell Adams's message of "Wed, 10 Jun 2009 11:22:40 -0500")

Russell Adams <RLAdams@AdamsInfoServ.Com> 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	other threads:[~2009-06-10 17:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-27 19:09 org-exp-block patch and Graphviz Demo Russell Adams
2009-05-28  7:48 ` Carsten Dominik
2009-05-28 13:44   ` Eric Schulte
2009-05-28 14:23     ` Eric Schulte
2009-05-28 18:03 ` Org Mode List
2009-05-28 22:47   ` Russell Adams
2009-05-28 22:57     ` Eric Schulte
2009-06-09 15:50       ` Russell Adams
2009-06-10 14:51         ` Eric Schulte
2009-06-10 15:29           ` Russell Adams
2009-06-10 16:06             ` Eric Schulte
2009-06-10 16:22               ` Russell Adams
2009-06-10 17:12                 ` Eric Schulte [this message]
2009-06-10 17:54             ` Mark Elston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2y6s057yf.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).