Skip to content

Commit 9071fd2

Browse files
committed
Merge pull request #52 from OpenScienceFramework/issue_52
Correctly handle files that don't have numbering.xml but also have lists
2 parents ba89557 + f5e3558 commit 9071fd2

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

CHANGELOG

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11

22
Changelog
33
=========
4+
* 0.3.6
5+
* It is possible for a docx file to not contain a `numbering.xml` file but
6+
still try to use lists. Now if this happens all lists get converted to
7+
paragraphs.
48
* 0.3.5
59
* Not all docx files contain a `styles.xml` file. We are no longer assuming
610
they do.
711
* 0.3.4
8-
* It is possible for `w:t` tags to have `text` set to `None`. This no longer causes an error when escaping that text.
12+
* It is possible for `w:t` tags to have `text` set to `None`. This no
13+
longer causes an error when escaping that text.
914
* 0.3.3
1015
* In the event that `cElementTree` has a problem parsing the document, a
1116
`MalformedDocxException` is raised instead of a `SyntaxError`
3.27 KB
Binary file not shown.

pydocx/tests/test_docx.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,20 @@ def test_missing_style():
735735
''')
736736

737737

738+
def test_missing_numbering():
739+
file_path = path.join(
740+
path.abspath(path.dirname(__file__)),
741+
'..',
742+
'fixtures',
743+
'missing_numbering.docx',
744+
)
745+
actual_html = convert(file_path)
746+
assert_html_equal(actual_html, BASE_HTML % '''
747+
<p>AAA</p>
748+
<p>BBB</p>
749+
''')
750+
751+
738752
def _converter(*args, **kwargs):
739753
# Having a converter that does nothing is the same as if abiword fails to
740754
# convert.

pydocx/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ def __init__(
168168

169169
def perform_pre_processing(self, root, *args, **kwargs):
170170
self._add_parent(root)
171-
self._set_list_attributes(root)
171+
# If we don't have a numbering root there cannot be any lists.
172+
if self.numbering_root is not None:
173+
self._set_list_attributes(root)
172174
self._set_table_attributes(root)
173175
self._set_is_in_table(root)
174176

0 commit comments

Comments
 (0)