Extract checks for acceptable custom markdown processors to method.

We should probably write more about what it does and how it works in a TomDoc block above.
@envygeeks, want to give that a shot?
This commit is contained in:
Parker Moore 2013-12-26 00:02:56 -05:00
parent a206dc1a8f
commit 60b43104ee
1 changed files with 6 additions and 1 deletions

View File

@ -16,7 +16,7 @@ module Jekyll
when 'maruku' then MarukuParser.new(@config)
else
# So they can't try some tricky bullshit or go down the ancestor chain, I hope.
if @config['markdown'] !~ /[^A-Za-z0-9]/ && self.class.constants.include?(@config['markdown'].to_sym)
if allowed_custom_class?(@config['markdown'])
self.class.const_get(@config['markdown']).new(@config)
else
Jekyll.logger.error "Invalid Markdown Processor:", "#{@config['markdown']}"
@ -40,6 +40,11 @@ module Jekyll
setup
@parser.convert(content)
end
private
def allowed_custom_class?(parser_name)
parser_name !~ /[^A-Za-z0-9]/ && self.class.constants.include?(parser_name.to_sym)
end
end
end
end