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 -1
View File
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_dependency('grit', "~> 2.4.1")
s.add_dependency('github-markup', [">= 0.4.0", "< 1.0.0"])
s.add_dependency('albino', "~> 1.3.2")
s.add_dependency('pygments.rb', "~> 0.2.0")
s.add_dependency('sinatra', "~> 1.0")
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
s.add_dependency('sanitize', "~> 2.0.0")
-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