diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-02-08 20:59:23 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-02-08 20:59:23 +0000 |
| commit | 0d4206bdf8791be7d7488d8720b6146d187f433f (patch) | |
| tree | eb4f136f35b8e36541f9ebc55199836bba25c22d | |
| parent | e3bdc14ab04aafd60e078d52311ca15a53aa8ac6 (diff) | |
Handle li elements outside of lists in markdown writer
| -rw-r--r-- | mammoth/writers/markdown.py | 2 | ||||
| -rw-r--r-- | tests/writers/markdown_tests.py | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/mammoth/writers/markdown.py b/mammoth/writers/markdown.py index 04b339a..948e197 100644 --- a/mammoth/writers/markdown.py +++ b/mammoth/writers/markdown.py @@ -68,7 +68,7 @@ def _list(ordered): def _list_item(attributes, markdown_state): - list_state = markdown_state.list_state + list_state = markdown_state.list_state or _MarkdownListState(ordered=False) list_state.count += 1 if list_state.ordered: diff --git a/tests/writers/markdown_tests.py b/tests/writers/markdown_tests.py index ac00388..05db8ff 100644 --- a/tests/writers/markdown_tests.py +++ b/tests/writers/markdown_tests.py @@ -141,6 +141,15 @@ def image_elements_are_ignored_if_they_have_no_src_and_no_alt_text(): @istest +def list_item_outside_of_list_is_treated_as_unordered_list(): + writer = _create_writer() + writer.start("li") + writer.text("Fruit") + writer.end("li") + assert_equal("- Fruit\n", writer.as_string()) + + +@istest def ol_element_is_written_as_ordered_list_with_sequential_numbering(): writer = _create_writer() writer.start("ol") |
