Rubocop: lib/jekyll/converters/markdown.rb
This commit is contained in:
parent
746e360c63
commit
38eb326b7f
|
@ -9,23 +9,33 @@ module Jekyll
|
||||||
return if @setup ||= false
|
return if @setup ||= false
|
||||||
unless (@parser = get_processor)
|
unless (@parser = get_processor)
|
||||||
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
|
Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
|
||||||
Jekyll.logger.info "", "Custom processors are not loaded in safe mode" if @config["safe"]
|
if @config["safe"]
|
||||||
Jekyll.logger.error "", "Available processors are: #{valid_processors.join(", ")}"
|
Jekyll.logger.info "", "Custom processors are not loaded in safe mode"
|
||||||
|
end
|
||||||
|
Jekyll.logger.error(
|
||||||
|
"",
|
||||||
|
"Available processors are: #{valid_processors.join(", ")}"
|
||||||
|
)
|
||||||
raise Errors::FatalException, "Bailing out; invalid Markdown processor."
|
raise Errors::FatalException, "Bailing out; invalid Markdown processor."
|
||||||
end
|
end
|
||||||
|
|
||||||
@setup = true
|
@setup = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Rubocop does not allow reader methods to have names starting with `get_`
|
||||||
|
# To ensure compatibility, this check has been disabled on this method
|
||||||
|
#
|
||||||
|
# rubocop:disable Style/AccessorMethodName
|
||||||
def get_processor
|
def get_processor
|
||||||
case @config["markdown"].downcase
|
case @config["markdown"].downcase
|
||||||
when "redcarpet" then return RedcarpetParser.new(@config)
|
when "redcarpet" then return RedcarpetParser.new(@config)
|
||||||
when "kramdown" then return KramdownParser.new(@config)
|
when "kramdown" then return KramdownParser.new(@config)
|
||||||
when "rdiscount" then return RDiscountParser.new(@config)
|
when "rdiscount" then return RDiscountParser.new(@config)
|
||||||
else
|
else
|
||||||
get_custom_processor
|
custom_processor
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# rubocop:enable Style/AccessorMethodName
|
||||||
|
|
||||||
# Public: Provides you with a list of processors, the ones we
|
# Public: Provides you with a list of processors, the ones we
|
||||||
# support internally and the ones that you have provided to us (if you
|
# support internally and the ones that you have provided to us (if you
|
||||||
|
@ -41,13 +51,13 @@ module Jekyll
|
||||||
|
|
||||||
def third_party_processors
|
def third_party_processors
|
||||||
self.class.constants - \
|
self.class.constants - \
|
||||||
%w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
|
%w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
|
||||||
&:to_sym
|
&:to_sym
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def extname_list
|
def extname_list
|
||||||
@extname_list ||= @config['markdown_ext'].split(',').map do |e|
|
@extname_list ||= @config["markdown_ext"].split(",").map do |e|
|
||||||
".#{e.downcase}"
|
".#{e.downcase}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -66,7 +76,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def get_custom_processor
|
def custom_processor
|
||||||
converter_name = @config["markdown"]
|
converter_name = @config["markdown"]
|
||||||
if custom_class_allowed?(converter_name)
|
if custom_class_allowed?(converter_name)
|
||||||
self.class.const_get(converter_name).new(@config)
|
self.class.const_get(converter_name).new(@config)
|
||||||
|
|
Loading…
Reference in New Issue