optionally export additional information with call lines
* lisp/ob-exp.el (org-babel-exp-call-line-template): Control export of additional call line information. (org-babel-exp-non-block-elements): Fancier call line export. * testing/examples/babel.org (an): Example data to test new call line export. * testing/lisp/test-ob-exp.el (ob-exp/export-call-line-information): Test new call line export.
This commit is contained in:
parent
1d99fd7010
commit
527e6844cc
|
@ -115,6 +115,23 @@ none ----- do not display either code or results upon export"
|
|||
(nth 1 info)))
|
||||
(org-babel-exp-do-export info 'block hash)))))
|
||||
|
||||
(defcustom org-babel-exp-call-line-template
|
||||
""
|
||||
"Template used to export call lines.
|
||||
This template may be customized to include the call line name
|
||||
with any export markup. The template is filled out using
|
||||
`org-fill-template', and the following %keys may be used.
|
||||
|
||||
line --- call line
|
||||
|
||||
An example value would be \"\\n: call: %line\" to export the call line
|
||||
wrapped in a verbatim environment.
|
||||
|
||||
Note: the results are inserted separately after the contents of
|
||||
this template."
|
||||
:group 'org-babel
|
||||
:type 'string)
|
||||
|
||||
(defvar org-babel-default-lob-header-args)
|
||||
(defun org-babel-exp-non-block-elements (start end)
|
||||
"Process inline source and call lines between START and END for export."
|
||||
|
@ -160,22 +177,24 @@ none ----- do not display either code or results upon export"
|
|||
(inlinep (match-string 11))
|
||||
(inline-start (match-end 11))
|
||||
(inline-end (match-end 0))
|
||||
(rep (let ((lob-info (org-babel-lob-get-info)))
|
||||
(save-match-data
|
||||
(org-babel-exp-do-export
|
||||
(list "emacs-lisp" "results"
|
||||
(org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-lob-header-args
|
||||
(org-babel-params-from-properties)
|
||||
(org-babel-parse-header-arguments
|
||||
(org-babel-clean-text-properties
|
||||
(concat ":var results="
|
||||
(mapconcat #'identity
|
||||
(butlast lob-info)
|
||||
" ")))))
|
||||
"" nil (car (last lob-info)))
|
||||
'lob)))))
|
||||
(results (save-match-data
|
||||
(org-babel-exp-do-export
|
||||
(list "emacs-lisp" "results"
|
||||
(org-babel-merge-params
|
||||
org-babel-default-header-args
|
||||
org-babel-default-lob-header-args
|
||||
(org-babel-params-from-properties)
|
||||
(org-babel-parse-header-arguments
|
||||
(org-babel-clean-text-properties
|
||||
(concat ":var results="
|
||||
(mapconcat #'identity
|
||||
(butlast lob-info)
|
||||
" ")))))
|
||||
"" nil (car (last lob-info)))
|
||||
'lob)))
|
||||
(rep (org-fill-template
|
||||
org-babel-exp-call-line-template
|
||||
`(("line" . ,(nth 0 lob-info))))))
|
||||
(if inlinep
|
||||
(save-excursion
|
||||
(goto-char inline-start)
|
||||
|
|
|
@ -334,3 +334,9 @@ Fifth
|
|||
#+begin_src emacs-lisp
|
||||
(push 5 *evaluation-collector*)
|
||||
#+end_src
|
||||
* exporting more than just results from a call line
|
||||
:PROPERTIES:
|
||||
:ID: bec63a04-491e-4caa-97f5-108f3020365c
|
||||
:END:
|
||||
Here is a call line with more than just the results exported.
|
||||
#+call: double(8)
|
||||
|
|
|
@ -231,6 +231,15 @@ elements in the final html."
|
|||
(org-export-as-ascii nil nil nil 'string)
|
||||
(should (equal '(5 4 3 2 1) *evaluation-collector*)))))
|
||||
|
||||
(ert-deftest ob-exp/export-call-line-information ()
|
||||
(org-test-at-id "bec63a04-491e-4caa-97f5-108f3020365c"
|
||||
(org-narrow-to-subtree)
|
||||
(let* ((org-babel-exp-call-line-template "\n: call: %line special-token")
|
||||
(html (org-export-as-html nil nil nil 'string t)))
|
||||
(should (string-match "double" html))
|
||||
(should (string-match "16" html))
|
||||
(should (string-match "special-token" html)))))
|
||||
|
||||
(provide 'test-ob-exp)
|
||||
|
||||
;;; test-ob-exp.el ends here
|
||||
|
|
Loading…
Reference in New Issue