Switch to pygments.rb

This commit is contained in:
Joshua Peek
2011-09-26 16:45:21 -05:00
parent e8df272729
commit 35da594bfc
4 changed files with 6 additions and 11 deletions
-1
View File
@@ -16,7 +16,6 @@ require File.expand_path('../gollum/wiki', __FILE__)
require File.expand_path('../gollum/page', __FILE__)
require File.expand_path('../gollum/file', __FILE__)
require File.expand_path('../gollum/markup', __FILE__)
require File.expand_path('../gollum/albino', __FILE__)
require File.expand_path('../gollum/sanitization', __FILE__)
module Gollum
-5
View File
@@ -1,5 +0,0 @@
require 'albino/multi'
class Gollum::Albino < Albino::Multi
self.bin = ::Albino::Multi.bin
end
+5 -4
View File
@@ -1,5 +1,6 @@
require 'digest/sha1'
require 'cgi'
require 'pygments'
module Gollum
@@ -398,9 +399,8 @@ module Gollum
end
highlighted = begin
blocks.size.zero? ? [] : Gollum::Albino.colorize(blocks)
rescue ::Albino::ShellArgumentError, ::Albino::TimeoutExceeded,
::Albino::MaximumOutputExceeded
blocks.map { |lang, code| Pygments.highlight(code, :lexer => lang) }
rescue ::RubyPython::PythonError
[]
end
@@ -467,8 +467,9 @@ module Gollum
doc.search('pre').each do |node|
next unless lang = node['lang']
next unless lexer = Pygments::Lexer[lang]
text = node.inner_text
html = Gollum::Albino.colorize(text, lang)
html = lexer.highlight(text)
node.replace(html)
end