Permalink
Browse files

Add and fix tests for hr abutting a list

  • Loading branch information...
1 parent 7295860 commit 72db29ceb189dc6e119aab06e30d8375fc85b8a7 @ashb ashb committed Jan 22, 2010
Showing with 26 additions and 2 deletions.
  1. +11 −2 lib/markdown.js
  2. +9 −0 test/features/lists/hr_abutting.json
  3. +6 −0 test/features/lists/hr_abutting.text
View
@@ -489,7 +489,8 @@ Markdown.dialects.Gruber = {
var stack = [], // Stack of lists for nesting.
list = make_list( m ),
last_li,
- loose = false;
+ loose = false,
+ ret = [ stack[0].list ];
// Loop to search over block looking for inner block elements and loose lists
loose_search:
@@ -583,6 +584,14 @@ Markdown.dialects.Gruber = {
if ( next_block.match(is_list_re) || next_block.match( /^ / ) ) {
block = next.shift();
+ // Check for an HR following a list: features/lists/hr_abutting
+ var hr = this.dialect.block.horizRule( block, next );
+
+ if (hr) {
+ ret.push.apply(ret, hr);
+ break;
+ }
+
// Make sure all listitems up the stack are paragraphs
stack.forEach( paragraphify , this );
@@ -592,7 +601,7 @@ Markdown.dialects.Gruber = {
break;
} // loose_search
- return [ stack[0].list ];
+ return ret;
}
})(),
@@ -0,0 +1,9 @@
+["html",
+ ["ul",
+ [ "li", "foo" ],
+ [ "li", "bar" ],
+ ],
+ ["hr"],
+ ["p", "after"]
+]
+
@@ -0,0 +1,6 @@
+* foo
+* bar
+
+ * * *
+after
+

0 comments on commit 72db29c

Please sign in to comment.