From 0529888f557077c1621b9edb5bf9aa0ee623c00c Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Mon, 2 May 2016 08:54:19 -0500 Subject: [PATCH] Fix adjacent list merging Prevent adjacent lists of differing types from being merged into a single list. No options are provided to enable the previous behavior. Fixes #235 --- block.go | 7 +++++++ block_test.go | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/block.go b/block.go index 740ad46..f9ce9e3 100644 --- a/block.go +++ b/block.go @@ -1174,6 +1174,13 @@ gatherlines: p.dliPrefix(chunk) > 0: if containsBlankLine { + // end the list if the type changed after a blank line + if (*flags&LIST_TYPE_ORDERED != 0 && p.uliPrefix(chunk) > 0) || + (*flags&LIST_TYPE_ORDERED == 0 && p.oliPrefix(chunk) > 0) { + + *flags |= LIST_ITEM_END_OF_LIST + break gatherlines + } *flags |= LIST_ITEM_CONTAINS_BLOCK } diff --git a/block_test.go b/block_test.go index f59268e..bb3a50b 100644 --- a/block_test.go +++ b/block_test.go @@ -657,6 +657,9 @@ func TestUnorderedList(t *testing.T) { "Paragraph\n\n* Linebreak\n", "

Paragraph

\n\n\n", + "* List\n\n1. Spacer Mixed listing\n", + "\n\n
    \n
  1. Spacer Mixed listing
  2. \n
\n", + "* List\n * Nested list\n", "\n", @@ -815,6 +818,12 @@ func TestOrderedList(t *testing.T) { "1. List\n\n code block with spaces\n", "
    \n
  1. List

    \n\n
      code block with spaces\n
  2. \n
\n", + "1. List\n\n* Spacer Mixed listing\n", + "
    \n
  1. List
  2. \n
\n\n\n", + + "1. List\n* Mixed listing\n", + "
    \n
  1. List
  2. \n
  3. Mixed listing
  4. \n
\n", + "1. List\n * Mixted list\n", "
    \n
  1. List\n\n
      \n
    • Mixted list
    • \n
  2. \n
\n",