* export: noweb blocks substituted versus verbatim ?
@ 2015-09-26 21:26 Brian Beckman
2015-09-26 22:45 ` Andreas Leha
2015-09-28 4:40 ` Brian Beckman
0 siblings, 2 replies; 5+ messages in thread
From: Brian Beckman @ 2015-09-26 21:26 UTC (permalink / raw)
To: emacs-orgmode
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
===========================
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: export: noweb blocks substituted versus verbatim ?
2015-09-26 21:26 export: noweb blocks substituted versus verbatim ? Brian Beckman
@ 2015-09-26 22:45 ` Andreas Leha
2015-09-26 23:19 ` Brian Beckman
2015-09-27 2:54 ` Charles C. Berry
2015-09-28 4:40 ` Brian Beckman
1 sibling, 2 replies; 5+ messages in thread
From: Andreas Leha @ 2015-09-26 22:45 UTC (permalink / raw)
To: emacs-orgmode
Hi Brian,
Brian Beckman <bc.beckman@gmail.com> writes:
> 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.
[[ omitted: the MVE ]]
As far as I can see, the difference is that some of the code blocks have
the header argument `:noweb yes', while others do not.
I do not know how to achieve working noweb extension during evaluation
but omitting noweb extension during export, though.
HTH,
Andreas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: export: noweb blocks substituted versus verbatim ?
2015-09-26 22:45 ` Andreas Leha
@ 2015-09-26 23:19 ` Brian Beckman
2015-09-27 2:54 ` Charles C. Berry
1 sibling, 0 replies; 5+ messages in thread
From: Brian Beckman @ 2015-09-26 23:19 UTC (permalink / raw)
To: emacs-orgmode
Andreas Leha <andreas.leha <at> med.uni-goettingen.de> writes:
>
> Hi Brian,
>
[[ omitted: deeper quotes ]]
>
> As far as I can see, the difference is that some of the code blocks have
> the header argument `:noweb yes', while others do not.
>
> I do not know how to achieve working noweb extension during evaluation
> but omitting noweb extension during export, though.
>
> HTH,
> Andreas
>
Hi Andreas,
Thanks for answering. I did some experiments putting `:noweb yes'
in various combinations and also putting a dummy line before the
references in the first (offending) block, like this:
#+NAME: test-block
#+BEGIN_SRC python :noweb yes :tangle test_foo.py
dummy_for_org_mode = True
<<imports>>
<<definitions>>
def test_smoke ():
np.testing.assert_approx_equal (foo_func (), foo_constant)
#+END_SRC
and separating the code lines with blank lines (as we must do in
org-babel `session' mode). None of it made any visible difference.
None of it made any difference
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: export: noweb blocks substituted versus verbatim ?
2015-09-26 22:45 ` Andreas Leha
2015-09-26 23:19 ` Brian Beckman
@ 2015-09-27 2:54 ` Charles C. Berry
1 sibling, 0 replies; 5+ messages in thread
From: Charles C. Berry @ 2015-09-27 2:54 UTC (permalink / raw)
To: Andreas Leha; +Cc: emacs-orgmode
On Sat, 26 Sep 2015, Andreas Leha wrote:
> Hi Brian,
>
> Brian Beckman <bc.beckman@gmail.com> writes:
>> 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.
>
> [[ omitted: the MVE ]]
>
> As far as I can see, the difference is that some of the code blocks have
> the header argument `:noweb yes', while others do not.
>
> I do not know how to achieve working noweb extension during evaluation
> but omitting noweb extension during export, though.
>
You can do like this (apart from anonymous backends):
#+header: :noweb (if (org-bound-and-true-p org-export-current-backend) "no" "yes")
HTH,
Chuck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: export: noweb blocks substituted versus verbatim ?
2015-09-26 21:26 export: noweb blocks substituted versus verbatim ? Brian Beckman
2015-09-26 22:45 ` Andreas Leha
@ 2015-09-28 4:40 ` Brian Beckman
1 sibling, 0 replies; 5+ messages in thread
From: Brian Beckman @ 2015-09-28 4:40 UTC (permalink / raw)
To: emacs-orgmode
Brian Beckman <bc.beckman <at> gmail.com> writes:
Found the appropriate docs here:
http://orgmode.org/manual/noweb.html#noweb
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-28 4:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-26 21:26 export: noweb blocks substituted versus verbatim ? Brian Beckman
2015-09-26 22:45 ` Andreas Leha
2015-09-26 23:19 ` Brian Beckman
2015-09-27 2:54 ` Charles C. Berry
2015-09-28 4:40 ` Brian Beckman
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.