From 4e77045d7808a49254c9caca2401af32ef0ea9af Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 16 Dec 2013 15:23:02 +0000 Subject: Set default paragraph rule to require fresh p element --- mammoth/conversion.py | 2 +- tests/conversion_tests.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mammoth/conversion.py b/mammoth/conversion.py index e21e3a0..b324c16 100644 --- a/mammoth/conversion.py +++ b/mammoth/conversion.py @@ -94,7 +94,7 @@ class DocumentConverter(object): def _find_html_path_for_paragraph(self, paragraph): - default = html_paths.path([html_paths.element("p")]) + default = html_paths.path([html_paths.element("p", fresh=True)]) return self._find_html_path(paragraph, "paragraph", default) def _find_html_path_for_run(self, run): diff --git a/tests/conversion_tests.py b/tests/conversion_tests.py index a041561..e3b4c9e 100644 --- a/tests/conversion_tests.py +++ b/tests/conversion_tests.py @@ -15,6 +15,17 @@ def plain_paragraph_is_converted_to_plain_paragraph(): assert_equal('

Hello

', result.value) +@istest +def multiple_paragraphs_are_converted_to_multiple_paragraphs(): + result = convert_document_element_to_html( + documents.document([ + documents.paragraph(children=[_run_with_text("Hello")]), + documents.paragraph(children=[_run_with_text("there")]), + ]) + ) + assert_equal('

Hello

there

', result.value) + + @istest def empty_paragraphs_are_ignored(): result = convert_document_element_to_html( -- cgit v1.2.3