3

As the title says, I'm trying to make the source blocks, when export, to be scrollable (e.g. vertical) so that the long source blocks don't mess up with the rest of content and the html/pdf files look neat in this way.
After doing some research, I've found a html way to do it, a little bit ugly, by adding html export block before the coding block

#+begin_export html
<pre style="height: 300px; overflow: scroll;">
#+end_export
#+begin_src python
very very long long source code
#+end_src

It exports as like enter image description here Which looks like nested blocks, but what I want is to make the source block can scroll itself.

1 Answer 1

2

If you want to set it for all your Org files you can use the following lines in your init file:

(setq org-html-head "<style type=\"text/css\">
    /*<![CDATA[*/
      pre.src {
        height: 100px;
        overflow: auto;
      }
    /*]]>*/
   </style>")

For a single Org file set the corresponding export property within the Org file instead:

#+HTML_HEAD: <style type="text/css">/*<![CDATA[*/ pre.src { height: 100px; overflow: auto; } /*]]>*/ </style>

Thereby, adapt the height attribute to your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.