Skip to main content
2 of 2
fixed typos
Felix Hoffmann
  • 825
  • 1
  • 9
  • 17

How to get colored syntax highlighting of code blocks in asynchronous Org-mode exports to HTML?

Colored syntax highlighting of code blocks in .org files works well when executed through the main init.el file. However, when setting up Emacs and Org-mode to publish projects asynchronously, colored synatax highlighting is not present and only bold and underlined formatting is used.

I have the following minimal example:

init.el

(add-to-list 'load-path "~/.emacs.d/modes/org-mode-8.2.10/lisp") (add-to-list 'load-path "~/.emacs.d/modes/htmlize-1.6.1/") (require 'org) (require 'htmlize) (setq org-src-fontify-natively t) (setq org-publish-project-alist '( ("prj" :base-directory "~/tmp/org-export-test/" :base-extension "org" :publishing-directory "~/tmp/org-export-pub/" :recursive t :publishing-function org-html-publish-to-html ))) ;; async export options (setq org-export-async-debug t) (setq org-export-async-init-file (expand-file-name "export-async-init-file.el" (file-name-directory user-init-file))) (global-set-key (kbd "C-c C-8") (lambda () (interactive) (org-publish "prj"))) ;; (lambda () (interactive) (org-publish "prj" :ASYNC t))) 

export-async-init-file.el

(add-to-list 'load-path "~/.emacs.d/modes/org-mode-8.2.10/lisp") (add-to-list 'load-path "~/.emacs.d/modes/htmlize-1.6.1/") (require 'org) (require 'htmlize) (setq org-src-fontify-natively t) (setq org-export-async-debug t) 

Org file in the project folder

Hello world example code: #+BEGIN_SRC python def hello_world(name): print(name) #+END_SRC The above should be colored and highlighted. 

In the above settings I get

enter image description here

When switching on the asynchronous export however (switching the comment on the last two lines of init.el), I get

enter image description here

How can I set up the above configuration to get color highlighting in asynchronous export as well?

(Note: While I would like to make colored syntax highlighting work in Org-mode 8.2.10, I have also tried the above example with the latest Org-mode 9.0.5 and have found the same behavior.)

Felix Hoffmann
  • 825
  • 1
  • 9
  • 17