Code highlighting in wordpress

To get code syntax highlighting for wordpress blogs, there are 2+1 options:

0. use an offline colorizer to generate html with the colors, then paste it in the “text” editor tab. This can be a bit cumbersome depending on your setup.

1. install one of the many syntax highlighting plugins

Since this is not possible for free blogs on wordpress.com, a cheap, bare-bones highlighting can be achieved by

2. wrapping your code in the Visual Editor like this:

[code language=”python”]
print(“hello”)
[/code]

Which produces:

print("hello")

The instructions and list of supported languages are here.

Unfortunately many languages (e.g. elisp) are not supported. For elisp, the closest I get is using clojure as the reference language.
It doesn’t look good, but better than nothing:

;; autosave sessions
(setq desktop-dirname "~/"
 desktop-base-file-name ".emacs.desktop"
 desktop-base-lock-name "lock"
 desktop-path (list desktop-dirname)
 desktop-save t
 desktop-files-not-to-save "^$" ;reload tramp paths
 desktop-load-locked-desktop nil)
(desktop-save-mode 1)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s