Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org-mode - no syntax highlighting in exported HTML page

I've been trying to get the syntax highlighting to work when exporting org-mode formatted file to HTML, but none of what I've done so far has worked. I followed the Babel configuration guide but the code block on the generated HTML page still looks plain. I have also set (setq org-src-fontify-natively t). What am I missing?

like image 876
Psycho Punch Avatar asked Jun 06 '14 12:06

Psycho Punch


1 Answers

Code block syntax highlighting in Org-mode's HTML export depends on the htmlize library, which Org-mode's documentation says is included but may actually need to be installed separately:

If the example is source code from a programming language, or any other text that can be marked up by font-lock in Emacs, you can ask for the example to look like the fontified Emacs buffer¹¹⁹. This is done with the ‘src’ block, where you also need to specify the name of the major mode that should be used to fontify the example¹²⁰, see Easy Templates for shortcuts to easily insert code blocks.

#+BEGIN_SRC emacs-lisp
  (defun org-xor (a b)
     "Exclusive or."
     (if a (not b) b))
#+END_SRC

...

¹¹⁹This works automatically for the HTML back-end (it requires version 1.34 of the htmlize.el package, which is distributed with Org). Fontified code chunks in LaTeX can be achieved using either the listings or the minted package. Refer to org-latex-listings documentation for details.

htmlize.el is available via MELPA.

like image 126
Chris Avatar answered Sep 20 '22 12:09

Chris