As I mentioned in a comment, section Exporting code blocks describes permissible values of the :exports
option: code
(contents of the block), results
(results of its evaluation), both
(code and results) and none
(nothing is exported).
By default Org tries to interpret results of evaluating a source code block (and turn it into a table, for example). If such an interpretation fails, evaluation results are formatted as monospace text and look as if wrapped in <pre> ... </pre>
when exported to HTML.
Luckily we can tell Org to put evaluation results in a special kind of a block using :results
(see Results of evaluation and :results
). If you want to be able to use a source code block to generate a part of an HTML page, use :results value html
or :results output html
and Org will wrap results in a #+BEGIN_HTML ... #+END_HTML
block.
Here's a minimal example (#+OPTIONS
are irrelevant, I added them to make it easier to inspect exported HTML code using C-c C-e h H
):
#+OPTIONS: html-postamble:nil
#+OPTIONS: html-preamble:nil html-scripts:nil html-style:nil
#+OPTIONS: html5-fancy:nil tex:t
Some text.
#+BEGIN_SRC python :exports results :results value html
return "<hr> Generated HTML code. <hr>"
#+END_SRC
More text.