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
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion pydocx/DocxParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions pydocx/tests/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BoldTestCase(_TranslationTestCase):
expected_output = """
<p><strong>AAA</strong></p>
<p>BBB</p>
<p>CCC</p>
"""

def get_xml(self):
Expand All @@ -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 = ''
Expand Down