diff --git a/HISTORY.rst b/HISTORY.rst index 26ccd2e3c..6d94db13f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,10 @@ Release History --------------- +0.4.4 (2022-09-14) +++++++++++++++++++ +- DEV-1807: fix `text` property of CT_IR and CT_DR + 0.4.3 (2022-05-13) ++++++++++++++++++ - DEV-1907: remove self-added `br` property from CT_R diff --git a/dist/python_docx-0.4.4-py3-none-any.whl b/dist/python_docx-0.4.4-py3-none-any.whl new file mode 100644 index 000000000..19c861efa Binary files /dev/null and b/dist/python_docx-0.4.4-py3-none-any.whl differ diff --git a/dist/python_docx-0.4.4rc1-py3-none-any.whl b/dist/python_docx-0.4.4rc1-py3-none-any.whl new file mode 100644 index 000000000..d0dba227c Binary files /dev/null and b/dist/python_docx-0.4.4rc1-py3-none-any.whl differ diff --git a/docx/__init__.py b/docx/__init__.py index 634a80b57..1831f126f 100644 --- a/docx/__init__.py +++ b/docx/__init__.py @@ -2,7 +2,7 @@ from docx.api import Document # noqa -__version__ = "0.4.3" +__version__ = "0.4.4" # register custom Part classes with opc package reader diff --git a/docx/oxml/text/delrun.py b/docx/oxml/text/delrun.py index 345e96254..9f897ca44 100644 --- a/docx/oxml/text/delrun.py +++ b/docx/oxml/text/delrun.py @@ -14,12 +14,14 @@ from ..simpletypes import ST_BrClear, ST_BrType from ..xmlchemy import (BaseOxmlElement, OptionalAttribute, ZeroOrMore, ZeroOrOne) + class CT_DR(BaseOxmlElement): """ ```` element, containing the properties and text for a delete run. """ r = ZeroOrMore('w:r') - def add_dt(self,text): + + def add_dt(self, text): """ Return a newly added '''' element containing *text*. """ @@ -37,13 +39,8 @@ def text(self): """ text = '' for child in self: - if child.tag == qn('w:delText'): - t_text = child.text - text += t_text if t_text is not None else '' - elif child.tag == qn('w:tab'): - text += '\t' - elif child.tag in (qn('w:br'), qn('w:cr')): - text += '\n' + if child.tag == qn("w:r"): + text += child.text return text @text.setter diff --git a/docx/oxml/text/insrun.py b/docx/oxml/text/insrun.py index f3707d112..4b65d001b 100644 --- a/docx/oxml/text/insrun.py +++ b/docx/oxml/text/insrun.py @@ -20,6 +20,7 @@ class CT_IR(BaseOxmlElement): ```` element, containing the properties and text for a insert run. """ r = ZeroOrMore('w:r') + def add_t(self,text): """ Return a newly added '''' element containing *text*. @@ -39,13 +40,8 @@ def text(self): """ text = '' for child in self: - if child.tag == qn('w:t'): - t_text = child.text - text += t_text if t_text is not None else '' - elif child.tag == qn('w:tab'): - text += '\t' - elif child.tag in (qn('w:br'), qn('w:cr')): - text += '\n' + if child.tag == qn('w:r'): + text += child.text return text @text.setter @@ -65,6 +61,7 @@ def rpr(self): @rpr.setter def rpr(self, value): self.copy_rpr(value) + @property def style(self): """