Presently there are three noweb modes: yes, no, and tangle. I would like a fourth, which would behave as follows: On tangle: normal noweb expansion is performed. On evaluation: normal noweb expansion is performed. On export: noweb references are STRIPPED. Not just ignored, but the lines containing the references are removed before export. The use case is this: I find myself writing articles where I have a series of code examples like this: #+begin_src ruby <<boilerplate>> 2 + 2 # => #+end_src The boilerplate is required to make the sample work, but I don't want to have the boilerplate code show up in the finished article, because it would be repeated for every example. I also don't want the noweb reference to show up in the finished article, because it will confuse readers and syntax highlighters. Is this possible now, and/or a feature that could be easily added? Thanks, -- Avdi Grimm http://avdi.org
Hi Avdi,
Avdi Grimm wrote:
> Presently there are three noweb modes: yes, no, and tangle. I would
> like a fourth, which would behave as follows:
Just for the sake of completeness, there is already a fourth option:
"no-export" which expands noweb references during tangling and execution, but
not during weaving (export).
Best regards,
Seb
--
Sebastien Vauban
On Tue, Jan 31, 2012 at 2:56 AM, Sebastien Vauban <wxhgmqzgwmuf@spammotel.com> wrote: > Just for the sake of completeness, there is already a fourth option: Ah! Looks like I had an older version. Thanks for prompting me to update! I guess what I'm looking for would be called ":noweb export-strip" or something like that. -- Avdi Grimm http://avdi.org
P.S. It's been a while since I've been on this ML, so if there's a "right way" to do a feature request please let me know and I'll do it :-) On Tue, Jan 31, 2012 at 12:38 PM, Avdi Grimm <groups@inbox.avdi.org> wrote: > On Tue, Jan 31, 2012 at 2:56 AM, Sebastien Vauban > <wxhgmqzgwmuf@spammotel.com> wrote: >> Just for the sake of completeness, there is already a fourth option: > > Ah! Looks like I had an older version. Thanks for prompting me to update! > > I guess what I'm looking for would be called ":noweb export-strip" or > something like that. > > -- > Avdi Grimm > http://avdi.org -- Avdi Grimm http://avdi.org
Avdi Grimm <groups@inbox.avdi.org> writes: > P.S. It's been a while since I've been on this ML, so if there's a > "right way" to do a feature request please let me know and I'll do it > :-) > You initial post in this thread was perfect, succinct and complete. Cheers, > > On Tue, Jan 31, 2012 at 12:38 PM, Avdi Grimm <groups@inbox.avdi.org> wrote: >> On Tue, Jan 31, 2012 at 2:56 AM, Sebastien Vauban >> <wxhgmqzgwmuf@spammotel.com> wrote: >>> Just for the sake of completeness, there is already a fourth option: >> >> Ah! Looks like I had an older version. Thanks for prompting me to update! >> >> I guess what I'm looking for would be called ":noweb export-strip" or >> something like that. >> >> -- >> Avdi Grimm >> http://avdi.org -- Eric Schulte http://cs.unm.edu/~eschulte/
Avdi Grimm <groups@inbox.avdi.org> writes: > Presently there are three noweb modes: yes, no, and tangle. I would > like a fourth, which would behave as follows: > > On tangle: normal noweb expansion is performed. > On evaluation: normal noweb expansion is performed. > On export: noweb references are STRIPPED. Not just ignored, but the > lines containing the references are removed before export. > > The use case is this: I find myself writing articles where I have a > series of code examples like this: > > #+begin_src ruby > <<boilerplate>> > 2 + 2 # => > #+end_src > > The boilerplate is required to make the sample work, but I don't want > to have the boilerplate code show up in the finished article, because > it would be repeated for every example. I also don't want the noweb > reference to show up in the finished article, because it will confuse > readers and syntax highlighters. > > Is this possible now, and/or a feature that could be easily added? > I've just added tested and documented such a "strip-export" argument to :noweb. Please let me know if it doesn't work as you expected. Best, > > Thanks, -- Eric Schulte http://cs.unm.edu/~eschulte/
On Wed, Feb 1, 2012 at 10:21 AM, Eric Schulte <eric.schulte@gmx.com> wrote: > I've just added tested and documented such a "strip-export" argument to > :noweb. Please let me know if it doesn't work as you expected. I just wanted to let you know I finally tried this out and it works beautifully. Thank you! -- Avdi Grimm http://avdi.org
Hi, I've tried to use the new :noweb strip-export feature but I can't work out the magic combination of headers (working with git head, i.e. commit 67694297fa0f9b32cf4bfe812ba8a5c5cf4a0859). Here is a stripped down example: START OF EXAMPLE * Example Define method #+name: boilerplate #+begin_src ruby def hello "Hello World" end #+end_src Use it #+name: example #+begin_src ruby :exports both :noweb strip-export «boilerplate» hello #+end_src And here is the result: #+RESULTS: example : Hello World END OF EXAMPLE On export, I expect this to display the result string "Hello World" after the code "hello" but get nothing. If I change the :noweb strip-export to :noweb yes, I do get the output (but also the boilerplate of course). Is strip-export meant to work like this? If so, could someone please post a working example? Thanks, Sean
Sean O'Halpin <sean.ohalpin@gmail.com> wrote:
>
> #+name: example
> #+begin_src ruby :exports both :noweb strip-export
> =ABboilerplate=BB
>
> hello
> #+end_src
>
This may have nothing to do with anything (it may even be an artifact of
mailer misbehavior) but is this supposed to be <<boilerplate>>? These
are supposed to be ASCII chars, so if you are using some sort of extended
charset, try changing them and see if that works.
Nick
"Sean O'Halpin" <sean.ohalpin@gmail.com> writes:
> Hi,
>
> I've tried to use the new :noweb strip-export feature but I can't work
> out the magic combination of headers (working with git head, i.e.
> commit 67694297fa0f9b32cf4bfe812ba8a5c5cf4a0859).
>
> Here is a stripped down example:
>
> START OF EXAMPLE
>
> * Example
>
> Define method
>
> #+name: boilerplate
> #+begin_src ruby
> def hello
> "Hello World"
> end
> #+end_src
>
> Use it
>
> #+name: example
> #+begin_src ruby :exports both :noweb strip-export
> «boilerplate»
>
> hello
> #+end_src
>
> And here is the result:
>
> #+RESULTS: example
> : Hello World
>
> END OF EXAMPLE
>
> On export, I expect this to display the result string "Hello World"
> after the code "hello" but get nothing. If I change the :noweb
> strip-export to :noweb yes, I do get the output (but also the
> boilerplate of course).
>
> Is strip-export meant to work like this? If so, could someone please
> post a working example?
>
> Thanks,
> Sean
If you don't want to export boilerplate you've to use :exports none in
it.
#+name: boilerplate
#+begin_src ruby :exports none
def hello
"Hello World"
end
#+end_src
Use it
#+name: example
#+begin_src ruby :exports both :noweb strip-export
<<boilerplate>>
hello
#+end_src
On Fri, Mar 30, 2012 at 5:37 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> This may have nothing to do with anything (it may even be an artifact of
> mailer misbehavior) but is this supposed to be <<boilerplate>>? These
> are supposed to be ASCII chars, so if you are using some sort of extended
> charset, try changing them and see if that works.
>
> Nick
I've customized =org-babel-noweb-wrap-start= and
=org-babel-noweb-wrap-end= to use guillemets rather than angle
brackets. The noweb stuff is working. It's the lack of the results output
when using strip-export that is bugging me.
On Fri, Mar 30, 2012 at 5:39 PM, Daimrod <daimrod@gmail.com> wrote:
> If you don't want to export boilerplate you've to use :exports none in
> it.
>
> #+name: boilerplate
> #+begin_src ruby :exports none
> def hello
> "Hello World"
> end
> #+end_src
>
> Use it
>
> #+name: example
> #+begin_src ruby :exports both :noweb strip-export
> <<boilerplate>>
>
> hello
> #+end_src
>
Thanks but that's not my problem. When I use :exports both I get the
code but not the results output in my exported HTML.
Do you get the "Hello World" output? If so, it looks like I'll have to
debug my configuration.
"Sean O'Halpin" <sean.ohalpin@gmail.com> writes:
> On Fri, Mar 30, 2012 at 5:39 PM, Daimrod <daimrod@gmail.com> wrote:
>> If you don't want to export boilerplate you've to use :exports none in
>> it.
>>
>> #+name: boilerplate
>> #+begin_src ruby :exports none
>> def hello
>> "Hello World"
>> end
>> #+end_src
>>
>> Use it
>>
>> #+name: example
>> #+begin_src ruby :exports both :noweb strip-export
>> <<boilerplate>>
>>
>> hello
>> #+end_src
>>
> Thanks but that's not my problem. When I use :exports both I get the
> code but not the results output in my exported HTML.
> Do you get the "Hello World" output? If so, it looks like I'll have to
> debug my configuration.
No, you're right, I have to execute evaluate the code manually to
produce
#+RESULTS: example
: Hello World
and then it's exported but only if the code isn't evaluated during the
export. It looks like there is a bug with in the ruby part because the
following code works as expected.
----------
* Title
#+name: boilerplate
#+begin_src emacs-lisp :exports none
(defun hello ()
"Hello World")
#+end_src
Use it
#+name: example
#+begin_src emacs-lisp :exports both :noweb strip-export
<<boilerplate>>
(hello)
#+end_src
----------
It exports to
----------
1 Title
Use it
(hello)
Hello World
----------
Nick Dokos <nicholas.dokos@hp.com> writes: > Sean O'Halpin <sean.ohalpin@gmail.com> wrote: > >> On Fri, Mar 30, 2012 at 5:39 PM, Daimrod <daimrod@gmail.com> wrote: >> > If you don't want to export boilerplate you've to use :exports none in >> > it. >> > >> > #+name: boilerplate >> > #+begin_src ruby :exports none >> > def hello >> > "Hello World" >> > end >> > #+end_src >> > >> > Use it >> > >> > #+name: example >> > #+begin_src ruby :exports both :noweb strip-export >> > <<boilerplate>> >> > >> > hello >> > #+end_src >> > >> Thanks but that's not my problem. When I use :exports both I get the >> code but not the results output in my exported HTML. >> Do you get the "Hello World" output? If so, it looks like I'll have to >> debug my configuration. >> > > Now that I've tried it, I can reproduce it: the final results disappear > on export. > > Nick > > Thanks for bringing this problem to light. I've just pushed up a fix. Cheers, -- Eric Schulte http://cs.unm.edu/~eschulte/
Sean O'Halpin <sean.ohalpin@gmail.com> wrote:
> On Fri, Mar 30, 2012 at 5:39 PM, Daimrod <daimrod@gmail.com> wrote:
> > If you don't want to export boilerplate you've to use :exports none in
> > it.
> >
> > #+name: boilerplate
> > #+begin_src ruby :exports none
> > def hello
> > "Hello World"
> > end
> > #+end_src
> >
> > Use it
> >
> > #+name: example
> > #+begin_src ruby :exports both :noweb strip-export
> > <<boilerplate>>
> >
> > hello
> > #+end_src
> >
> Thanks but that's not my problem. When I use :exports both I get the
> code but not the results output in my exported HTML.
> Do you get the "Hello World" output? If so, it looks like I'll have to
> debug my configuration.
>
Now that I've tried it, I can reproduce it: the final results disappear
on export.
Nick
On Sat, Mar 31, 2012 at 4:32 PM, Eric Schulte <eric.schulte@gmx.com> wrote:
>
> Thanks for bringing this problem to light. I've just pushed up a fix.
>
> Cheers,
>
> --
> Eric Schulte
> http://cs.unm.edu/~eschulte/
Thanks! This is really useful.
Regards,
Sean