require "uv" module Gorgyrella module Formatters class Ultraviolet # Will silently ignore unknown lexers, will raise an error if # unknown format called. def self.highlight(text, lexer, format, line_numbers = true, theme = 'amy') raise "#{lexer} syntax not available" unless Uv.syntaxes.include?(lexer) Uv.parse( text, format, lexer, line_numbers, theme) end def self.resolve_lexer(file, language = nil, sample_text = "") if language language else candidates = Uv.syntax_for_file(file) if candidates.size == 1 candidates.first[0] else nil end end end def self.resolve_format(format, parent_filename = nil, first_line = 0) format ||= 'xhtml' format = nil if format === 'text' format = 'xhtml' if format === 'html' format end end end end