Demonstrate inline-src block-behavior and the {{{results( )}}} macro. The `demo' src block sets up an inline-src-block, calls it, then exports the result. The output is as follows: - inline-src-block :: inline-src-block with headers and content. - export backend :: Which backend was used to render the result. - result :: What the ~*.org~ buffer looks looks like after babel executes the inline-src-block. - exported as :: Show the exported version (starting on the next line). * :results replace (default) #+name: demo #+BEGIN_SRC emacs-lisp :var str="replace" bkend="ascii" contents="42" (let ((cmd (format "src_emacs-lisp[:results %s]{%s}" str contents))) (concat "inline-src-block: " cmd "\nexport backend: " bkend "\nresult: " (with-temp-buffer (insert cmd) (org-babel-execute-buffer) (buffer-string)) "\nexported as:\n" (org-export-string-as cmd (intern bkend) t))) #+END_SRC #+RESULTS: demo : inline-src-block: src_emacs-lisp[:results replace]{42} : export backend: ascii : result: src_emacs-lisp[:results replace]{42} {{{results(=42=)}}} : exported as: : `42' #+CALL: demo("replace") #+RESULTS: : inline-src-block: src_emacs-lisp[:results replace]{42} : export backend: ascii : result: src_emacs-lisp[:results replace]{42} {{{results(=42=)}}} : exported as: : `42' * :results html under html backend #+CALL: demo("html","html") #+RESULTS: : inline-src-block: src_emacs-lisp[:results html]{42} : export backend: html : result: src_emacs-lisp[:results html]{42} {{{results(@@html:42@@)}}} : exported as: :
: 42
* :results html under latex backend #+CALL: demo("html","latex") #+RESULTS: : inline-src-block: src_emacs-lisp[:results html]{42} : export backend: latex : result: src_emacs-lisp[:results html]{42} {{{results(@@html:42@@)}}} : exported as: * :results latex under latex backend #+CALL: demo("latex","latex") #+RESULTS: : inline-src-block: src_emacs-lisp[:results latex]{42} : export backend: latex : result: src_emacs-lisp[:results latex]{42} {{{results(@@latex:42@@)}}} : exported as: : 42 * :results replace :wrap ascii #+CALL: demo("replace :wrap ascii","ascii") #+RESULTS: : inline-src-block: src_emacs-lisp[:results replace :wrap ascii]{42} : export backend: ascii : result: src_emacs-lisp[:results replace :wrap ascii]{42} {{{results(@@ascii:42@@)}}} : exported as: : 42 * :results raw #+CALL: demo("raw") #+RESULTS: : inline-src-block: src_emacs-lisp[:results raw]{42} : export backend: ascii : result: src_emacs-lisp[:results raw]{42} 42 : exported as: : 42 * :results drawer Same as default. #+CALL: demo("drawer") #+RESULTS: : inline-src-block: src_emacs-lisp[:results drawer]{42} : export backend: ascii : result: src_emacs-lisp[:results drawer]{42} {{{results(42)}}} : exported as: : 42 * :results org Code is quoted like this: `42' under ascii backend. #+CALL: demo("org") #+RESULTS: : inline-src-block: src_emacs-lisp[:results org]{42} : export backend: ascii : result: src_emacs-lisp[:results org]{42} {{{results(src_org{42})}}} : exported as: : `42' * :results code Code is quoted like this: `42' under ascii backend. #+CALL: demo("code") #+RESULTS: : inline-src-block: src_emacs-lisp[:results code]{42} : export backend: ascii : result: src_emacs-lisp[:results code]{42} {{{results(src_emacs-lisp[]{42})}}} : exported as: : `42' * :results list Lists and tables should be avoided for inline-src-blocks, but for completeness some are listed here. #+CALL: demo("list") #+RESULTS: : inline-src-block: src_emacs-lisp[:results list]{42} : export backend: ascii : result: src_emacs-lisp[:results list]{42} {{{results(*Inline error:* `:results list')}}} : exported as: : *Inline error:* `:results list' * :results table #+CALL: demo("table") #+RESULTS: : inline-src-block: src_emacs-lisp[:results table]{42} : export backend: ascii : result: src_emacs-lisp[:results table]{42} {{{results(*Inline error:* `:results table')}}} : exported as: : *Inline error:* `:results table' * :results replace, proper list as content Proper lists become tables. #+CALL: demo(contents="\'(42)") #+RESULTS: : inline-src-block: src_emacs-lisp[:results replace]{'(42) } : export backend: ascii : result: src_emacs-lisp[:results replace]{'(42) } {{{results(*Inline error:* list result)}}} : exported as: : *Inline error:* list result * :results code, contents as elisp #+CALL: demo("code",contents="(quote (+ 1 2))") #+RESULTS: : inline-src-block: src_emacs-lisp[:results code]{(quote (+ 1 2) )} : export backend: ascii : result: src_emacs-lisp[:results code]{(quote (+ 1 2) )} {{{results(src_emacs-lisp[]{(+ 1 2) : })}}} : exported as: : src_emacs-lisp[]{(+ 1 2) }