From 53fb01bb2f044fc6877419ae2a2dbcf9a4ad13d7 Mon Sep 17 00:00:00 2001 From: Sean Lang Date: Thu, 26 Mar 2015 15:19:34 -0400 Subject: [PATCH] fix issue with lists resetting & add test case --- lib/index.coffee | 2 +- test/index.coffee | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/index.coffee b/lib/index.coffee index 173e1ea..5910602 100644 --- a/lib/index.coffee +++ b/lib/index.coffee @@ -81,10 +81,10 @@ preprocessAST = (ast) -> i = 0 out = [] orderedList = false - orderedListItemNumber = 0 while i < ast.length currentToken = ast[i] if currentToken.type is 'list_start' + orderedListItemNumber = 0 # this is actually all we need the list start token for orderedList = currentToken.ordered else if currentToken.type in nestingStartTokens diff --git a/test/index.coffee b/test/index.coffee index 9a7d7c2..2119e04 100644 --- a/test/index.coffee +++ b/test/index.coffee @@ -187,6 +187,26 @@ describe 'lists', -> - last item ''') + it 'should normalize ordered lists', -> + tidyMdSnippet(''' + # H1 header + 1. blah + 2. blah + 3. blah + + # another H1 header + 1. blah + 2. blah + ''').should.equal(''' + # H1 header + 1. blah + 2. blah + 3. blah + + # another H1 header + 1. blah + 2. blah + ''') describe 'inline grammar', -> it 'should handle special characters', ->