Refactoring, less warnings.
This commit is contained in:
parent
e3941ba8e5
commit
b6e582e7b0
1 changed files with 7 additions and 7 deletions
|
@ -7,15 +7,15 @@ require "albino"
|
||||||
module Ace
|
module Ace
|
||||||
class PygmentsFilter < Filter
|
class PygmentsFilter < Filter
|
||||||
def call(item, content)
|
def call(item, content)
|
||||||
puts 'PygmentsFilter ************************'
|
|
||||||
doc = Nokogiri::HTML(content)
|
doc = Nokogiri::HTML(content)
|
||||||
doc.css('pre').each do |pre|
|
doc.css("pre[lang]").each do |pre|
|
||||||
puts "\nWARNING: '#{item.original_path}' - element <pre> not contains attribute 'lang'\n" if pre['lang'].nil?
|
unless pre['lang'].nil? || pre['lang'].empty?
|
||||||
puts "\nWARNING: '#{item.original_path}' - attribute 'lang' not contains any value\n" if !pre['lang'].nil? && pre['lang'].empty?
|
# Set $VERBOSE to nil if you don't want to see this message.
|
||||||
puts "*** Syntax highlight using '#{pre['lang']}' lexer" unless pre['lang'].nil? || pre['lang'].empty?
|
warn "~ Syntax highlight in '#{item.original_path}' using '#{pre['lang']}' lexer."
|
||||||
pre.replace Albino.colorize(pre.content, pre['lang']) unless pre['lang'].nil? || pre['lang'].empty?
|
pre.replace Albino.colorize(pre.content, pre['lang'])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
doc
|
doc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue