Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.4.4 - fix text property of CT_IR and CT_DR #13

Merged
merged 9 commits into from
Sep 19, 2022
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
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added dist/python_docx-0.4.4-py3-none-any.whl
Binary file not shown.
Binary file added dist/python_docx-0.4.4rc1-py3-none-any.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion docx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions docx/oxml/text/delrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
from ..simpletypes import ST_BrClear, ST_BrType
from ..xmlchemy import (BaseOxmlElement, OptionalAttribute, ZeroOrMore, ZeroOrOne)


class CT_DR(BaseOxmlElement):
"""
``<w:del>`` 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 ''<w:delText>'' element containing *text*.
"""
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions docx/oxml/text/insrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class CT_IR(BaseOxmlElement):
``<w:ins>`` element, containing the properties and text for a insert run.
"""
r = ZeroOrMore('w:r')

def add_t(self,text):
"""
Return a newly added ''<w:t>'' element containing *text*.
Expand All @@ -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
Expand All @@ -65,6 +61,7 @@ def rpr(self):
@rpr.setter
def rpr(self, value):
self.copy_rpr(value)

@property
def style(self):
"""
Expand Down