diff --git a/CHANGELOG b/CHANGELOG index 7a19c801..f1bc6410 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,7 +8,8 @@ Changelog cases in which the continue attribute is not there. * We now correctly handle documents with unicode character in the namespace. - + * In rare cases, some text would be output with a style when it should not + have been. This issue has been fixed. * 0.3.1 * Added support for several more OOXML tags including: * caps diff --git a/pydocx/DocxParser.py b/pydocx/DocxParser.py index 0f734b5e..465d2786 100644 --- a/pydocx/DocxParser.py +++ b/pydocx/DocxParser.py @@ -30,6 +30,7 @@ INDENTATION_RIGHT = 'right' INDENTATION_LEFT = 'left' INDENTATION_FIRST_LINE = 'firstLine' +DISABLED_VALUES = ['false', '0'] # Add some helper functions to Element to make it slightly more readable @@ -572,7 +573,8 @@ def _is_style_on(self, el): sufficient. You need to check to make sure it is not set to "false" as well. """ - return el.get('val') != 'false' + val = el.get('val', '').lower() + return val.lower() not in DISABLED_VALUES def parse_t(self, el, parsed): return self.escape(el.text) diff --git a/pydocx/tests/test_xml.py b/pydocx/tests/test_xml.py index fded774b..7e80b323 100644 --- a/pydocx/tests/test_xml.py +++ b/pydocx/tests/test_xml.py @@ -16,6 +16,7 @@ class BoldTestCase(_TranslationTestCase): expected_output = """

AAA

BBB

+

CCC

""" def get_xml(self): @@ -36,6 +37,14 @@ def get_xml(self): ), ], ), + DXB.p_tag( + [ + DXB.r_tag( + [DXB.t_tag('CCC')], + rpr=DXB.rpr_tag({'b': '0'}), + ), + ], + ), ] body = ''