Best way to export code block and results in different styles
aseltmann opened this issue · comments
I keep an elaborate org file as a Lab notebook and am playing around with export options. ox-twbs
is really doing an awesome job on this by the way - thank you! :)
Since I want to document my code blocks together with their results, and I have quite a lot of them executed in a sequence, I would like to style the #+SRC_...
blocks differently from the #+RESULTS:
blocks (the actual output in question is either in the format of org tables or #+BEGIN_EXAMPLE
blocks). A simple Indentation of the #+RESULTS
block relative to the corresponding #+SRC
block would already be enough. Alternatives would be a different colour etc.
There are some related questions on SO, but they mostly deal with latex export.
I already checked org's #+OPTIONS
for an easy fix and could not find it. I suppose some custom code has to be written?
An update here: I made part of what I wanted work with CSS support as described in the manual
E.g. this line at the beginning of the document colours all #+BEGIN_EXAMPLE blocks in yellow and makes them half as big (note that #+HTML_HEAD:
without EXTRA will corrupt the twbs styling).
#+HTML_HEAD_EXTRA: <style type="text/css">.example {width:50%; background-color: #eff000;}</style>
Also, one problem which was not directly clear to me: how do I access the styling of different types of #+BEGIN_SRC
blocks. The manual only mentions pre.src
. Some digging in some old email channels pointed me towards the solution (here an example for two colours, one for emacs-lisp blocks and one for shell blocks - trivial, but not documented):
#+HTML_HEAD_EXTRA: <style type="text/css">pre.src-emacs-lisp {background-color: #efd8f6;}</style>
#+HTML_HEAD_EXTRA: <style type="text/css">pre.src-sh {background-color: #d3f3be;}</style>
There still the following questions I am trying to solve:
- if the
#+RESULTS
are not in form of a#+BEGIN_EXAMPLE
block, but e.g. in form of a org table, then the styling doesn't work. And of course,#+BEGIN_EXAMPLE
blocks, which are NOT results of code execution, are coloured as well - which wouldn't be the case in my ideal world.
So if anyone can point me towards a direction on what the best conduct would be, I would be greatful. Of course, this might not necessarily have something to do with ox-twbs, so feel free to close the issue.
Sidenote:
I also tried manually changing the styling using #+ATTR_HTML:
(see below), but this didn't work for #+BEGIN_...
blocks for me (not for normal html export, neither for twbs export). Strangely, it works totally fine with e.g. org-tables.
#+ATTR_HTML: :style background-color:#eff0fe;
#+BEGIN_EXAMPLE
hello world!
#+END_EXAMPLE