From: Brian Beckman <bc.beckman@gmail.com>
To: emacs-orgmode@gnu.org
Subject: export: noweb blocks substituted versus verbatim ?
Date: Sat, 26 Sep 2015 21:26:14 +0000 (UTC) [thread overview]
Message-ID: <loom.20150926T231822-803@post.gmane.org> (raw)
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
https://drive.google.com/file/d/0B4v0MzmZfdm8TzRLeFlreUFnbEk/view
#+BEGIN_COMMENT
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.
#+END_COMMENT
#+BEGIN_SRC emacs-lisp :exports results :results none
(setq org-confirm-babel-evaluate nil)
#+END_SRC
** 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
<<imports>>
<<definitions>>
def test_smoke ():
np.testing.assert_approx_equal (foo_func (), foo_constant)
#+END_SRC
#+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
#+END_SRC
#+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
<<foo-func>>
#+END_SRC
#+RESULTS: definitions
** Define Some Functions
*** Foo Function is Really Interesting
#+NAME: foo-func
#+BEGIN_SRC python
def foo_func () :
return 42.000
#+END_SRC
#+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
#+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
===========================
next reply other threads:[~2015-09-26 21:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-26 21:26 Brian Beckman [this message]
2015-09-26 22:45 ` export: noweb blocks substituted versus verbatim ? Andreas Leha
2015-09-26 23:19 ` Brian Beckman
2015-09-27 2:54 ` Charles C. Berry
2015-09-28 4:40 ` Brian Beckman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=loom.20150926T231822-803@post.gmane.org \
--to=bc.beckman@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.