Skip to content

Commit 81adb71

Browse files
author
Jason Ward
committed
refs #27: correctly handle sdt tags (including break separating)
1 parent 00b8148 commit 81adb71

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pydocx/DocxParser.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def _set_next(self, body):
334334
def _get_children(el):
335335
# We only care about children if they have text in them.
336336
children = []
337-
for child in self._filter_children(el, ['p', 'tbl']):
337+
for child in self._filter_children(el, ['p', 'tbl', 'sdt']):
338338
has_descendant_with_tag = False
339339
if child.has_descendant_with_tag('t'):
340340
has_descendant_with_tag = True
@@ -555,15 +555,19 @@ def parse_p(self, el, text):
555555
return parsed
556556

557557
def _should_append_break_tag(self, next_el):
558+
paragraph_like_tags = [
559+
'p',
560+
'sdt',
561+
]
558562
if next_el.is_list_item:
559563
return False
560564
if next_el.previous is None:
561565
return False
562566
if next_el.previous.is_last_list_item_in_root:
563567
return False
564-
if next_el.previous.tag != 'p':
568+
if next_el.previous.tag not in paragraph_like_tags:
565569
return False
566-
if next_el.tag != 'p':
570+
if next_el.tag not in paragraph_like_tags:
567571
return False
568572
return True
569573

0 commit comments

Comments
 (0)