Repository: miyuchina/mistletoe

Issue:
lists should not contain <p>
Why do you use &lt;p&gt;&lt;/p&gt; in lists ? This is not the way Commonmark does it.

Other strange behavior: in the same document, some lists get the paragraphs, some others don't. Could you explain how it is supposed to work ?

Discussion:
coveralls: 
[![Coverage Status](https://coveralls.io/builds/18793185/badge)](https://coveralls.io/builds/18793185)

Coverage increased (+1.3%) to 93.163% when pulling **ba97a0b43331d67a50205adef6ee757ad8650b88 on Rogdham:fix-54** into **8cca7a53626e8c25039423dc9cd8db843447f813 on miyuchina:master**.


Patch:
diff --git a/mistletoe/block_token.py b/mistletoe/block_token.py
index 0a4c2c0..7eeb3f1 100644
--- a/mistletoe/block_token.py
+++ b/mistletoe/block_token.py
@@ -574,6 +574,9 @@ class ListItem(BlockToken):
             if not cls.in_continuation(next_line, prepend):
                 # directly followed by another token
                 if cls.other_token(next_line):
+                    if newline:
+                        lines.backstep()
+                        del line_buffer[-newline:]
                     break
                 # next_line is a new list item
                 marker_info = cls.parse_marker(next_line)


Test patch:
diff --git a/test/test_block_token.py b/test/test_block_token.py
index b3c94b1..78fb0b2 100644
--- a/test/test_block_token.py
+++ b/test/test_block_token.py
@@ -191,6 +191,14 @@ class TestListItem(unittest.TestCase):
         list_item = block_token.tokenize(lines)[0].children[0]
         self.assertEqual(list_item.loose, False)
 
+    def test_tight_list(self):
+        lines = ['- foo\n',
+                 '\n',
+                 '# bar\n']
+        f = FileWrapper(lines)
+        list_item = block_token.tokenize(lines)[0].children[0]
+        self.assertEqual(list_item.loose, False)
+
 
 class TestList(unittest.TestCase):
     def test_different_markers(self):