源代码评估标头,以便 Org 文件在 Github 中呈现

问题描述 投票:0回答:1

拥有带有 #+RESULTS: 的文件:在 Github 中看到时,不会实际呈现结果。

例如: https://github.com/BuddhiLW/pos-go-expert/blob/main/Notes.org#structs-and-interfaces

本节的源代码文件中实际上有以下文本,但未重新渲染:

#+RESULTS:
: struFoo: {Foo 256 true} fundacao.StruFoo
: struFooBar: {[Foo Bar] [256 512] [true false] {Foo 256 true}} fundacao.StruFooBar
: struBarfoo: {[Foo Bar] [256 512] [true false] {Foo 256 true}} fundacao.StruBarfoo
:
: Struct instances of StruFooBar and StruBarfoo will look identical, but aren't.
: Composition vs Standard type (implies direct access vs not direct access):
: struFooBar.S (Foo) == struBarfoo.SFoo.S (Foo)? true

我希望 #+RESULTS 部分会自动在 Github 中呈现。

我可以通过一些选项更改 src 代码标头,从而使评估结果在 Github 中“可渲染”吗?

github org-mode
1个回答
0
投票

我发现相对较快地到达一半的唯一方法是对结果进行后处理并将其包装在引号块中

此块向结果行添加反斜杠,否则在引用/渲染中将忽略换行/换行符

#+name: add_newline
#+begin_src emacs-lisp :exports none :var lines="" :results raw
(string-join (mapcar (lambda (line) (concat line "\\\\")) (split-string lines "\n")) "\n")
#+end_src

这里有趣的部分是

:post
:wrap
标题

#+begin_src shell :results output replace raw :post add_newline(*this*) :wrap quote
echo "Test line 1"
echo "Test line 2"
#+end_src

#+RESULTS:
#+begin_quote
Test line 1\\
Test line 2\\
\\
#+end_quote

我在 github 上并不活跃,但我想这个拐杖可以接管你,直到 github 更新到更新的 org-ruby 版本(如果发生这种情况)。

© www.soinside.com 2019 - 2024. All rights reserved.