diff --git a/lib/linguist/lexer.rb b/lib/linguist/lexer.rb
index f38d730b..e7bdeb96 100644
--- a/lib/linguist/lexer.rb
+++ b/lib/linguist/lexer.rb
@@ -1,4 +1,4 @@
-require 'albino'
+require 'pygments'
require 'yaml'
module Linguist
@@ -55,16 +55,6 @@ module Linguist
end
end
- # Internal: Test if system has Pygments
- #
- # Only used in tests to disable tests that require Pygments.
- #
- # Returns true if `pygmentize` in is PATH otherwise false.
- def self.has_pygments?
- `which #{Albino.bin}`
- $?.success?
- end
-
# Public: Get all Lexers
#
# Returns an Array of Lexers
@@ -141,7 +131,7 @@ module Linguist
#
# Returns html String
def colorize(text)
- Albino.new(text, self).colorize(:O => 'stripnl=false')
+ Pygments.highlight(text, :lexer => aliases.first, :options => {:stripnl => false})
end
# Public: Highlight syntax of text without the outer highlight div
diff --git a/linguist.gemspec b/linguist.gemspec
index 703d811b..8a4d88df 100644
--- a/linguist.gemspec
+++ b/linguist.gemspec
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
s.files = Dir['lib/**/*']
s.executables << 'linguist'
- s.add_dependency 'albino', '1.3.2'
s.add_dependency 'escape_utils', '0.2.3'
s.add_dependency 'mime-types', '1.16'
+ s.add_dependency 'pygments.rb'
s.add_development_dependency 'rake'
end
diff --git a/test/test_blob.rb b/test/test_blob.rb
index 9de355cc..174a9495 100644
--- a/test/test_blob.rb
+++ b/test/test_blob.rb
@@ -380,21 +380,19 @@ class TestBlob < Test::Unit::TestCase
assert_equal nil, blob("foo.rb").shebang_language
end
- if Lexer.has_pygments?
- def test_colorize
- assert_equal <<-HTML, blob("foo.rb").colorize
+ def test_colorize
+ assert_equal <<-HTML, blob("foo.rb").colorize
- HTML
- end
+ HTML
+ end
- def test_colorize_without_wrapper
- assert_equal <<-HTML, blob("foo.rb").colorize_without_wrapper
+ def test_colorize_without_wrapper
+ assert_equal <<-HTML, blob("foo.rb").colorize_without_wrapper
module Foo
end
- HTML
- end
+ HTML
end
end
diff --git a/test/test_language.rb b/test/test_language.rb
index da328577..871a70ba 100644
--- a/test/test_language.rb
+++ b/test/test_language.rb
@@ -296,43 +296,41 @@ class TestLanguage < Test::Unit::TestCase
end
- if Lexer.has_pygments?
- def test_colorize
- assert_equal <<-HTML, Language['Text'].colorize("Hello")
+ def test_colorize
+ assert_equal <<-HTML, Language['Text'].colorize("Hello")
- HTML
+ HTML
- assert_equal <<-HTML, Language['Ruby'].colorize("def foo\n 'foo'\nend\n")
+ assert_equal <<-HTML, Language['Ruby'].colorize("def foo\n 'foo'\nend\n")
- HTML
- end
+ HTML
+ end
- def test_colorize_without_wrapper
- assert_equal <<-HTML, Language['Text'].colorize_without_wrapper("Hello")
+ def test_colorize_without_wrapper
+ assert_equal <<-HTML, Language['Text'].colorize_without_wrapper("Hello")
Hello
- HTML
+ HTML
- assert_equal <<-HTML, Language['Ruby'].colorize_without_wrapper("def foo\n 'foo'\nend\n")
+ assert_equal <<-HTML, Language['Ruby'].colorize_without_wrapper("def foo\n 'foo'\nend\n")
def foo
'foo'
end
- HTML
- end
+ HTML
+ end
- def test_colorize_doesnt_strip_newlines
- assert_equal <<-HTML, Language['Ruby'].colorize_without_wrapper("\n\n# Foo\ndef 'foo'\nend\n")
+ def test_colorize_doesnt_strip_newlines
+ assert_equal <<-HTML, Language['Ruby'].colorize_without_wrapper("\n\n# Foo\ndef 'foo'\nend\n")
# Foo
def 'foo'
end
- HTML
- end
+ HTML
end
end
diff --git a/test/test_lexer.rb b/test/test_lexer.rb
index dc10254d..44da63d2 100644
--- a/test/test_lexer.rb
+++ b/test/test_lexer.rb
@@ -61,33 +61,31 @@ class TestLexer < Test::Unit::TestCase
assert !Lexer['Ruby'].eql?(Lexer.new('Ruby'))
end
- if Lexer.has_pygments?
- def test_colorize
- assert_equal <<-HTML, Lexer['Text only'].colorize("Hello")
+ def test_colorize
+ assert_equal <<-HTML, Lexer['Text only'].colorize("Hello")
- HTML
+ HTML
- assert_equal <<-HTML, Lexer['Ruby'].colorize("def foo\n 'foo'\nend\n")
+ assert_equal <<-HTML, Lexer['Ruby'].colorize("def foo\n 'foo'\nend\n")
- HTML
- end
+ HTML
+ end
- def test_colorize_without_wrapper
- assert_equal <<-HTML, Lexer['Text only'].colorize_without_wrapper("Hello")
+ def test_colorize_without_wrapper
+ assert_equal <<-HTML, Lexer['Text only'].colorize_without_wrapper("Hello")
Hello
- HTML
+ HTML
- assert_equal <<-HTML, Lexer['Ruby'].colorize_without_wrapper("def foo\n 'foo'\nend\n")
+ assert_equal <<-HTML, Lexer['Ruby'].colorize_without_wrapper("def foo\n 'foo'\nend\n")
def foo
'foo'
end
- HTML
- end
+ HTML
end
end