lib/kramdown/parser/kramdown/list.rb in kramdown-2.4.0 vs lib/kramdown/parser/kramdown/list.rb in kramdown-2.5.0
- old
+ new
@@ -28,14 +28,14 @@
end
# Used for parsing the first line of a list item or a definition, i.e. the line with list item
# marker or the definition marker.
def parse_first_list_line(indentation, content)
- if content =~ self.class::LIST_ITEM_IAL_CHECK
+ if content.match?(self.class::LIST_ITEM_IAL_CHECK)
indentation = 4
else
- while content =~ /^ *\t/
+ while content.match?(/^ *\t/)
temp = content.scan(/^ */).first.length + indentation
content.sub!(/^( *)(\t+)/) { $1 << " " * (4 - (temp % 4) + ($2.length - 1) * 4) }
end
indentation += content[/^ */].length
end
@@ -165,11 +165,11 @@
para = @tree.children.pop
first_as_para = true
end
# take location from preceding para which is the first definition term
deflist.options[:location] = para.options[:location]
- para.children.first.value.split(/\n/).each do |term|
+ para.children.first.value.split("\n").each do |term|
el = Element.new(:dt, nil, nil, location: @src.current_line_number)
term.sub!(self.class::LIST_ITEM_IAL) do
parse_attribute_list($1, el.options[:ial] ||= {})
''
end
@@ -254,29 +254,30 @@
private
# precomputed patterns for indentations 1..4 and fallback expression
# to compute pattern when indentation is outside the 1..4 range.
def fetch_pattern(type, indentation)
- if type == :ul
+ case type
+ when :ul
case indentation
- when 1 then %r/^( {0}[+*-])(#{PATTERN_TAIL})/o
- when 2 then %r/^( {0,1}[+*-])(#{PATTERN_TAIL})/o
- when 3 then %r/^( {0,2}[+*-])(#{PATTERN_TAIL})/o
- else %r/^( {0,3}[+*-])(#{PATTERN_TAIL})/o
+ when 1 then /^( {0}[+*-])(#{PATTERN_TAIL})/o
+ when 2 then /^( {0,1}[+*-])(#{PATTERN_TAIL})/o
+ when 3 then /^( {0,2}[+*-])(#{PATTERN_TAIL})/o
+ else /^( {0,3}[+*-])(#{PATTERN_TAIL})/o
end
- elsif type == :ol
+ when :ol
case indentation
- when 1 then %r/^( {0}\d+\.)(#{PATTERN_TAIL})/o
- when 2 then %r/^( {0,1}\d+\.)(#{PATTERN_TAIL})/o
- when 3 then %r/^( {0,2}\d+\.)(#{PATTERN_TAIL})/o
- else %r/^( {0,3}\d+\.)(#{PATTERN_TAIL})/o
+ when 1 then /^( {0}\d+\.)(#{PATTERN_TAIL})/o
+ when 2 then /^( {0,1}\d+\.)(#{PATTERN_TAIL})/o
+ when 3 then /^( {0,2}\d+\.)(#{PATTERN_TAIL})/o
+ else /^( {0,3}\d+\.)(#{PATTERN_TAIL})/o
end
- elsif type == :dl
+ when :dl
case indentation
- when 1 then %r/^( {0}:)(#{PATTERN_TAIL})/o
- when 2 then %r/^( {0,1}:)(#{PATTERN_TAIL})/o
- when 3 then %r/^( {0,2}:)(#{PATTERN_TAIL})/o
- else %r/^( {0,3}:)(#{PATTERN_TAIL})/o
+ when 1 then /^( {0}:)(#{PATTERN_TAIL})/o
+ when 2 then /^( {0,1}:)(#{PATTERN_TAIL})/o
+ when 3 then /^( {0,2}:)(#{PATTERN_TAIL})/o
+ else /^( {0,3}:)(#{PATTERN_TAIL})/o
end
end
end
end