我目前正在尝试在 Org 模式下设置 Raku 脚本。但是,Raku 主要模式没有定义注释语法。有没有办法告诉 Org Mode 注释标题参数使用什么注释语法作为标题参数?
例如,这个代码块
* This should be a comment
#+BEGIN_SRC raku :comments org
lorem ipsum
#+END_SRC
Run Code Online (Sandbox Code Playgroud)
编译时提示我没有定义的注释语法。作为参考,在 Raku Major 模式(官方模式)中,评论会像这样正确突出显示
# This is a comment
constant Str this = "is not.";
Run Code Online (Sandbox Code Playgroud)
从我通过阅读 Org Mode 文档可以看出,:commentsheader 参数仅在同时使用:tangleheader 参数时才有意义。它涉及如何将上下文注释添加到混乱的代码中。
https://orgmode.org/manual/Extracting-Source-Code.html#Extracting-Source-Code
以下代码块显示了三种可用的注释插入方法:
* Tangled Header Comment
#+begin_src raku :results output :comments org :tangle yes :shebang #!/usr/bin/env raku
say 'hi';
#+end_src
#+RESULTS:
* Link Comments
#+begin_src raku :results output :comments link :tangle yes :shebang #!/usr/bin/env raku
say 'hello';
#+end_src
* Both Link and Org Comments
#+begin_src raku :results output :comments both :tangle yes :shebang #!/usr/bin/env raku
say 'hello';
#+end_src
Run Code Online (Sandbox Code Playgroud)
缠结后(使用Ctrl-c Ctrl-v t),生成的 .raku 文件如下所示:
#!/usr/bin/env raku
# Tangled Header Comment
say 'hi';
# [[file:~/git/play.org::*Link Comments][Link Comments:1]]
say 'hello';
# Link Comments:1 ends here
# Both Link and Org Comments
# [[file:~/git/play.org::*Both Link and Org Comments][Both Link and Org Comments:1]]
say 'hello';
# Both Link and Org Comments:1 ends here
Run Code Online (Sandbox Code Playgroud)
我认为这种行为与我从 Melpa 安装的raku-mode没有任何关系。它确实需要 Org Babel 的 Raku 后端。我正在使用 ob-raku.el,我想我是从这里得到的:
https://github.com/tmtvl/ob-raku