【问题标题】:How can I use other heading styles like twiki ---+ or mediawiki == h2 == in org-mode?如何在 org-mode 中使用其他标题样式,例如 twiki ---+ 或 mediawiki == h2 ==?
【发布时间】:2012-07-27 23:58:02
【问题描述】:

我真的很想使用 org-mode。

但是,我想使用 org-mode 来理解已经使用不同标题语法编写的结构化文档,

例如使用 twiki 的 ---+

---+ H1 

Top level

---++ H2

Nested

---+ H1 #2

Second top level

或类似媒体维基

= H1 = 

Top level

== H2 ==

Nested

= H1 #2 =

Second top level

我想拥有 org-mode 折叠等的所有优点,只需使用这些不同的标题样式。


实际上,更糟糕的是:

例如,我希望 twiki 或 mediawaiki 标题优先于 org 模式星号标题。但我想同时使用两者。

= H1 =

Top level

* this is a list
** nested
* list
** nested

== H2 ==

Nested

= H1 #2 =

Second top level

--+ 到目前为止我所尝试的

我已经能够使用大纲模式来处理 twiki, 例如通过

---+ Emacs stuff
# try (defvar twiki-outline-regexp "---+\\++ \\|\\(\\(?:   \\)+\\)[0-9*] ")
Local Variables: ***
outline-regexp: "^---\\++" ***
org-outline-regexp: "^---\\++" ***
End: ***

但是,org-outline-regexp 并没有达到我希望的效果。

emacs 的大纲模式的 out-level 函数看起来几乎和我想要的一样。

(defvar outline-level 'outline-level
  "*Function of no args to compute a header's nesting level in an outline.
It can assume point is at the beginning of a header line and that the match
data reflects the `outline-regexp'.")

即而不是正则表达式,一个通用函数。

但我还没有设法让它与 org-mode 一起工作。看起来 org-mode 并没有真正使用它,或者,更确切地说,还有其他东西。

;; In Org buffers, the value of `outline-regexp' is that of
;; `org-outline-regexp'.  The only function still directly relying on
;; `outline-regexp' is `org-overview' so that `org-cycle' can do its
;; job when `orgstruct-mode' is active.
(defvar org-outline-regexp "\\*+ "
  "Regexp to match Org headlines.")
(defconst org-outline-regexp-bol "^\\*+ "
  "Regexp to match Org headlines.
This is similar to `org-outline-regexp' but additionally makes
sure that we are at the beginning of the line.")

(defconst org-heading-regexp "^\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$"
  "Matches an headline, putting stars and text into groups.
Stars are put in group 1 and the trimmed body in group 2.")

失败了,好吧,我想从 org-mode 获得的主要内容是链接,在这里提出另一个问题 How can I "linkify" a non-org-mode buffer in emacs

【问题讨论】:

  • 您最好的选择是将丑陋的格式转换为漂亮的格式。但也许您可以充分利用org-heading-regexp 使其在其他模式之一下工作?
  • 哪种格式丑,哪种格式好看? ;-} // 在链接到的问题中,我有相当通用的链接工作。

标签: emacs org-mode


【解决方案1】:

我的挫败感只是 org-mode 对于新大纲部分的构成规则与 outline-mode 不同。它需要在星号后有一个空格,因此它不适用于我的大量笔记集,这些笔记放弃了这些空格。

我通过删除未充分记录的org-outline-regexp 变量中的尾随空格解决了这个问题,该变量用于初始化缓冲区局部变量outline-regexp,这似乎对我有用。例如。 (set-variable 'org-outline-regexp "\\*+")

至于您的实际问题,我的猜测是其他正则表达式和代码必须更改以处理完全不同的内容,例如 twiki 或 mediawiki 标题。

【讨论】:

  • 感谢有关尾随空格的提示。 // 是的,org-mode 使用的正则表达式系统很笨拙,而且,似乎有几个地方可以“计算星数”来确定缩进级别。而在 mediawiki 中我需要计算 ===s,而在 twiki 中我需要计算 +++s。 // IE。它需要是一个给出标题级别的函数,而不是一个正则表达式。
  • 顺便说一句,我目前正在使用我的链接代码来格式化链接,使用大纲模式,它可以很好地处理 twiki,但是调用一些 org-mode goto-link 函数而不实际打开在组织模式。 // 笨重,但足够好。
猜你喜欢
  • 1970-01-01
  • 2013-08-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
相关资源
最近更新 更多