Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
it can pass specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyr committed Sep 8, 2013
1 parent b9a8460 commit e36ba2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions lib/minidown/elements/list_group_element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ class ListGroupElement < Element
def parse
nodes << self
while line = unparsed_lines.shift
#handle nested ul
if line =~ self.class.const_get(:NestRegexp)
#handle nested list
if (ul = line =~ /\A(\s+)[*\-+]\s+(.+)/) || line =~ /\A(\s+)\d+\.\s+(.+)/
list_class = ul ? UnorderListElement : OrderListElement
li, str = $1.size, $2
if li > @indent_level
self.class.new(doc, str, li).parse
list_class.new(doc, str, li).parse
@lists.last.contents << nodes.pop
next
elsif li == @indent_level
self.class.new(doc, str, li).parse
list_class.new(doc, str, li).parse
child = nodes.pop
if LineElement === nodes.last
@lists.last.p_tag_content = child.lists.first.p_tag_content = true
Expand All @@ -32,10 +33,6 @@ def parse

doc.parse_line line
child = nodes.pop
# if /\A\s+(.+)/ =~ line
# @lists.last.contents << child
# next
# end
case child
when self.class
if LineElement === nodes.last
Expand Down Expand Up @@ -71,8 +68,13 @@ def parse
# unparsed_lines.unshift line
# break
else
@put_back << child if child
break
# if /\A\s+(.+)/ =~ line
# @lists.last.contents << child
# next
# else
@put_back << child if child
break
# end
end
@blank = (LineElement === child)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/li_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@
1. ol
2. ol
3. ol'
Minidown.parse(str).to_html.should == '<ul><li><p>ul1</p><ol><li>ol</li><li>ol</li><li>ol</li></ol></li><li><p>ul2</p></li><li><p>ul3</p><ol><li> ol</li><li> ol</li><li> ol</li><li> ol</li><li> ol</li></ol></li><li><p>ul4</p></li><li><p>ul5</p><ol><li>ol</li><li>ol</li><li>ol</li></ol></li></ul>'
Minidown.parse(str).to_html.should == '<ul><li><p>ul1<br><ol><li>ol</li><li>ol</li><li>ol</li></ol></p></li><li><p>ul2</p></li><li><p>ul3<br><ol><li>ol</li><li>ol</li><li>ol</li><li>ol</li><li>ol</li></ol></p></li><li><p>ul4</p></li><li>ul5
<ol><li>ol</li><li>ol</li><li>ol</li></ol></li></ul>'
end
end
end
Expand Down

0 comments on commit e36ba2d

Please sign in to comment.