[英]Preserving content of source blocks when exporting literate program to HTML with ReadTheOrg
I wrote a program in org-mode using literate programming technique with:noweb extension(?).我使用文学编程技术在 org 模式下编写了一个程序:noweb extension(?)。 Typical piece of code looks like this:
典型的代码如下所示:
* Section
In order to do foo with bar, we define a function ~do_foo~, which initializes object of a class ~BarParser~ with a value of parameter of the type ~bar_t~.
#+name: section_function_blockname
#+begin_src cpp
void do_foo
( bar_t bar
, <<additional_parameter_to_do_foo>>
) {
BarParser barParser(bar);
<<section_function_do_fooBody>>
}
#+end_src
The function will require additional parameter for the purposes of the /FizzBazz/ module. We will discuss them in a [[*Decoding FizzBazz messages][later_section]].
Entire content of the program is stored in a single file, which at the top has #+SETUP: theme-readtheorg.setup
.程序的全部内容存储在一个文件中,顶部有
#+SETUP: theme-readtheorg.setup
。 The setup file is not the problem, because the HTML generates correctly, only with not the content I want.安装文件不是问题,因为 HTML 生成正确,只是没有我想要的内容。
To generate the code, I use (org-babel-tangle)
.为了生成代码,我使用
(org-babel-tangle)
。 This produces all the files I'd expect for all the blocks with:tangle parameter.这会生成我期望的所有带有:tangle 参数的块的所有文件。 The files have the content I expect them to have and code compiles and runs the way it should.
这些文件具有我期望它们具有的内容,并且代码按应有的方式编译和运行。
To generate the documentation I'd like to publish along the code, I use (org-html-export-to-html)
.为了生成我想随代码发布的文档,我使用
(org-html-export-to-html)
。 What I expected to happen was that either:我期望发生的是:
<<tags>>
will get substituted with their expected value, which wouldn't be ideal but at least acceptable, or <<tags>>
将被它们的期望值替换,这不是理想的,但至少可以接受,或者<<tags>>
will be left untouched the way they are presented,when editing the org-file with Emacs.<<tags>>
将保持不变。 However the output to (org-html-export-to-html)
is quite different and unexpected - all the <<tags>>
are replaced with a newline character.然而 output 到
(org-html-export-to-html)
完全不同且出乎意料 - 所有<<tags>>
都替换为换行符。 This leaves me with all the code blocks having incorrect content that cannot be understood without either looking at the generated code or original org-file which completely defeats the purpose of the documentation being in the separate file.这让我看到所有代码块的内容不正确,如果不查看生成的代码或原始 org 文件就无法理解,这完全违背了文档在单独文件中的目的。 I cannot force everyone I work with to switch to Emacs to let them browse the documentation!
我不能强迫与我一起工作的每个人都切换到 Emacs 让他们浏览文档!
As stated above, the problem is with noweb <> being procesed by some call inside (org-html-export-to-html)
.如上所述,问题在于 noweb <> 被
(org-html-export-to-html)
内部的一些调用处理。 The question I have regarding this issue is:我对这个问题的疑问是:
How can I force (org-html-export-to-html)
to leave the contents of source blocks as they are, without stripping away the noweb <<tags>>
?如何强制
(org-html-export-to-html)
保留源块的内容,而不剥离 noweb <<tags>>
?
IIUC, you need to specify an appropriate :noweb
header. IIUC,您需要指定一个适当的
:noweb
header。 Try this:尝试这个:
#+begin_src cpp :noweb no-export
and refer to the noweb section in the manual for other values and more details.有关其他值和更多详细信息,请参阅手册中的noweb 部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.