Hi, The following code adds an export block of type 'mscgen'. The block body will be processed by the mscgen application. Sort of works, not very tested yet.
;;; org-exp-mscgen.el --- message sequence chart support for org-export ;; Copyright (C) 2010 ;; Free Software Foundation, Inc. ;; Author: Juan Pechiar ;; Version: 0.1 2010-05-16 ;; This is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This software is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;; ;; This software provides EMACS org-mode export support for message ;; sequence charts. The mscgen utility is used for processing the ;; sequence definition, and must therefore be installed in the system. ;; ;; The code is a direct modification of org-export-blocks-format-ditaa ;; from the org-mode distribution. ;; ;; Mscgen is available and documented at http://www.mcternan.me.uk/mscgen/index.html ;; ;; Customize path to mscgen utility with org-mscgen-path variable ;; ;; Example: ;; ;; #+begin_mscgen example1 ;; A,B; ;; --- [ label = "start of sequence" ]; ;; A -> B [ label = "send message" ]; ;; #+end_mscgen ;; ;; TODO: check cleanup of temp files ;; TODO: fix automatic filename generation when name not given ;; TODO: export in EPS format for LaTeX (need to convert EPS to PDF for pdflatex to use) (defvar org-mscgen-path "/opt/local/bin/mscgen" "Complete path to the mscgen executable") (defun org-export-blocks-format-mscgen (body &rest headers) "Pass block BODY to the mscgen utility creating an image. Enclosing tags \"msc{\" and \"}\" must not appear in BODY. Specify the path at which the image should be saved as the first element of headers. Additional header elements are ignored and for future use." (message "mscgen-formatting...") (let* ((args (if (cdr headers) (mapconcat 'identity (cdr headers) " "))) ;; for building hash (data-file (make-temp-file "org-mscgen")) ;; temp storage for BODY (hash (sha1 (prin1-to-string (list body args)))) ;; hash (body + args) (raw-out-file (if headers (car headers) "out_mscgen" )) ;; output file (out-file-parts (cons raw-out-file "png")) (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts))) (unless (file-exists-p org-mscgen-path) (error (format "Could not find mscgen at %s" org-mscgen-path))) (cond ((or latexp htmlp docbookp) ;; HTML, LaTeX and DocBook export (unless (file-exists-p out-file) (mapc ;; remove old hashed versions of this file (lambda (file) (when (and (string-match (concat (regexp-quote (car out-file-parts)) "_\\([[:alnum:]]+\\)\\." (regexp-quote (cdr out-file-parts))) file) (= (length (match-string 1 out-file)) 40)) (delete-file (expand-file-name file (file-name-directory out-file))))) (directory-files (or (file-name-directory out-file) default-directory))) (with-temp-file data-file (insert (concat "msc {\n" body "\n}\n"))) (message (concat org-mscgen-path " -T png -o " out-file " -i " data-file)) (shell-command (concat org-mscgen-path " -T png -o " out-file " -i " data-file))) (cond (latexp (format "\n#+ATTR_LaTeX: width=0.85\\textwidth\n[[file:%s]]\n" out-file)) (t (format "\n[[file:%s]]\n" out-file)))) ;; export to other formats: keep body as is (t (concat "\n#+BEGIN_EXAMPLE\n" body (if (string-match "\n$" body) "" "\n") "#+END_EXAMPLE\n"))))) (org-export-blocks-add-block '(mscgen org-export-blocks-format-mscgen nil)) _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode