Maj*_*ggs 5 emacs elisp org-mode
我想知道 org-mode 中是否有任何功能可以使我能够使用秘密结构进行操作,即:我在编辑时可以看到的结构,但在导出时被视为不存在. 它主要是在我导出为 ascii 时导入。
例子:
我想在 .org 文件中这样做:
* Normal heading
** Secret heading 1
Some text 1
** Secret heading 2
Some text 2
** Secret heading 3
Some text 3
Run Code Online (Sandbox Code Playgroud)
要导出到这个:
Normal heading
--------------
Some text 1
Some text 2
Some text 3
Run Code Online (Sandbox Code Playgroud)
使标题保密的东西可以是标签、属性或其他东西,但秘密标题应该是可折叠的。
编辑:
找到了这个解决方案(从这里)(我使用的是 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)
Run Code Online (Sandbox Code Playgroud)
您可以使用该EXCLUDE_TAGS属性并标记某些部分,然后使用org-export-exclude-tags. 例如:
#+EXCLUDE_TAGS: noexport
* Public Section
* Secret Section :noexport:
Run Code Online (Sandbox Code Playgroud)
文档在这里。
您想要的内容在这里解决- 这是答案(重复):
将以下内容添加到您的.emacs文件中:
(require 'ox-extra)
(ox-extras-activate '(ignore-headlines))
Run Code Online (Sandbox Code Playgroud)ignore在您想忽略的标题上使用标签(同时不忽略其内容)
我升级到 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)
Run Code Online (Sandbox Code Playgroud)
但前提是您没有选项: #+OPTIONS: tags:nil。我想在调用依赖于某个标签的过滤之前,标签不应该被过滤掉,这是很明显的——但这困扰了我很长一段时间。
注意:导出到 ascii 时,标题下划线将保留而没有标题,因此您也需要此设置:
(setq org-ascii-underline (quote ((ascii) (latin1) (utf-8))))
Run Code Online (Sandbox Code Playgroud)
...一起删除头条新闻。