emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Noweb blocks duplicate during Org export if part of #+include


From: Nicolas Goaziou
Subject: Re: [O] Noweb blocks duplicate during Org export if part of #+include
Date: Sat, 08 Dec 2018 10:42:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Hello,

Kaushal Modi <address@hidden> writes:

> Here is a MWE:
>
> 1. With point on the "** Foo" section, running C-c C-e C-s h o, will
> result in noweb-duplicate-bug.html with the <<some_snippet>> block
> expanded only once, as expected.
>
> 2. But with point on the "* Foo Included" section, running the same
> C-c C-e C-s h o, will result in foo_included.html with the
> <<some_snippet>> block expanded twice! It seems like the Noweb
> expansion happens first as usual, and then again when parsing
> #+include (which shouldn't happen?).

That's not exactly what is happening.

INCLUDE keywords are always expanded before Babel kicks in. Moreover,
when exporting a subtree, only INCLUDE keywords from the subtree are
expanded. So, in your first example, nothing fancy happens.

Now, onto the second case. When evaluating Babel code, the whole initial
buffer is taken as reference. It allows, for example, to define source
blocks in a dedicated section, and export another one that calls them.
When the INCLUDE keyword is expanded, there are two ":noweb-ref
some_snippet". Even if they are outside the exported subtree, they are
still concatenated and used as a replacement for "<<some_snippet>".

In a nutshell, that can be surprising, but this is to be expected.

Regards,

-- 
Nicolas Goaziou



reply via email to

[Prev in Thread] Current Thread [Next in Thread]