Only compile the Converter#matches regexp when asked for

This commit is contained in:
Parker Moore 2014-10-12 14:31:49 -07:00
parent fbe98df488
commit 4942b2947b
2 changed files with 14 additions and 12 deletions

View File

@ -8,7 +8,6 @@ module Jekyll
def setup
return if @setup
@regexp = build_extname_regexp
@parser =
case @config['markdown'].downcase
when 'redcarpet' then RedcarpetParser.new(@config)
@ -28,11 +27,6 @@ module Jekyll
@setup = true
end
def build_extname_regexp
rgx = '^\.(' + @config['markdown_ext'].gsub(',','|') +')$'
Regexp.new(rgx, Regexp::IGNORECASE)
end
def valid_processors
%w[
maruku
@ -52,8 +46,15 @@ module Jekyll
].map(&:to_sym)
end
def extname_matches_regexp
@extname_matches_regexp ||= Regexp.new(
'(' + @config['markdown_ext'].gsub(',','|') +')$',
Regexp::IGNORECASE
)
end
def matches(ext)
ext =~ @regexp
ext =~ extname_matches_regexp
end
def output_ext(ext)

View File

@ -9,7 +9,6 @@ module Jekyll
def setup
return if @setup
require 'redcloth'
@regexp = build_extname_regexp
@setup = true
rescue LoadError
STDERR.puts 'You are missing a library required for Textile. Please run:'
@ -17,13 +16,15 @@ module Jekyll
raise Errors::FatalException.new("Missing dependency: RedCloth")
end
def build_extname_regexp
rgx = '(' + @config['textile_ext'].gsub(',','|') +')$'
Regexp.new(rgx, Regexp::IGNORECASE)
def extname_matches_regexp
@extname_matches_regexp ||= Regexp.new(
'(' + @config['textile_ext'].gsub(',','|') +')$',
Regexp::IGNORECASE
)
end
def matches(ext)
ext =~ @regexp
ext =~ extname_matches_regexp
end
def output_ext(ext)