Switch to pygments.rb
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|||||||
|
|
||||||
s.add_dependency('grit', "~> 2.4.1")
|
s.add_dependency('grit', "~> 2.4.1")
|
||||||
s.add_dependency('github-markup', [">= 0.4.0", "< 1.0.0"])
|
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('sinatra', "~> 1.0")
|
||||||
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
|
s.add_dependency('mustache', [">= 0.11.2", "< 1.0.0"])
|
||||||
s.add_dependency('sanitize', "~> 2.0.0")
|
s.add_dependency('sanitize', "~> 2.0.0")
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ require File.expand_path('../gollum/wiki', __FILE__)
|
|||||||
require File.expand_path('../gollum/page', __FILE__)
|
require File.expand_path('../gollum/page', __FILE__)
|
||||||
require File.expand_path('../gollum/file', __FILE__)
|
require File.expand_path('../gollum/file', __FILE__)
|
||||||
require File.expand_path('../gollum/markup', __FILE__)
|
require File.expand_path('../gollum/markup', __FILE__)
|
||||||
require File.expand_path('../gollum/albino', __FILE__)
|
|
||||||
require File.expand_path('../gollum/sanitization', __FILE__)
|
require File.expand_path('../gollum/sanitization', __FILE__)
|
||||||
|
|
||||||
module Gollum
|
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 'digest/sha1'
|
||||||
require 'cgi'
|
require 'cgi'
|
||||||
|
require 'pygments'
|
||||||
|
|
||||||
module Gollum
|
module Gollum
|
||||||
|
|
||||||
@@ -398,9 +399,8 @@ module Gollum
|
|||||||
end
|
end
|
||||||
|
|
||||||
highlighted = begin
|
highlighted = begin
|
||||||
blocks.size.zero? ? [] : Gollum::Albino.colorize(blocks)
|
blocks.map { |lang, code| Pygments.highlight(code, :lexer => lang) }
|
||||||
rescue ::Albino::ShellArgumentError, ::Albino::TimeoutExceeded,
|
rescue ::RubyPython::PythonError
|
||||||
::Albino::MaximumOutputExceeded
|
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -467,8 +467,9 @@ module Gollum
|
|||||||
|
|
||||||
doc.search('pre').each do |node|
|
doc.search('pre').each do |node|
|
||||||
next unless lang = node['lang']
|
next unless lang = node['lang']
|
||||||
|
next unless lexer = Pygments::Lexer[lang]
|
||||||
text = node.inner_text
|
text = node.inner_text
|
||||||
html = Gollum::Albino.colorize(text, lang)
|
html = lexer.highlight(text)
|
||||||
node.replace(html)
|
node.replace(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user