Hpricot + Ultraviolet

Warning: This hasn’t been touched since 2007 and is abandonware!

A small one-function library to highlight the syntax of code embedded in HTML documents or fragments using Hpricot and Ultraviolet.

Example

HpricotPlusUltraviolet.color_syntax('<code lang="ruby">@test</code>')
# => '<code class="ultraviolet"><span class="Variable"><span class="Variable">@</span>test</span></code>'

In other words, color_syntax processes the <code> element with the ruby syntax highlighter and turns @test into @test.

Also, all code snippets on this site use this mechanism.

Download

hpricot_plus_ultraviolet.rb

“The name sucks!”

Henrik complained that the library name is too techy… Yes, but I picked the current name to emphasize that it’s just a pat of glue between Hpricot and Ultraviolet.

More…

Hpricot Text GSub is a part of Hpricot Goodies.