When <> expands to multiple line and I wrote like this
some-string <<noweb ref>>
then it expands like
some-string line1-from-noweb-ref
some-string line2-from-noweb-ref
some-string line3-from-noweb-ref
Is there a way to avoid this?
I think you're asking how to prefix only the first line of the noweb block. It will probably depend on the language your using, but I came up with this hack for bash:
#+NAME: example
#+BEGIN_SRC text
please echo this line
date ## but not this one
cd test ## this one
ls -l ## or this one
#+END_SRC
Bad source code block, echo prepended to very line:
#+BEGIN_SRC bash :noweb yes :results verbatim
echo <<example>>
#+END_SRC
#+RESULTS:
: please echo this line
: date
: cd test
: ls -l
:
Good source code block, echo prepended to the first line only, the rest
are executed:
#+BEGIN_SRC bash :noweb yes :results verbatim
echo \
<<example>>
#+END_SRC
#+RESULTS:
: please echo this line
: Thu Nov 9 10:22:32 EST 2017
: total 0
: -rw-r--r-- 1 tws tws 0 Nov 9 09:44 one
: -rw-r--r-- 1 tws tws 0 Nov 9 09:44 three
: -rw-r--r-- 1 tws tws 0 Nov 9 09:44 two
somestring ${nowebref()}
do the same - multiply somestring as many as nowebref() will return rows ?
Commented
Nov 10, 2017 at 9:26
some-string
to appear only on the first line? Or not at all? A minimal reproducible example would help clarify this.