So, right now, I am trying to build my website with Nikola static site generator. There is a nice orgmode plugin for it where I can write my content in orgmode and Nikola can then render it to html (exporting org into html). It works nice but there is one problem that I am facing right now where it cannot really render text within a drawer.

For example, this org source file: enter image description here

will only output: enter image description here

As you can see, the #+RESULTS: somehow completely makes the RESULTS drawer not been rendered at all. Even the TEST drawer came up weird (I put the TEST drawer just to show how a plain drawer is being rendered into html).

So, I want the RESULTS of the org-babel to be rendered into a box (so that it can somehow show that this is the output of the previous source file). Something like this: enter image description here

To do that, I investigated a bit on how the plugin works. Inside an init.el (file for the orgmode plugin), these are the functions that are related to this question.

;; Override the html export function to use pygments
(defun org-html-src-block (src-block contents info)
  "Transcode a SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item.  INFO is a plist holding
contextual information."
  (if (org-export-read-attribute :attr_html src-block :textarea)
      (org-html--textarea-block src-block)
    (let ((lang (org-element-property :language src-block))
          (code (org-element-property :value src-block))
          (code-html (org-html-format-code src-block info)))
      (if nikola-use-pygments
          (pygmentize (downcase lang) (org-html-decode-plain-text code))

;; Export function used by Nikola.
(defun nikola-html-export (infile outfile)
  "Export the body only of the input file and write it to
specified location."
  (with-current-buffer (find-file infile)
    (org-macro-replace-all nikola-macro-templates)
    (org-html-export-as-html nil nil t t)
    (write-file outfile nil)))

Then, within a python file, emacs is called with above init.el file (I believe this is when the org file is exported into html):

command = [
    'emacs', '--batch',
    '-l', join(dirname(abspath(__file__)), 'init.el'),
    '--eval', '(nikola-html-export "{0}" "{1}")'.format(
        abspath(source), abspath(dest))


So, I think, what I need to do is override the html export function related to the drawer. The problem is, I am still novice in emacs-lisp and I don't know what function should I override etc. I've tried to override org-html-drawer by doing something like this (just to check weather this function is being called or not during the export process)

(defun org-html-drawer (drawer contents info)
  (mkdir "/Users/hilman_dayo/Desktop/testdir/")

with no success at all (the testdir is not created in my Desktop which means this code is not being called during the export process).

My questions is, how can I make it so that the RESULTS drawer can be rendered into a box? Or at least, are there any keywords or things that I can google to dig deeper into this topic?

  • Only one question per question, please. Try to simplify/clarify what you're asking, if you can. Thx.
    – Drew
    Apr 8 '18 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.