lib/webby/helpers/ultraviolet_helper.rb in TwP-webby-0.9.4 vs lib/webby/helpers/ultraviolet_helper.rb in TwP-webby-0.9.4.1

- old
+ new

@@ -1,10 +1,24 @@ # This code was provided by Guillaume Carbonneau -- http://radr.ca/ # Many thanks for his support of Webby! if try_require 'uv' +Loquacious.configuration_for(:webby) { + desc "Options for UltraViolet syntax highlighting." + uv { + desc 'The language to highlight (ruby, c, html, ...).' + lang 'ruby' + + desc 'Display line numbers (true, false).' + line_numbers false + + desc 'See the UltraViolet documentation for a list of available themes.' + theme 'mac_classic' + } +} + module Webby::Helpers module UltraVioletHelper # The +uv+ method applies syntax highlighting to source code embedded # in a webpage. The UltraViolet highlighting engine is used for the HTML @@ -37,16 +51,16 @@ text = capture_erb(&block) return if text.empty? defaults = ::Webby.site.uv - lang = opts.getopt(:lang, defaults[:lang]) - line_numbers = opts.getopt(:line_numbers, defaults[:line_numbers]) - theme = opts.getopt(:theme, defaults[:theme]) + lang = opts.getopt(:lang, defaults.lang) + line_numbers = opts.getopt(:line_numbers, defaults.line_numbers) + theme = opts.getopt(:theme, defaults.theme) - out = '<div class="UltraViolet">' + out = %Q{<div class="UltraViolet">\n} out << Uv.parse(text, "xhtml", lang, line_numbers, theme) - out << '</div>' + out << %Q{\n</div>} # put some guards around the output (specifically for textile) out = _guard(out) concat_erb(out, block.binding)