Repository: d0c-s4vage/lookatme

Issue:
Add newline token support
Apparently I never add double newlines in a markdown document

Discussion:

Patch:
diff --git a/lookatme/render/markdown_block.py b/lookatme/render/markdown_block.py
index 77a7433..703478f 100644
--- a/lookatme/render/markdown_block.py
+++ b/lookatme/render/markdown_block.py
@@ -46,6 +46,16 @@ def _list_level(item):
     return _meta(item).get("list_level", 1)
 
 
+@contrib_first
+def render_newline(token, body, stack, loop):
+    """Render a newline
+
+    See :any:`lookatme.tui.SlideRenderer.do_render` for argument and return
+    value descriptions.
+    """
+    return urwid.Divider()
+
+
 @contrib_first
 def render_heading(token, body, stack, loop):
     """Render markdown headings, using the defined styles for the styling and


Test patch:
diff --git a/tests/test_markdown.py b/tests/test_markdown.py
index aa3c2e3..5fa53f9 100644
--- a/tests/test_markdown.py
+++ b/tests/test_markdown.py
@@ -162,6 +162,42 @@ def test_lists(mocker):
         assert stripped_row_text == stripped_rows[idx]
 
 
+def test_lists_with_newline(mocker):
+    """Test list rendering with a newline between a new nested list and the
+    previous list item
+    """
+    import lookatme.widgets.table
+
+    mocker.patch.object(lookatme.config, "LOG")
+    fake_config = mocker.patch.object(lookatme.render.markdown_block, "config")
+    mocker.patch.object(lookatme.widgets.table, "config", fake_config)
+    fake_config.STYLE = {
+        "bullets": {
+            "default": "*",
+            "1": "-",
+            "2": "=",
+            "3": "^",
+        },
+    }
+
+    rendered = render_markdown("""
+* list 1
+
+  * list 2
+""")
+
+    stripped_rows = [
+        b'',
+        b'  - list 1',
+        b'',
+        b'      = list 2',
+        b'',
+    ]
+    for idx, row in enumerate(rendered):
+        stripped_row_text = row_text(row).rstrip()
+        assert stripped_row_text == stripped_rows[idx]
+
+
 def test_block_quote(mocker):
     """Test block quote rendering
     """