strapyourself.in and flouri.sh
Ultraviolet syntax highlighting in Mephisto
Being a mac rails user, I love textmate. Naturally, I went crazy when I found out that Ultraviolet is a syntax highlighting gem for ruby that reads textmate theme and textmate syntax files to create xhtml highlighted code. After using this in my tictactoe project, I integrated it into mephisto. Because I wanted to use the filter:code tag that's normally used by coderay, I did this by deleting all the files in the filtered_column_code_macro/lib plugin except code_macro.rb, which I replaced as follows
require 'uv' class CodeMacro < FilteredColumn::Macros::Base def self.filter(attributes, inner_text = '', text = '') lang = attributes.delete(:lang) || "ruby_on_rails" theme = attributes.delete(:theme) || "cobalt" begin Uv.parse( inner_text, "xhtml", lang, false, theme) rescue RAILS_DEFAULT_LOGGER.warn "UltraViolet Error: #{$!.message}" RAILS_DEFAULT_LOGGER.debug $!.backtrace.join("\n") end end end
Then I copied in the xhtml CSS files for Ultraviolet xhtml rendering (as shown in the UV instructions) into my stylesheets directory. I included the themes I liked into my layout.liquid as follows:
<link rel="stylesheet" href="/stylesheets/uv/blackboard.css" type="text/css" media="screen" /> <link rel="stylesheet" href="/stylesheets/uv/dawn.css" type="text/css" media="screen" /> <link rel="stylesheet" href="/stylesheets/uv/cobalt.css" type="text/css" media="screen" />
Finally, you have to remove a reference to 'include "coderay"' in environment.rb. For each code block in your blog, you can change the theme (there's about 12 included themes):
import java.net; public class Bob extends BobParent implements Bobliness { private final int SOMETHING=0; public static void main(String[] args) { System.out.println("Hello world!" + 5.5) } }
UV comes with syntax highlightinb for 158 languages:
actionscript, active4d_html, active4d_ini, active4d_library, active4d, ada, antlr, apache, applescript, asp, asp_vb.net, bibtex, blog_html, blog_markdown, blog_textile, blog_text, build, bulletin_board, cake, camlp4, cm, coldfusion, context_free, css_experimental, css, cs, csv, c, c++, diff, dokuwiki, dot, doxygen, d, dylan, eiffel, erlang, fortran, f-script, fxscript, greasemonkey, gri, groovy, gtdalt, gtd, haml, haskell, html-asp, html_django, html_for_asp.net, html_mason, html_rails, html, html_tcl, icalendar, inform, ini, installer_distribution_script, io, javaproperties, javascript_+_prototype_bracketed, javascript_+_prototype, javascript, java, jquery_javascript, json, languagedefinition, latex_beamer, latex_log, latex_memoir, latex, lexflex, lighttpd, lilypond, lisp, literate_haskell, logo, logtalk, lua, macports_portfile, mail, makefile, man, markdown, mediawiki, mel, mips, mod_perl, modula-3, moinmoin, mootools, movable_type, m, multimarkdown, objective-c, objective-c++, ocamllex, ocaml, ocamlyacc, opengl, pascal, perl, php, plain_text, pmwiki, postscript, processing, prolog, property_list, python_django, python, qmake_project, qt_c++, quake3_config, ragel, r_console, rd_r_documentation, regexp, regular_expressions_oniguruma, regular_expressions_python, release_notes, remind, restructuredtext, rez, r, ruby_experimental, ruby_on_rails, ruby, s5, scheme, scilab, setext, shell-unix-generic, slate, smarty, sql_rails, sql, ssh-config, standard_ml, strings_file, subversion_commit_message, sweave, swig, tcl, template_toolkit, tex_math, tex, textile, tsv, twiki, txt2tags, vectorscript, xhtml_1.0, xml_strict, xml, xsl, yaml, yui_javascript
Sorry, comments are closed for this article.