[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] export: noweb blocks substituted versus verbatim ?

From: Brian Beckman
Subject: [O] export: noweb blocks substituted versus verbatim ?
Date: Sat, 26 Sep 2015 21:26:14 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Hello -- I have a situation where some code blocks with noweb references in
them <<like-this>> are substituted inline when I export the document, and
other code blocks with noweb references, are copied verbatim into the
exported PDF. I do not know what causes this difference in behavior and I
don't know how to control it, but I'd like to control it. I'd like to be
able to specify that some blocks have behavior 1 (references substituted
inline) and other blocks have behavior 2 (references verbatim).

I'm sure this is pilot error, but I'm stumped and would be grateful for advice. 

My Minimal Viable Example (MVE) follows below, and the PDF file that's
exported is here


The emacs lisp block must export results, even though the exports are none,
otherwise the block will not be eval'ed on export, and we will get 
unacceptable confirmation requests for all the subsequent python blocks. 

#+BEGIN_SRC emacs-lisp :exports results :results none
(setq org-confirm-babel-evaluate nil)

** PyTests

   Define the test and cases. This code must be tangled out to an external file
   so =py.test= can see it.

   When I /export/ this to PDF, the noweb references, namely =<<imports>>= and
   =<<definitions>>=, are substituted inline, so the typeset version of this
   block in the PDF shows ALL the code.  This is not what I want.

#+NAME: test-block
#+BEGIN_SRC python :noweb yes :tangle test_foo.py 
def test_smoke ():
    np.testing.assert_approx_equal (foo_func (), foo_constant)

#+RESULTS: test-block
: None

   The following blocks import prerequisites and do a quick smoke test:

** Do Some Imports

#+NAME: imports
#+BEGIN_SRC python 
import numpy as np

#+RESULTS: imports
: None

** Define Some Variables

   However, in the typeset PDF, the noweb reference =<<foo-func>>= in the block
   below is /not/ substituted in-line, but rather appears verbatim. I want /all/
   noweb references to appear verbatim in the exported, typeset, PDF document,
   just like this one.

#+NAME: definitions
#+BEGIN_SRC python 
foo_constant = 42.0

#+RESULTS: definitions

** Define Some Functions

*** Foo Function is Really Interesting

#+NAME: foo-func
#+BEGIN_SRC python
def foo_func () :
    return 42.000

#+RESULTS: foo-func
: None

We want results from pytest whether it succeeds or fails, hence the /OR/ with
=true= in the shell

#+BEGIN_SRC sh :results output replace :exports both
py.test || true

: ============================= 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]