consider following mve in org-mode -- contains full question in detail. but, in summary, code blocks, noweb references other code blocks substituted inline when export document, and, other code blocks, noweb references, in double broket quotes, copied verbatim exported pdf. not know causes difference in behavior , don't know how control it, i'd to. i'd able specify blocks have behavior 1 (references substituted) , other blocks have behavior 2 (references verbatim).
the pdf results org-export
at link
#+begin_comment emacs lisp block must export results, though results none, otherwise block not eval'ed on export, , unacceptable confirmation requests subsequent python blocks. #+end_comment #+begin_src emacs-lisp :exports results :results none (setq org-confirm-babel-evaluate nil) #+end_src ** pytests define test , cases. code must tangled out external file =py.test= can see it. when /export/ pdf, noweb references, namely =<<imports>>= , =<<definitions>>=, substituted inline, typeset version of block in pdf shows code. not want. #+name: test-block #+begin_src python :noweb yes :tangle test_foo.py <<imports>> <<definitions>> def test_smoke (): np.testing.assert_approx_equal (foo_func (), foo_constant) #+end_src #+results: test-block : none following blocks import prerequisites , quick smoke test: ** imports #+name: imports #+begin_src python import numpy np #+end_src #+results: imports : none ** define variables however, in typeset pdf, noweb reference =<<foo-func>>= in block below /not/ substituted in-line, rather appears verbatim. want /all/ noweb references appear verbatim in exported, typeset, pdf document, one. #+name: definitions #+begin_src python foo_constant = 42.0 <<foo-func>> #+end_src #+results: definitions ** define functions *** foo function interesting #+name: foo-func #+begin_src python def foo_func () : return 42.000 #+end_src #+results: foo-func : none want results pytest whether succeeds or fails, hence /or/ =true= in shell #+begin_src sh :results output replace :exports both py.test || true #+end_src #+results: : ============================= test session starts ============================== : platform darwin -- python 2.7.10, pytest-2.8.0, py-1.4.30, pluggy-0.3.1 : rootdir: /users/bbeckman/foo, inifile: : collected 1 items : : test_foo.py . : : =========================== 1 passed in 0.06 seconds ===========================
found appropriate references here
here corrected pdf exported following .org file.
and here corrected mve (it, itself, explains correction):
#+begin_comment emacs lisp block must export results, though exports none, otherwise block not eval'ed on export, , unacceptable confirmation requests subsequent python blocks. #+end_comment #+begin_src emacs-lisp :exports results :results none (setq org-confirm-babel-evaluate nil) #+end_src ** pytests define test , cases. code must tangled out external file =py.test= can see it. when /export/ pdf, noweb references, namely =<<imports>>= , =<<definitions>>=, *not* substituted inline, typeset verbatim. want. behavior saying =:noweb no-export= in header. #+name: test-block #+begin_src python :tangle test_foo.py :noweb no-export :exports code :results none dummy_for_org_mode = true <<imports>> <<definitions>> def test_smoke (): np.testing.assert_approx_equal (foo_func (), foo_constant) #+end_src following blocks import prerequisites , quick smoke test: ** imports #+name: imports #+begin_src python :exports code :results none import numpy np #+end_src ** define variables , functions in block, want noweb reference =<<foo-func>>= in block substituted in-line , not appear verbatim. saying =:noweb yes= in header. #+name: definitions #+begin_src python :noweb yes :exports code :results none foo_constant = 42.0 <<foo-func>> #+end_src ** define functions *** foo function interesting here, want talk implementation of foo function in detail, don't want code exported again, appear in original =.org= file reminder or note me. #+name: foo-func #+begin_src python :exports none :results none def foo_func () : return 42.000 #+end_src ** run tests want results pytest whether succeeds or fails, hence /or/ =true= in shell #+begin_src sh :results output replace :exports both py.test || true #+end_src #+results: : ============================= test session starts ============================== : platform darwin -- python 2.7.10, pytest-2.8.0, py-1.4.30, pluggy-0.3.1 : rootdir: /users/bbeckman/foo, inifile: : collected 1 items : : test_foo.py . : : =========================== 1 passed in 0.08 seconds ===========================
Comments
Post a Comment