[使用ReadTheOrg将文学程序导出为HTML时保留源块的内容

问题描述 投票:0回答:1

最小示例

我使用具有:noweb扩展名(?)的读写编程技术以组织模式编写了一个程序。典型的代码如下:

* 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]].

程序的全部内容存储在一个文件中,该文件的顶部为#+SETUP: theme-readtheorg.setup。设置文件不是问题,因为HTML可以正确生成,仅包含不需要的内容。

问题

为了生成代码,我使用(org-babel-tangle)。这将生成所有我期望的带有:tangle参数的所有块的文件。这些文件具有我希望它们包含的内容,并按照应有的方式进行代码编译和运行。

为了生成我想随代码一起发布的文档,我使用(org-html-export-to-html)。我期望发生的是:

  1. <<tags>>将替换为它们的期望值,这不是理想的,但至少可以接受,或者
  2. <<tags>>的显示方式将保持不变,当使用Emacs编辑组织文件时。

但是(org-html-export-to-html)的输出却大不相同,并且出乎意料-所有<<tags>>都用换行符替换。这给我留下了所有代码块,它们的内容不正确,如果不查看生成的代码或原始的组织文件,就无法理解它们,这完全违背了将文档放在单独文件中的目的。我不能强迫与我一起工作的所有人切换到Emacs,让他们浏览文档!

问题

如上所述,问题在于(org-html-export-to-html)内部的某些调用导致noweb <>出现。关于这个问题,我的问题是:

我如何强制(org-html-export-to-html)保留源代码块的内容,而不剥离noweb <<tags>>

c++ emacs org-mode org-babel noweb
1个回答
0
投票

IIUC,您需要指定适当的:noweb标头。试试这个:

#+begin_src cpp :noweb no-export

并且有关其他值和更多详细信息,请参考手册中的noweb section

© www.soinside.com 2019 - 2024. All rights reserved.