Things I've discovered that I consider useful.

2007-04-06

CHM files don't suck after all

A lot of ebooks seem to get packaged in CHM format, a proprietary Microsoft format originally used for help files. It turns out they can be extracted pretty nicely.

sudo apt-get install libchm-bin
extract_chmLib foo.chm outputdir

2007-04-04

Using vim to convert syntax highlighted source to XHTML with CSS

I've known for a long time that vim has the handy feature of the :TOhtml command to take the current syntax highlighted source file with one's chosen colour scheme and create a new buffer with the same source rendered with colours in HTML. However, I only checked today that it can now output XHTML 1.0 with CSS, so instead of lots of annoying <font color="#ff40ff"> stuff, you get <span class="PreProc"> and can therefore control the style of each syntax element in one place. To enable, place this in .vimrc:

let use_xhtml = 1
let html_use_css = 1

You will need a relatively recent vim, and it doesn't quite produce perfect XHTML 1.0 Strict in that it omits a container for the <pre> tags.

Sample output:

I've known for a long time that <a href="http://www.vim.org">vim</a> has the handy feature of the <span class="inlinecode">:TOhtml</span> command to take the current syntax highlighted source file with one's chosen colour scheme and create a new buffer with the same source rendered with colours in HTML.

Which was created with:

I've known for a long time that <span class="Identifier">&lt;</span><span class="Statement">a</span><span class="Identifier"> </span><span class="Type">href</span><span class="Identifier">=</span><span class="Constant">&quot;<a href="http://www.vim.org">http://www.vim.org</a>&quot;</span><span class="Identifier">&gt;</span><span class="Underlined">vim</span><span class="Identifier">&lt;/</span><span class="Statement">a</span><span class="Identifier">&gt;</span> has the handy feature of the <span class="Identifier">&lt;</span><span class="Statement">span</span><span class="Identifier"> </span><span class="Type">class</span><span class="Identifier">=</span><span class="Constant">&quot;inlinecode&quot;</span><span class="Identifier">&gt;</span>:TOhtml<span class="Identifier">&lt;/</span><span class="Statement">span</span><span class="Identifier">&gt;</span> command to take the current syntax highlighted source file with one's chosen colour scheme and create a new buffer with the same source rendered with colours in HTML.

Multitail

From the homepage, multitail is tail on steroids. It creates multiple windows in the terminal using ncurses, and it can watch files, stdin or any external program. It does a lot more, including arbitrary highlighting of the text it tails. Outstanding.

Screen can now split vertically

GNU Screen is, in my opinion, the most useful *nix utility of all time. Recent versions (4.1 and the current CVS release) can now do vertical split with Command Key + |

Valid XHTML 1.0 Strict Valid CSS!