Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pydocx/DocxParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions pydocx/parsers/Docx2Html.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def heading(self, text, heading_value):

def insertion(self, text, author, date):
return (
"<span class='pydocx-insert' author='%(author)s' "
"date='%(date)s'>%(text)s</span>"
"<span class='pydocx-insert'>%(text)s</span>"
) % {
'author': author,
'date': date,
Expand Down Expand Up @@ -88,8 +87,7 @@ def image(self, path, x, y):

def deletion(self, text, author, date):
return (
"<span class='pydocx-delete' author='%(author)s' "
"date='%(date)s'>%(text)s</span>"
"<span class='pydocx-delete'>%(text)s</span>"
) % {
'author': author,
'date': date,
Expand Down
15 changes: 6 additions & 9 deletions pydocx/tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def test_performance(self):

class NonStandardTextTagsTestCase(_TranslationTestCase):
expected_output = '''
<p><span class='pydocx-insert' author='' date=''>insert </span>
<p><span class='pydocx-insert'>insert </span>
smarttag</p>
'''

Expand Down Expand Up @@ -674,8 +674,8 @@ def get_xml(self):
class DeleteTagInList(_TranslationTestCase):
expected_output = '''
<ol list-style-type="decimal">
<li>AAA<br />
<span class='pydocx-delete' author='' date=''>BBB</span>
<li>AAA
<span class='pydocx-delete'>BBB</span>
</li>
<li>CCC</li>
</ol>
Expand All @@ -696,8 +696,7 @@ def get_xml(self):
class InsertTagInList(_TranslationTestCase):
expected_output = '''
<ol list-style-type="decimal">
<li>AAA<br />
<span class='pydocx-insert' author='' date=''>BBB</span>
<li>AAA<span class='pydocx-insert'>BBB</span>
</li>
<li>CCC</li>
</ol>
Expand All @@ -719,8 +718,7 @@ def get_xml(self):
class SmartTagInList(_TranslationTestCase):
expected_output = '''
<ol list-style-type="decimal">
<li>AAA<br />
BBB
<li>AAABBB
</li>
<li>CCC</li>
</ol>
Expand Down Expand Up @@ -875,8 +873,7 @@ def get_xml(self):
class SDTTestCase(_TranslationTestCase):
expected_output = '''
<ol list-style-type="decimal">
<li>AAA<br />
BBB
<li>AAABBB
</li>
<li>CCC</li>
</ol>
Expand Down