Source code evaluation header, in order that the Org file to be rendered it in Github

45 Views Asked by At

Having a file with #+RESULTS: won't have the results actually rendered, when seen in Github.

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

The source code in this section actually have the following text in the file, but is not redered:

#+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

I expected the #+RESULTS section to be rendered in Github automatically.

Can I change the src code header, with some option, that will make the evaluation result "renderable" in Github?

1

There are 1 best solutions below

0
Tom Regner On

The only way to get halfway there I found relativly quickly would be to post process the result and wrap it in a quote block

This block adds backslashes to the lines of the result, line-breaks would be ignored in githubs quote-rendering otherwise

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

The interesting part here are the :post and the :wrap header

#+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

I am not active on github, but I guess this crutch can take you over until github updates to a newer org-ruby version (if that ever happens).