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
|
def setup
|
||||||
return if @setup
|
return if @setup
|
||||||
|
@regexp = build_extname_regexp
|
||||||
@parser =
|
@parser =
|
||||||
case @config['markdown'].downcase
|
case @config['markdown'].downcase
|
||||||
when 'redcarpet' then RedcarpetParser.new(@config)
|
when 'redcarpet' then RedcarpetParser.new(@config)
|
||||||
|
@ -27,6 +28,11 @@ module Jekyll
|
||||||
@setup = true
|
@setup = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_extname_regexp
|
||||||
|
rgx = '^\.(' + @config['markdown_ext'].gsub(',','|') +')$'
|
||||||
|
Regexp.new(rgx, Regexp::IGNORECASE)
|
||||||
|
end
|
||||||
|
|
||||||
def valid_processors
|
def valid_processors
|
||||||
%w[
|
%w[
|
||||||
maruku
|
maruku
|
||||||
|
@ -47,8 +53,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches(ext)
|
def matches(ext)
|
||||||
rgx = '^\.(' + @config['markdown_ext'].gsub(',','|') +')$'
|
ext =~ @regexp
|
||||||
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_ext(ext)
|
def output_ext(ext)
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Jekyll
|
||||||
def setup
|
def setup
|
||||||
return if @setup
|
return if @setup
|
||||||
require 'redcloth'
|
require 'redcloth'
|
||||||
|
@regexp = build_extname_regexp
|
||||||
@setup = true
|
@setup = true
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
STDERR.puts 'You are missing a library required for Textile. Please run:'
|
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")
|
raise Errors::FatalException.new("Missing dependency: RedCloth")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def build_extname_regexp
|
||||||
|
rgx = '(' + @config['textile_ext'].gsub(',','|') +')$'
|
||||||
|
Regexp.new(rgx, Regexp::IGNORECASE)
|
||||||
|
end
|
||||||
|
|
||||||
def matches(ext)
|
def matches(ext)
|
||||||
rgx = '(' + @config['textile_ext'].gsub(',','|') +')'
|
ext =~ @regexp
|
||||||
ext =~ Regexp.new(rgx, Regexp::IGNORECASE)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def output_ext(ext)
|
def output_ext(ext)
|
||||||
|
|
Loading…
Reference in New Issue