diff --git a/pydocx/DocxParser.py b/pydocx/DocxParser.py index c57817f0..33c322d2 100644 --- a/pydocx/DocxParser.py +++ b/pydocx/DocxParser.py @@ -576,12 +576,22 @@ def parse_p(self, el, text): def _should_append_break_tag(self, next_el): paragraph_like_tags = [ 'p', - 'sdt', + ] + inline_like_tags = [ + 'smartTag', + 'ins', + 'delText', ] if next_el.is_list_item: return False if next_el.previous is None: return False + tag_is_inline_like = any( + next_el.has_descendant_with_tag(tag) for + tag in inline_like_tags + ) + if tag_is_inline_like: + return False if next_el.previous.is_last_list_item_in_root: return False if next_el.previous.tag not in paragraph_like_tags: diff --git a/pydocx/parsers/Docx2Html.py b/pydocx/parsers/Docx2Html.py index 782be941..525bdd9c 100644 --- a/pydocx/parsers/Docx2Html.py +++ b/pydocx/parsers/Docx2Html.py @@ -54,8 +54,7 @@ def heading(self, text, heading_value): def insertion(self, text, author, date): return ( - "%(text)s" + "%(text)s" ) % { 'author': author, 'date': date, @@ -88,8 +87,7 @@ def image(self, path, x, y): def deletion(self, text, author, date): return ( - "%(text)s" + "%(text)s" ) % { 'author': author, 'date': date, diff --git a/pydocx/tests/test_xml.py b/pydocx/tests/test_xml.py index 4e5cf1a0..16b274c7 100644 --- a/pydocx/tests/test_xml.py +++ b/pydocx/tests/test_xml.py @@ -641,7 +641,7 @@ def test_performance(self): class NonStandardTextTagsTestCase(_TranslationTestCase): expected_output = ''' -

insert +

insert smarttag

''' @@ -674,8 +674,8 @@ def get_xml(self): class DeleteTagInList(_TranslationTestCase): expected_output = '''
    -
  1. AAA
    - BBB +
  2. AAA + BBB
  3. CCC
@@ -696,8 +696,7 @@ def get_xml(self): class InsertTagInList(_TranslationTestCase): expected_output = '''
    -
  1. AAA
    - BBB +
  2. AAABBB
  3. CCC
@@ -719,8 +718,7 @@ def get_xml(self): class SmartTagInList(_TranslationTestCase): expected_output = '''
    -
  1. AAA
    - BBB +
  2. AAABBB
  3. CCC
@@ -875,8 +873,7 @@ def get_xml(self): class SDTTestCase(_TranslationTestCase): expected_output = '''
    -
  1. AAA
    - BBB +
  2. AAABBB
  3. CCC