lib/kramdown/parser/kramdown/list.rb in kramdown-0.8.0 vs lib/kramdown/parser/kramdown/list.rb in kramdown-0.9.0
- old
+ new
@@ -30,11 +30,11 @@
class Kramdown
# 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 =~ /^\s*\n/
+ if content =~ /^\s*(#{IAL_SPAN_START})?\s*\n/
indentation = 4
else
while content =~ /^ *\t/
temp = content.scan(/^ */).first.length + indentation
content.sub!(/^( *)(\t+)/) {$1 + " "*(4 - (temp % 4)) + " "*($2.length - 1)*4}
@@ -73,11 +73,11 @@
elsif @src.scan(list_start_re)
item = Element.new(:li)
item.value, indentation, content_re, indent_re = parse_first_list_line(@src[1].length, @src[2])
list.children << item
- item.value.sub!(/^#{IAL_SPAN_START}/) do |match|
+ item.value.sub!(/^#{IAL_SPAN_START}\s*/) do |match|
parse_attribute_list($~[1], item.options[:ial] ||= {})
''
end
list_start_re = (type == :ul ? /^( {0,#{[3, indentation - 1].min}}[+*-])([\t| ].*?\n)/ :
@@ -117,14 +117,14 @@
it.value = nil
next if it.children.size == 0
if it.children.first.type == :p && (it.children.length < 2 || it.children[1].type != :blank ||
(it == list.children.last && it.children.length == 2 && !eob_found)) &&
- (list.children.last != it || list.children.size == 1 || list.children[0..-2].any? {|cit| cit.children.first.type != :p})
- text = it.children.shift.children.first
- text.value += "\n" if !it.children.empty? && it.children[0].type != :blank
- it.children.unshift(text)
+ (list.children.last != it || list.children.size == 1 ||
+ list.children[0..-2].any? {|cit| cit.children.first.type != :p || cit.children.first.options[:transparent]})
+ it.children.first.children.first.value += "\n" if it.children.size > 1 && it.children[1].type != :blank
+ it.children.first.options[:transparent] = true
end
if it.children.last.type == :blank
last = it.children.pop
else
@@ -171,10 +171,15 @@
item = Element.new(:dd)
item.options[:first_as_para] = first_as_para
item.value, indentation, content_re, indent_re = parse_first_list_line(@src[1].length, @src[2])
deflist.children << item
+ item.value.sub!(/^#{IAL_SPAN_START}\s*/) do |match|
+ parse_attribute_list($~[1], item.options[:ial] ||= {})
+ ''
+ end
+
def_start_re = /^( {0,#{[3, indentation - 1].min}}:)([\t| ].*?\n)/
first_as_para = false
elsif result = @src.scan(content_re)
result.sub!(/^(\t+)/) { " "*4*($1 ? $1.length : 0) }
result.sub!(indent_re, '')
@@ -200,12 +205,11 @@
last = it.children.pop
else
last = nil
end
if it.children.first.type == :p && !it.options.delete(:first_as_para)
- text = it.children.shift.children.first
- text.value += "\n" if !it.children.empty?
- it.children.unshift(text)
+ it.children.first.children.first.value += "\n" if it.children.size > 1
+ it.children.first.options[:transparent] = true
end
end
if @tree.children.length >= 1 && @tree.children.last.type == :dl
@tree.children[-1].children += deflist.children