emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Exporting noweb-ref's without disabling org-babel processing


From: Berry, Charles
Subject: Re: [O] Exporting noweb-ref's without disabling org-babel processing
Date: Wed, 23 Oct 2019 16:50:40 +0000

Diego,

I am not sure I understand. Here is my interpretation:

You wish to have `:exports both' behavior in your org export.

You want noweb references in the exported code to render as angle-bracketed 
chunk names, such as <<my-code>> rather than being expanded in place.

If that is what you want, you can use the feature of CALL keywords that resets 
the header arguments for the src block it calls to obtain different behavior 
with the same code. For example:

#+begin_src org
  ,#+name: template-chunk
  ,#+begin_src emacs-lisp :noweb no
  (concat c b a
  <<super-duper-code>>
  )
  ,#+end_src

  ,#+CALL: template-chunk() :noweb yes :var a="A" b="B" c="C"

  ,#+begin_src emacs_lisp :noweb-ref super-duper-code
  (concat a b c)
  ,#+end_src
#+end_src

exports as 

--8<---------------cut here---------------start------------->8---
,----
| (concat c b a
| <<super-duper-code>>
| )
`----

,----
| CBAABC
`----


,----
| (concat a b c)
`----
--8<---------------cut here---------------end--------------->8---

HTH,

Chuck

> On Oct 22, 2019, at 1:29 PM, Diego Zamboni <address@hidden> wrote:
> 
> Hi,
> 
> I'm working on a Leanpub Markua exporter (not quite complete yet but already 
> usable, if you are interested: 
> https://github.com/zzamboni/ox-leanpub/tree/book-and-markua)
> 
> I would like to include the value of :noweb-ref for code blocks in exported 
> output, like noweb originally did, e.g. something like this:
> 
> #begin_src emacs_lisp :noweb-ref super-duper-code
> ...
> #end_src
> 
> to produce something like this in the export:
> 
> <<super-duper-code>>=
>  ...
> 
> After much poking around, I figured that the :noweb and :noweb-ref header 
> args are removed by org-babel *before* the src block makes it to the 
> exporter. I also discovered that by setting org-export-use-babel to nil I 
> could disable this behavior, which means that my exporter can access the 
> :noweb-ref argument by parsing the :parameters property (see 
> https://github.com/zzamboni/ox-leanpub/blob/book-and-markua/ox-leanpub-markua.el#L388).
> 
> This was good for my original purpose, but I just realized that this also 
> disables other useful org-babel features on export, such as the processing of 
> the :exports header argument, which means that both code and results are 
> always included in the export regardless of what :exports says :)
> 
> I have tried using org-babel-exp-code-template, but unfortunately if I try to 
> use "%noweb-ref" as a key in its value, it gets replaced by the value of 
> :noweb followed by "-ref" in every case.
> 
> Is there some other way of accessing org-babel header arguments like 
> :noweb-ref from the exporter, but without having to disable org-babel 
> processing completely? Any other ideas for achieving what I want?
> 
> Thanks for any ideas,
> --Diego
> 





reply via email to

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