Rubocop: Style/PerlBackrefs

- Avoid the use of Perl-style backrefs
This commit is contained in:
Pat Hawks 2016-01-04 12:01:23 -08:00
parent be3666fcf0
commit 086e85ca9e
No known key found for this signature in database
GPG Key ID: F1746FF5F18B3D1B
3 changed files with 5 additions and 5 deletions

View File

@ -47,7 +47,7 @@ module Jekyll
merged_file_read_opts(opts)) merged_file_read_opts(opts))
if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
self.content = $POSTMATCH self.content = $POSTMATCH
self.data = SafeYAML.load($1) self.data = SafeYAML.load(Regexp.last_match(1))
end end
rescue SyntaxError => e rescue SyntaxError => e
Jekyll.logger.warn "YAML Exception reading #{File.join(base, name)}: #{e.message}" Jekyll.logger.warn "YAML Exception reading #{File.join(base, name)}: #{e.message}"

View File

@ -263,7 +263,7 @@ module Jekyll
self.content = File.read(path, merged_file_read_opts(opts)) self.content = File.read(path, merged_file_read_opts(opts))
if content =~ YAML_FRONT_MATTER_REGEXP if content =~ YAML_FRONT_MATTER_REGEXP
self.content = $POSTMATCH self.content = $POSTMATCH
data_file = SafeYAML.load($1) data_file = SafeYAML.load(Regexp.last_match(1))
merge_data!(data_file) if data_file merge_data!(data_file) if data_file
end end

View File

@ -13,11 +13,11 @@ module Jekyll
def initialize(tag_name, markup, tokens) def initialize(tag_name, markup, tokens)
super super
if markup.strip =~ SYNTAX if markup.strip =~ SYNTAX
@lang = $1.downcase @lang = Regexp.last_match(1).downcase
@highlight_options = {} @highlight_options = {}
if defined?($2) && $2 != '' if defined?(Regexp.last_match(2)) && Regexp.last_match(2) != ''
# Split along 3 possible forms -- key="<quoted list>", key=value, or key # Split along 3 possible forms -- key="<quoted list>", key=value, or key
$2.scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt| Regexp.last_match(2).scan(/(?:\w="[^"]*"|\w=\w|\w)+/) do |opt|
key, value = opt.split('=') key, value = opt.split('=')
# If a quoted list, convert to array # If a quoted list, convert to array
if value && value.include?("\"") if value && value.include?("\"")