Cache the extname regexp in Converters::Markdown and Textile
This commit is contained in:
parent
681d71ac04
commit
44c9f81921
|
@ -8,6 +8,7 @@ module Jekyll
|
|||
|
||||
def setup
|
||||
return if @setup
|
||||
@regexp = build_extname_regexp
|
||||
@parser =
|
||||
case @config['markdown'].downcase
|
||||
when 'redcarpet' then RedcarpetParser.new(@config)
|
||||
|
@ -27,6 +28,11 @@ 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
|
||||
|
@ -47,8 +53,7 @@ module Jekyll
|
|||
end
|
||||
|
||||
def matches(ext)
|
||||
rgx = '^\.(' + @config['markdown_ext'].gsub(',','|') +')$'
|
||||
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
||||
ext =~ @regexp
|
||||
end
|
||||
|
||||
def output_ext(ext)
|
||||
|
|
|
@ -9,6 +9,7 @@ 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:'
|
||||
|
@ -16,9 +17,13 @@ module Jekyll
|
|||
raise Errors::FatalException.new("Missing dependency: RedCloth")
|
||||
end
|
||||
|
||||
def build_extname_regexp
|
||||
rgx = '(' + @config['textile_ext'].gsub(',','|') +')$'
|
||||
Regexp.new(rgx, Regexp::IGNORECASE)
|
||||
end
|
||||
|
||||
def matches(ext)
|
||||
rgx = '(' + @config['textile_ext'].gsub(',','|') +')'
|
||||
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
||||
ext =~ @regexp
|
||||
end
|
||||
|
||||
def output_ext(ext)
|
||||
|
|
Loading…
Reference in New Issue