简体   繁体   English

如何在组织模式下进行内联注释?

[英]How to make inline comments in Org-mode?

In Org-mode there are several ways to make comments . 在Org-mode中有几种方法可以发表评论 But I do not know of any way to make inline comments. 但我不知道如何制作内联评论。 According to the manual 根据手册

regions surrounded by '#+BEGIN_COMMENT' ... '#+END_COMMENT' will not be exported. 由'#+ BEGIN_COMMENT'包围的区域...'#+ END_COMMENT'将不会被导出。

But this is only true if the said region starts a line. 但只有当所述区域开始一条线时才会出现这种情况。

In the following 在下面的

#+TITLE: Test

text #+BEGIN_COMMENT comment 1 #+END_COMMENT text

text
#+BEGIN_COMMENT comment 2 #+END_COMMENT text

only comment 2 is treated as a comment. 只有评论2被视为评论。 It exports (eg Ce A ) as 它出口(例如Ce A )为

text #+BEGIN_COMMENT comment 1 #+END_COMMENT text text#+ BEGIN_COMMENT comment 1#+ END_COMMENT text

text 文本

Also, org-toggle-comment does not work for making inline comments by using it on regions and comment-region does not even create a comment. 此外, org-toggle-comment不适用于通过在区域上使用它来制作内联注释,而comment-region甚至不会创建注释。

So, how can I make inline comments in Org-mode? 那么,我如何在Org模式下进行内联注释?

Jonathan Leech-Pepin's comment on your question on \\printbibliography gave me an idea. Jonathan Leech-Pepin对你关于\\printbibliography的问题的评论给了我一个想法。 You can use a macro for inline comments. 您可以使用宏来进行内联注释。 Note that you need trailing space after the comment definition. 请注意,在注释定义之后需要尾随空格。

#+macro: comment  

...

{{{comment(here is a comment)}}}

EDIT: Since this is supposed to be a macro odd input may screw things up. 编辑:因为这应该是一个宏奇怪的输入可能搞砸了。 I'm a little surprised that 我有点意外

{{{comment(here is a)}} comment)}}}

works for me, although 虽然对我有用

{{{comment(here is a comment) more}}}

does not. 才不是。 I would assume that anything other than fairly simple text would be fairly fragile if they decide to change the way they parse macros in the future. 我认为如果他们决定改变将来解析宏的方式,那么除了相当简单的文本之外的任何东西都会相当脆弱。

Another way will be to use the export snippets (defined in Org Syntax (draft) , search for "Export Snippets"), like so: 另一种方法是使用导出片段(在Org语法(草稿)中定义,搜索“导出片段”),如下所示:

This is the @@comment:This is an inline comment@@ original text.

I used the word comment where the export backend should be just for clarity, you can use any other word (besides the backend you're exporting to). 我使用了单词comment ,其中导出后端应该只是为了清楚,你可以使用任何其他单词(除了你要导出的后端)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM