【问题标题】:Secret structure in org-mode?组织模式下的秘密结构?
【发布时间】:2014-04-07 08:00:38
【问题描述】:

我想知道 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

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

编辑:

找到这个解决方案(from here)(我使用的是 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)

【问题讨论】:

    标签: emacs elisp org-mode


    【解决方案1】:

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

    #+EXCLUDE_TAGS: noexport
    
    * Public Section
    
    * Secret Section :noexport:
    

    文档here

    【讨论】:

    • EXCLUDE_TAGS 不包括标题和该标题的内容。我有兴趣只排除标题。
    • @MajorBriggs 啊,对不起,我的错。
    【解决方案2】:

    你想要的地址是here——这是答案(重复):

    1. 将以下内容添加到您的 .emacs 文件中:

      (require 'ox-extra)
      (ox-extras-activate '(ignore-headlines))
      
    2. 在您希望忽略的标题上使用ignore 标签(同时不忽略其内容)

    【讨论】:

    • 这似乎可行,而且似乎比公认的解决方案更简单。
    • require 步骤不起作用,给我一个文件丢失错误。我使用的是 orgmode 9.1.9,我在任何地方都找不到这个文件。我也在Mac上。有什么建议吗?
    • @GuilhermeSalomé 请参阅链接答案中有关添加 org-mode ELPA 存储库的信息。
    【解决方案3】:

    我升级到 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))))
    

    ... 一起删除标题。

    【讨论】:

      【解决方案4】:

      linked question about the ignoreheading tag 中,我为 Emacs 24.1.1 中的 Org 8.2.10 发布了工作,simpler org-export-before-parsing-hook solution

      它基于org-map-entries 函数的文档,该函数还声明它自动将其包装在save-recursion 中。它比使用concat 更简单,因为org-map-entries 的第二个参数是议程样式的匹配字符串。

      【讨论】:

        【解决方案5】:

        在尝试解决相同问题时,我发现this 线程描述了如何使用notignore 标记扩展ox-extra.el。除非明确标记 notignore,否则此方法不会导出 任何 标题。标题内容正常导出。

        对于我的大多数文档,notignore 方法比“忽略”方法更有用,因为大多数标题都是“秘密结构”,不适合导出。

        目前我在我的 init.el 文件中激活了notignore-headlines。任何人都可以建议一种方法来在每个文档的基础上激活它。

        【讨论】:

          猜你喜欢
          • 2023-04-01
          • 2020-05-08
          • 2015-10-18
          • 2021-06-27
          • 1970-01-01
          • 1970-01-01
          • 2014-08-13
          • 2016-06-15
          相关资源
          最近更新 更多