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) (ignore-errors (org-babel-execute-buffer)) (buffer-string)) "\nexported as:\n" (ignore-errors (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} =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} =42= : exported as: : `42' * :results html under html backend #+CALL: demo("html","html") #+RESULTS: #+begin_example inline-src-block: src_emacs-lisp[:results html]{42} export backend: html result: src_emacs-lisp[:results html]{42} #+BEGIN_HTML 42#+END_HTML exported as:

#+BEGINHTML 42#+ENDHTML

#+end_example * :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} #+BEGIN_HTML : 42#+END_HTML : : exported as: : \#+BEGIN\(_{\text{HTML}}\) : 42\#+END\(_{\text{HTML}}\) * :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} #+BEGIN_LaTeX : 42#+END_LaTeX : : exported as: : \#+BEGIN\(_{\text{\LaTeX{}}}\) : 42\#+END\(_{\text{\LaTeX{}}}\) * :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} #+BEGIN_ascii : 42#+END_ascii : : exported as: : #+BEGIN_ascii 42#+END_ascii * :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:END: : : exported as: : :RESULTS: 42:END: * :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} src_org{42} : exported as: * :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} 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: s- 42 : : rc_emacs-lisp[:results list]{42} : exported as: * :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} : | 42 | : : exported as: : 42 * :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) } : | 42 | : : exported as: : 42 * :results replace, proper list as content, latex backend #+CALL: demo(bkend="latex",contents="\'((42)(43))") #+RESULTS: #+begin_example inline-src-block: src_emacs-lisp[:results replace]{'((42) (43))} export backend: latex result: src_emacs-lisp[:results replace]{'((42) (43))} | 42 | | 43 | exported as: \begin{center} \begin{tabular}{r} 42\\ 43\\ \end{tabular} \end{center} #+end_example * :results list, proper list as content, latex backend #+CALL: demo(str="list",bkend="latex",contents="\'((42)(43))") #+RESULTS: : inline-src-block: src_emacs-lisp[:results list]{'((42) (43))} : export backend: latex : result: s- (42) : - (43) : rc_emacs-lisp[:results list]{'((42) (43))} : : exported as: * :results html list Don't mix :results args like this! #+CALL: demo("html list") #+RESULTS: : inline-src-block: src_emacs-lisp[:results html list]{42} : export backend: ascii : result: s- 42 : #+END_HTML : rc_emacs-lisp[:results#+BEGIN_HTML : html list]{42} : exported as: * :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) )} src_emacs-lisp[]{(+ 1 2) : } : exported as: : src_emacs-lisp[]{(+ 1 2) }