htmlize.el by HrvojeNiksic? is a package for exporting the contents of an Emacs buffer to HTML while respecting display properties such as colors, fonts, underlining, invisibility, etc. Get it from,
The conversion is quite sophisticated, it understands non-ascii characters, looks up colours in the X11 RGB database, and can generate either
css or old style
Its typical usage is to export fontified (syntax-highlighted) source code as HTML, but it can be used for any Emacs buffer, such as Gnus or
org-mode buffers. The resulting HTML can be used by other tools, published on the web, printing, etc.
The following packages use or extend
See also HtmlFontify which does similar things (and hopefully will be included in Emacs soon). However, HtmlFontify appears not to support converting a region which is really practical for publishing small snippets on blogs.
[new] Converting a region is supported in hfyview.el (which uses htmlfontify.el).
[new] You can use this package to render code snippets with syntax highlighting when exporting Org-mode files to HTML. http://orgmode.org/, see manual “Literal Examples”, 6.26 d, Chapter 12, p. 102, footnote1. – StefanVollmar
[new] See also htmlize.sh by Volkan YAZICI which is a small shell script wrapped around htmlize.el with some syntax highligting enhancements for particular emacs modes. Moreover, htmlize.sh has an extensible syntax recognition enhancement module that you can introduce new functionalities relatively easily; e.g., it provides CLHS and MOP symbol linking capabities for lisp-mode. (See README file for details.)
htmlize.el has some conflicts with
rainbow-delimiters-mode, functions such as
htmlize-buffer will report an error:
htmlize-make-face-map: Wrong type argument: listp, "rainbow-delimiters-depth-1-face", so I do a small hack to overcome this by using the elisp’s
Here’s the code:
(defadvice htmlize-buffer-1 (around ome-htmlize-buffer-1 disable) (rainbow-delimiters-mode -1) ad-do-it (rainbow-delimiters-mode t)) (defun ome-htmlize-setup () (if (el-get-read-package-status 'rainbow-delimiters) (progn (ad-enable-advice 'htmlize-buffer-1 'around 'ome-htmlize-buffer-1) (ad-activate 'htmlize-buffer-1))))