lib/linguist/blob_helper.rb in gitlab-linguist-2.9.6 vs lib/linguist/blob_helper.rb in gitlab-linguist-3.0.0
- old
+ new
@@ -2,11 +2,10 @@
require 'linguist/language'
require 'charlock_holmes'
require 'escape_utils'
require 'mime/types'
-require 'pygments'
require 'yaml'
module Linguist
# DEPRECATED Avoid mixing into Blob classes. Prefer functional interfaces
# like `Language.detect` over `Blob#language`. Functions are much easier to
@@ -187,24 +186,17 @@
size.to_i > MEGABYTE
end
# Public: Is the blob safe to colorize?
#
- # We use Pygments for syntax highlighting blobs. Pygments
- # can be too slow for very large blobs or for certain
- # corner-case blobs.
- #
# Return true or false
def safe_to_colorize?
!large? && text? && !high_ratio_of_long_lines?
end
# Internal: Does the blob have a ratio of long lines?
#
- # These types of files are usually going to make Pygments.rb
- # angry if we try to colorize them.
- #
# Return true or false
def high_ratio_of_long_lines?
return false if loc == 0
size / loc > 5000
end
@@ -296,10 +288,10 @@
# Internal: Get the lexer of the blob.
#
# Returns a Lexer.
def lexer
- language ? language.lexer : Pygments::Lexer.find_by_name('Text only')
+ language ? language.lexer : nil
end
# Public: Highlight syntax of blob
#
# options - A Hash of options (defaults to {})