Move YAML Front Matter regexp into a constant.
This commit is contained in:
parent
d7e3d4df8f
commit
c7d92c4e6d
|
@ -7,6 +7,8 @@ module Jekyll
|
||||||
attr_reader :path, :site, :extname
|
attr_reader :path, :site, :extname
|
||||||
attr_accessor :content, :collection, :output
|
attr_accessor :content, :collection, :output
|
||||||
|
|
||||||
|
YAML_FRONT_MATTER_REGEXP = /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
|
||||||
|
|
||||||
# Create a new Document.
|
# Create a new Document.
|
||||||
#
|
#
|
||||||
# site - the Jekyll::Site instance to which this Document belongs
|
# site - the Jekyll::Site instance to which this Document belongs
|
||||||
|
@ -210,7 +212,7 @@ module Jekyll
|
||||||
@data = defaults
|
@data = defaults
|
||||||
end
|
end
|
||||||
@content = File.read(path, merged_file_read_opts(opts))
|
@content = File.read(path, merged_file_read_opts(opts))
|
||||||
if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
|
if content =~ YAML_FRONT_MATTER_REGEXP
|
||||||
@content = $POSTMATCH
|
@content = $POSTMATCH
|
||||||
data_file = SafeYAML.load($1)
|
data_file = SafeYAML.load($1)
|
||||||
unless data_file.nil?
|
unless data_file.nil?
|
||||||
|
|
Loading…
Reference in New Issue