【问题标题】:Is it possible to have nested "includes" in emacs org mode?是否可以在 emacs org 模式下嵌套“包含”?
【发布时间】:2015-09-01 14:45:27
【问题描述】:

我正在编写文档,而我的一份文档开始变得非常庞大。我决定将其分解为多个部分并将它们全部包含在一个主要部分中,但我意识到这样做时我无法正确导出 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)

当我构建时,我最终会得到这样的东西:

与此同时,我期待这样的事情:

这是 emacs org 模式的已知问题/限制吗? 有没有办法增加包含深度?

谢谢!

【问题讨论】:

    标签: emacs org-mode


    【解决方案1】:

    我怀疑您用于导出的功能是org-mode 的旧版本。在 org-mode 版本 8 中,导出功能被重写。我已经快速了解了如何使用我的 emacs 安装的 org 版本来实现它。所以对我来说:

    M-x org-version

    给出:

    组织模式版本 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

    包括深度

    此版本的包含似乎没有限制深度,但它会记住以前包含的文件区域以确保包含不是递归的。

    升级中

    如果您有早期版本的 emacs:您可以升级您的 emacs 版本,或者您可以在现有安装中安装更新版本的 org。

    通过包管理器安装较新版本或从 github 本地安装。请参阅Org Manual 中的安装页面。

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

    【讨论】:

    • 非常感谢您的回答。我将检查我的版本中是否有该导出功能,否则我将升级并重试。确认正确后,我会奖励答案。
    • 我认为您至少应该拥有版本 8 才能获得基于 ox.el 的导出器版本。请注意org-html-export-to-htmlorg-html-export-as-html 之间的区别:前者根据您的要求导出到文件,后者导出到没有关联文件的缓冲区。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-26
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多