Function: org-babel-execute:plantuml
org-babel-execute:plantuml is a byte-compiled function defined in
ob-plantuml.el.gz.
Signature
(org-babel-execute:plantuml BODY PARAMS)
Documentation
Execute a block of plantuml code with org-babel.
This function is called by org-babel-execute-src-block.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-plantuml.el.gz
(defun org-babel-execute:plantuml (body params)
"Execute a block of plantuml code with org-babel.
This function is called by `org-babel-execute-src-block'."
(let* ((do-export (member "file" (cdr (assq :result-params params))))
(out-file (if do-export
(or (cdr (assq :file params))
(error "No :file provided but :results set to file. For plain text output, set :results to verbatim"))
(org-babel-temp-file "plantuml-" ".txt")))
(cmdline (cdr (assq :cmdline params)))
(in-file (org-babel-temp-file "plantuml-"))
(java (or (cdr (assq :java params)) ""))
(executable (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-executable-path)
(t "java")))
(executable-args (cond ((eq org-plantuml-exec-mode 'plantuml) org-plantuml-args)
((string= "" org-plantuml-jar-path)
(error "`org-plantuml-jar-path' is not set"))
((not (file-exists-p org-plantuml-jar-path))
(error "Could not find plantuml.jar at %s" org-plantuml-jar-path))
(t `(,java
"-jar"
,(shell-quote-argument (expand-file-name org-plantuml-jar-path))
,@org-plantuml-args))))
(full-body (org-babel-plantuml-make-body body params))
(cmd (mapconcat #'identity
(append
(list executable)
executable-args
(pcase (file-name-extension out-file)
("png" '("-tpng"))
("svg" '("-tsvg"))
("eps" '("-teps"))
("pdf" '("-tpdf"))
("tex" '("-tlatex"))
("tikz" '("-tlatex:nopreamble"))
("vdx" '("-tvdx"))
("xmi" '("-txmi"))
("scxml" '("-tscxml"))
("html" '("-thtml"))
("txt" '("-ttxt"))
("utxt" '("-utxt")))
(list
"-p"
cmdline
"<"
(org-babel-process-file-name in-file)
">"
(org-babel-process-file-name out-file)))
" ")))
(with-temp-file in-file (insert full-body))
(message "%s" cmd) (org-babel-eval cmd "")
(if (and (string= (file-name-extension out-file) "svg")
org-babel-plantuml-svg-text-to-path)
(org-babel-eval (format "inkscape %s -T -l %s" out-file out-file) ""))
(unless do-export (with-temp-buffer
(insert-file-contents out-file)
(buffer-substring-no-properties
(point-min) (point-max))))))