org-mode中的秘密结构?

6

我想知道org-mode是否有任何功能可以让我操作保密结构,即:当我编辑时可以看到的结构,在导出时却被视为不存在。这主要是在导出为ascii时很重要。

例如:

我希望在.org文件中写入以下内容:

* Normal heading
** Secret heading 1
Some text 1
** Secret heading 2
Some text 2
** Secret heading 3
Some text 3

要导出到这个:
Normal heading
--------------
Some text 1
Some text 2
Some text 3

什么可以使标题保密?

可以是标签、属性或其他任何东西,但保密标题应该是可折叠的。

编辑:

发现了这个解决方案(来自这里)(我正在使用org-mode 7.9.3 f。它不起作用。带有:ignoreheading:标记的标题仍然显示:

;; backend aware export preprocess hook
(defun sa-org-export-preprocess-hook ()
  "My backend aware export preprocess hook."
  (save-excursion
    (when (eq org-export-current-backend 'latex)
      ;; ignoreheading tag for bibliographies and appendices
      (let* ((tag "ignoreheading"))
        (org-map-entries (lambda ()
                           (delete-region (point-at-bol) (point-at-eol)))
                         (concat ":" tag ":"))))))

(add-hook 'org-export-preprocess-hook 'sa-org-export-preprocess-hook)
5个回答

5
你想要解决的问题在这里得到了回答,以下是答案(再次重复):
  1. Add the following to your .emacs file:

    (require 'ox-extra)
    (ox-extras-activate '(ignore-headlines))
    
  2. Use the ignore tag on headlines you'd like to have ignored (while not ignoring their content)


1
这似乎可行,而且比被接受的解决方案更简单。 - incandescentman
require 步骤无法工作,给我一个文件丢失的错误。我正在使用 orgmode 9.1.9,但我无法在任何地方找到这个文件。我也在 Mac 上。有什么建议吗? - Guilherme Salomé
@GuilhermeSalomé,请查看链接答案中有关添加org-mode ELPA存储库的信息。 - Mark

5
您可以使用EXCLUDE_TAGS属性并标记某些部分,然后使用org-export-exclude-tags导出。例如:
#+EXCLUDE_TAGS: noexport

* Public Section

* Secret Section :noexport:

Documentation here.


1
EXCLUDE_TAGS会排除标题和标题内容。我只想要排除标题本身。 - MajorBriggs
@MajorBriggs 啊,抱歉,是我的错。 - Biffen

1

我升级到了org-mode 8.2.5h,这样就可以正常工作了:

(defun sa-ignore-headline (contents backend info)
  "Ignore headlines with tag `ignoreheading'."
  (when (and (org-export-derived-backend-p backend 'latex 'html 'ascii)
          (string-match "\\`.*ignoreheading.*\n"
                (downcase contents)))
    (replace-match "" nil nil contents)))

(add-to-list 'org-export-filter-headline-functions 'sa-ignore-headline)

但仅当您没有选项:#+OPTIONS: tags:nil 时。我想这是显而易见的,即在调用依赖于某个标签的过滤器之前,不应该过滤掉标签 - 但这让我困扰了很长时间。
注意:在导出为ASCII时,标题下划线将保留而没有标题,因此您也需要这个设置:
(setq org-ascii-underline (quote ((ascii) (latin1) (utf-8))))

...完全删除标题。


1
在尝试解决同样的问题时,我找到了 this 论坛帖子,描述了如何使用 notignore 标签扩展 ox-extra.el。除非明确标记为 notignore,否则此方法不会导出任何标题。标题内容将正常导出。
对于我的大多数文档,notignore 方法比“忽略”方法更有用,因为大多数标题都是“秘密结构”,不打算导出。
目前我已经在我的 init.el 文件中激活了 notignore-headlines。有人能建议一种按文档基础激活的方法吗?

1

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