Switch to pygments.rb
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'albino/multi'
|
||||
|
||||
class Gollum::Albino < Albino::Multi
|
||||
self.bin = ::Albino::Multi.bin
|
||||
end
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user