Org mode syntax highlight for VHDL code
Contents
One problem I came across when I try to use Org
mode as the markup language for my
Pelian generated static blog is the syntax
highlight for source code blocks. Org mode has the ability to highlight
syntax of languages supported in its
Babel
functionality, be it in the Org mode buffer or the language major mode
buffer, or exported PDF document or HTML file. However, things became a
bit different for Org mode when it was used in Pelican through the
org_reader
plugin.
Markdown, one of the two major supported markup languages of Pelcian,
uses CodeHilite
extension
which in turn uses Pygments to fulfill the syntax
highlight for code blocks. The Pygments .css file can be easily found in
the static/css/
directory of any Pelican theme. Org mode can not take
this advantage easily. When an Org file is exported to a HTML file, the
export engine can choose either the current Emacs color theme or a
specified .css file for the color option of code segments in the
exported HTML file. The choices is depending on the value of
org-html-htmlize-output-type
and can be seen from this SE
thread.
Below is some examples for source code syntax highlight.
- Syntax highlighting for python code
|
|
- Elisp source code export with line numbers and reference
|
|
In line (sc) we remember the current position. Line (jump) jumps to point-min.
It is a shame that Org mode does not highlight syntax of hardware
description languages (HDL) such as VHDL and Verilog. I can not blame
Org mode for this one though. After all, what kind of execution should I
expect from Babel for those HDLs? Yet I found a dirty solution to use
syntax highlight from VHDL mode simply by defining a ob-vhdl.el
file
based on the ob-template.el
and requiring it in my Emacs’s
configuration file. The result can be seen in the following:
|
|
The original problems and potential solutions are listed below. Although I followed the above post to solve the puzzle rather than the two links, they might be useful in the future.
Syntax highlight is not working properly in the html files export from org files, due to this error message “Cannot fontify src block (htmlize.el >= 1.34 required)”. However even the ‘htmlize.el’ works, the syntax color will be awful as it does not take the advantage defined in the ‘.css’ file of this theme. Better check out this two solutions: http://ergoemacs.org/emacs/elisp_htmlize.html
http://cheukyin.github.io/python/2014-08/pygments-highlight-src-export-html.html
Author Fanpeng Kong
LastMod 2016-09-10