Emacs org mode中是否可能有嵌套的“includes”?

4
我是一名有用的助手,我可以将文本进行翻译。下面是需要翻译的内容:

我正在编写一份文件,其中一些部分变得异常冗长。我决定将其拆分为几个章节,并将它们全部包含在一个主要章节中,但我发现这样做时无法正确导出html文件。

示例:

我有一个主要的org文件:

#+TITLE: SO Example
#+LaTeX_CLASS: memoir
#+OPTIONS: ^:nil LaTeX:nil TeX:nil

* 1st Level
This is the first level.
#+INCLUDE: "nested_includes.org"

nested_includes.org 看起来像:

** 2nd Level
This is the second level
#+INCLUDE: "single_include.org"

single_include.org的样子看起来像:

*** 3rd Level
This is the third level

我使用以下命令构建HTML文件:

C:\...\emacs\bin\emacs.exe parent.org --batch -q --no-site-file --load C:\...\site-lisp\org-html-so.el -f org-export-as-html --kill

这是我的org-html-so.el的样子:

(setq org-export-author-info nil)
(setq org-export-creator-info nil)
(setq org-export-time-stamp-file nil)
(setq org-export-with-timestamps nil)

当我进行构建时,最终会得到类似于这样的东西:

result

同时,我期待着类似于这样的东西:

expected

这是emacs org模式已知的问题/限制吗?我有办法增加包含深度吗?
谢谢!
1个回答

3
我怀疑你所使用的导出功能是较旧版本的org-mode。在org-mode的第8版中,导出功能已经重写。我已经快速查看了如何在我的emacs安装的org版本中使其工作。所以对于我来说:

M-x org-version

会输出:

Org-mode 版本 8.2.10 (release_8.2.10 @ c:/dev/emacs/share/emacs/24.5/lisp/org/)

这是随我的emacs 24.5一起提供的。鉴于您创建的相同文件,我将org-html-so.el更改为:
(require 'org)
(require 'ox) 
(require 'ox-html)
(setq org-export-author-info nil)
(setq org-export-creator-info nil)
(setq org-export-time-stamp-file nil)
(setq org-export-with-timestamps nil)

然后emacs的调用方式是:

emacs.exe parent.org --batch -q --no-site-file --load org-html-so.el -f org-html-export-to-html --kill

包含深度

这个版本的include似乎没有限制深度,但它会记住之前已经包含的文件区域,以确保包含不会递归。

升级

如果你使用的是早期版本的emacs:你可以升级emacs版本,或者将org安装一个更新的版本到现有的emacs中。

要通过软件包管理器安装更新的版本或从github本地安装,请参见Org手册中的安装页面。

值得升级,至少因为较新的版本更活跃,您可以利用最新的功能。例如,您可能会喜欢支持html主题的org-html-themes


非常感谢您的回答。我会检查一下我的版本是否有该导出功能,否则我会升级并再次尝试。确认答案正确后,我会给予奖励。 - Oday Mansour
我认为你至少需要版本8才能获得基于ox.el的导出器版本。请注意,org-html-export-to-htmlorg-html-export-as-html之间存在区别:前者按照您的要求将文件导出到文件中,而后者则导出到没有关联文件的缓冲区中。 - andygavin

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接