diff --git a/CHANGELOG b/CHANGELOG index 94035b11..f009a3b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,16 @@ Changelog ========= +* 0.3.6 + * It is possible for a docx file to not contain a `numbering.xml` file but + still try to use lists. Now if this happens all lists get converted to + paragraphs. * 0.3.5 * Not all docx files contain a `styles.xml` file. We are no longer assuming they do. * 0.3.4 - * It is possible for `w:t` tags to have `text` set to `None`. This no longer causes an error when escaping that text. + * It is possible for `w:t` tags to have `text` set to `None`. This no + longer causes an error when escaping that text. * 0.3.3 * In the event that `cElementTree` has a problem parsing the document, a `MalformedDocxException` is raised instead of a `SyntaxError` diff --git a/pydocx/fixtures/missing_numbering.docx b/pydocx/fixtures/missing_numbering.docx new file mode 100644 index 00000000..5034f524 Binary files /dev/null and b/pydocx/fixtures/missing_numbering.docx differ diff --git a/pydocx/tests/test_docx.py b/pydocx/tests/test_docx.py index a0aa1909..f5b39995 100644 --- a/pydocx/tests/test_docx.py +++ b/pydocx/tests/test_docx.py @@ -735,6 +735,20 @@ def test_missing_style(): ''') +def test_missing_numbering(): + file_path = path.join( + path.abspath(path.dirname(__file__)), + '..', + 'fixtures', + 'missing_numbering.docx', + ) + actual_html = convert(file_path) + assert_html_equal(actual_html, BASE_HTML % ''' +

AAA

+

BBB

+ ''') + + def _converter(*args, **kwargs): # Having a converter that does nothing is the same as if abiword fails to # convert. diff --git a/pydocx/utils.py b/pydocx/utils.py index 45beed0b..1d5cd8b9 100644 --- a/pydocx/utils.py +++ b/pydocx/utils.py @@ -168,7 +168,9 @@ def __init__( def perform_pre_processing(self, root, *args, **kwargs): self._add_parent(root) - self._set_list_attributes(root) + # If we don't have a numbering root there cannot be any lists. + if self.numbering_root is not None: + self._set_list_attributes(root) self._set_table_attributes(root) self._set_is_in_table(root)