Native Human

Up

code highlighting

I want to blog on code and thus inserting code into the blog is important. I also want highlighting. There are multiple tools around which do this job, but I had a look at. source-highlight. I could run it from the command line but since I am an emacs user I can also run it from emacs. Thus, I have created a little elisp function which helps to convert code into highlighted code:

(defun highlight-region (&optional b e)
  (interactive "r")
  (shell-command-on-region b e "highlight --syntax lisp -f" (current-buffer) t)
  (comment-region (mark) (point)))
The snippet can tolerate a bit of improvement, but the highlighting does its job.

Created at: 2015-03-12

author:
mail:
comment:

Subscribe

List of posts