From 8a66fe6dfd206cdae9fec82a47c61a7082e1a235 Mon Sep 17 00:00:00 2001 From: Graham Holker Date: Sat, 18 Mar 2023 16:40:28 -0400 Subject: [PATCH] Handle empty list item --- src/mistune/renderers/_list.py | 2 +- tests/fixtures/renderer_markdown.txt | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mistune/renderers/_list.py b/src/mistune/renderers/_list.py index 0a18639..90b3ef5 100644 --- a/src/mistune/renderers/_list.py +++ b/src/mistune/renderers/_list.py @@ -28,7 +28,7 @@ def _render_list_item(renderer, parent, item, state): text += renderer.render_token(tok, state) lines = text.splitlines() - text = lines[0] + '\n' + text = (lines[0] if lines else '') + '\n' prefix = ' ' * len(leading) for line in lines[1:]: if line: diff --git a/tests/fixtures/renderer_markdown.txt b/tests/fixtures/renderer_markdown.txt index 184350c..1440875 100644 --- a/tests/fixtures/renderer_markdown.txt +++ b/tests/fixtures/renderer_markdown.txt @@ -277,3 +277,11 @@ hello 2. item 2 ```````````````````````````````` + +```````````````````````````````` example +- list +- +. +- list +- +````````````````````````````````