emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Feature request for noweb mode that strips references on export
@ 2012-01-31  4:11 Avdi Grimm
  2012-01-31  7:56 ` Sebastien Vauban
  2012-02-01 15:21 ` Eric Schulte
  0 siblings, 2 replies; 16+ messages in thread
From: Avdi Grimm @ 2012-01-31  4:11 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-01-31  4:11 Feature request for noweb mode that strips references on export Avdi Grimm
@ 2012-01-31  7:56 ` Sebastien Vauban
  2012-01-31 17:38   ` Avdi Grimm
  2012-02-01 15:21 ` Eric Schulte
  1 sibling, 1 reply; 16+ messages in thread
From: Sebastien Vauban @ 2012-01-31  7:56 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-01-31  7:56 ` Sebastien Vauban
@ 2012-01-31 17:38   ` Avdi Grimm
  2012-01-31 18:48     ` Avdi Grimm
  0 siblings, 1 reply; 16+ messages in thread
From: Avdi Grimm @ 2012-01-31 17:38 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-01-31 17:38   ` Avdi Grimm
@ 2012-01-31 18:48     ` Avdi Grimm
  2012-02-01 14:18       ` Eric Schulte
  0 siblings, 1 reply; 16+ messages in thread
From: Avdi Grimm @ 2012-01-31 18:48 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-01-31 18:48     ` Avdi Grimm
@ 2012-02-01 14:18       ` Eric Schulte
  0 siblings, 0 replies; 16+ messages in thread
From: Eric Schulte @ 2012-02-01 14:18 UTC (permalink / raw)
  To: avdi; +Cc: emacs-orgmode

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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-01-31  4:11 Feature request for noweb mode that strips references on export Avdi Grimm
  2012-01-31  7:56 ` Sebastien Vauban
@ 2012-02-01 15:21 ` Eric Schulte
  2012-03-15 18:24   ` Avdi Grimm
  1 sibling, 1 reply; 16+ messages in thread
From: Eric Schulte @ 2012-02-01 15:21 UTC (permalink / raw)
  To: avdi; +Cc: emacs-orgmode

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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-02-01 15:21 ` Eric Schulte
@ 2012-03-15 18:24   ` Avdi Grimm
  2012-03-30 16:22     ` Sean O'Halpin
  0 siblings, 1 reply; 16+ messages in thread
From: Avdi Grimm @ 2012-03-15 18:24 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-15 18:24   ` Avdi Grimm
@ 2012-03-30 16:22     ` Sean O'Halpin
  2012-03-30 16:37       ` Nick Dokos
  2012-03-30 16:39       ` Daimrod
  0 siblings, 2 replies; 16+ messages in thread
From: Sean O'Halpin @ 2012-03-30 16:22 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode, avdi

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-30 16:22     ` Sean O'Halpin
@ 2012-03-30 16:37       ` Nick Dokos
  2012-03-31  8:28         ` Sean O'Halpin
  2012-03-30 16:39       ` Daimrod
  1 sibling, 1 reply; 16+ messages in thread
From: Nick Dokos @ 2012-03-30 16:37 UTC (permalink / raw)
  To: Sean O'Halpin; +Cc: nicholas.dokos, emacs-orgmode, avdi, Eric Schulte

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-30 16:22     ` Sean O'Halpin
  2012-03-30 16:37       ` Nick Dokos
@ 2012-03-30 16:39       ` Daimrod
  2012-03-31  8:33         ` Sean O'Halpin
  1 sibling, 1 reply; 16+ messages in thread
From: Daimrod @ 2012-03-30 16:39 UTC (permalink / raw)
  To: emacs-orgmode

"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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-30 16:37       ` Nick Dokos
@ 2012-03-31  8:28         ` Sean O'Halpin
  0 siblings, 0 replies; 16+ messages in thread
From: Sean O'Halpin @ 2012-03-31  8:28 UTC (permalink / raw)
  To: emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-30 16:39       ` Daimrod
@ 2012-03-31  8:33         ` Sean O'Halpin
  2012-03-31  9:04           ` Daimrod
  2012-03-31 16:03           ` Nick Dokos
  0 siblings, 2 replies; 16+ messages in thread
From: Sean O'Halpin @ 2012-03-31  8:33 UTC (permalink / raw)
  To: Daimrod; +Cc: emacs-orgmode

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.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-31  8:33         ` Sean O'Halpin
@ 2012-03-31  9:04           ` Daimrod
  2012-03-31 16:03           ` Nick Dokos
  1 sibling, 0 replies; 16+ messages in thread
From: Daimrod @ 2012-03-31  9:04 UTC (permalink / raw)
  To: emacs-orgmode

"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
----------

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-31 16:03           ` Nick Dokos
@ 2012-03-31 15:32             ` Eric Schulte
  2012-04-01 21:28               ` Sean O'Halpin
  0 siblings, 1 reply; 16+ messages in thread
From: Eric Schulte @ 2012-03-31 15:32 UTC (permalink / raw)
  To: nicholas.dokos; +Cc: Daimrod, emacs-orgmode

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/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-31  8:33         ` Sean O'Halpin
  2012-03-31  9:04           ` Daimrod
@ 2012-03-31 16:03           ` Nick Dokos
  2012-03-31 15:32             ` Eric Schulte
  1 sibling, 1 reply; 16+ messages in thread
From: Nick Dokos @ 2012-03-31 16:03 UTC (permalink / raw)
  To: Sean O'Halpin; +Cc: Daimrod, nicholas.dokos, emacs-orgmode

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Feature request for noweb mode that strips references on export
  2012-03-31 15:32             ` Eric Schulte
@ 2012-04-01 21:28               ` Sean O'Halpin
  0 siblings, 0 replies; 16+ messages in thread
From: Sean O'Halpin @ 2012-04-01 21:28 UTC (permalink / raw)
  To: Eric Schulte; +Cc: Daimrod, nicholas.dokos, emacs-orgmode

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-04-01 21:28 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-31  4:11 Feature request for noweb mode that strips references on export Avdi Grimm
2012-01-31  7:56 ` Sebastien Vauban
2012-01-31 17:38   ` Avdi Grimm
2012-01-31 18:48     ` Avdi Grimm
2012-02-01 14:18       ` Eric Schulte
2012-02-01 15:21 ` Eric Schulte
2012-03-15 18:24   ` Avdi Grimm
2012-03-30 16:22     ` Sean O'Halpin
2012-03-30 16:37       ` Nick Dokos
2012-03-31  8:28         ` Sean O'Halpin
2012-03-30 16:39       ` Daimrod
2012-03-31  8:33         ` Sean O'Halpin
2012-03-31  9:04           ` Daimrod
2012-03-31 16:03           ` Nick Dokos
2012-03-31 15:32             ` Eric Schulte
2012-04-01 21:28               ` Sean O'Halpin

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).