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
9 changes: 8 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
Release History
---------------

0.4.6 ()
0.4.7 (2023-07-19)
++++++++++++++++++
- DEV-2649: add shd tag to TcPr for colored table cells
- Fix "text" attr setter for CT_DR and CT_IR
- DEV-3177: get children anywhere for all_runs for CT_IR to support runs
nested inside of deletes

0.4.6 (2023-05-26)
++++++++++++++++++
- DEV-3195: wrap int() call in float() so we can read float vals of size attrs
in e.g. w:spacing tags
Expand Down
Binary file added dist/python-docx-1961rc1.tar.gz
Binary file not shown.
Binary file added dist/python_docx-0.4.7-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.6"
__version__ = "0.4.7"


# register custom Part classes with opc package reader
Expand Down
1 change: 1 addition & 0 deletions docx/oxml/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ class CT_TcPr(BaseOxmlElement):
gridSpan = ZeroOrOne('w:gridSpan', successors=_tag_seq[3:])
tcBorders = ZeroOrOne('w:tcBorders', successors = ('w:tcPr',))
vMerge = ZeroOrOne('w:vMerge', successors=_tag_seq[5:])
shd = ZeroOrOne('w:shd', successors=_tag_seq[7:])
vAlign = ZeroOrOne('w:vAlign', successors=_tag_seq[12:])

del _tag_seq
Expand Down
10 changes: 6 additions & 4 deletions docx/oxml/text/delrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..ns import qn
from ..simpletypes import ST_BrClear, ST_BrType
from ..xmlchemy import (BaseOxmlElement, OptionalAttribute, ZeroOrMore, ZeroOrOne)
from ..xmlchemy import (BaseOxmlElement, OptionalAttribute, ZeroOrMore, ZeroOrOne, OxmlElement)


class CT_DR(BaseOxmlElement):
Expand Down Expand Up @@ -46,14 +46,16 @@ def text(self):
@text.setter
def text(self, text):
self.clear_content()
_RunContentAppender.append_to_run_from_text(self, text)
new_run = OxmlElement("w:r")
new_run.add_dt(text)
self.append(new_run)

def clear_content(self):
"""
Remove all child elements except the ``<w:rPr>`` element if present.
"""
content_child_elms = self[1:] if self.rPr is not None else self[:]
for child in content_child_elms:
# content_child_elms = self[1:] if self.rPr is not None else self[:]
for child in self[:]:
self.remove(child)

def copy_rpr(self,rprCopy):
Expand Down
10 changes: 6 additions & 4 deletions docx/oxml/text/insrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..ns import qn
from ..simpletypes import ST_BrClear, ST_BrType
from ..xmlchemy import (BaseOxmlElement, OptionalAttribute, ZeroOrMore, ZeroOrOne)
from ..xmlchemy import (BaseOxmlElement, OptionalAttribute, ZeroOrMore, ZeroOrOne, OxmlElement)


class CT_IR(BaseOxmlElement):
Expand Down Expand Up @@ -47,7 +47,9 @@ def text(self):
@text.setter
def text(self, text):
self.clear_content()
_RunContentAppender.append_to_run_from_text(self, text)
new_run = OxmlElement("w:r")
new_run.text = text
self.append(new_run)

def copy_rpr(self,rprCopy):
rPr = self._r.get_or_add_rPr()
Expand Down Expand Up @@ -86,8 +88,8 @@ def clear_content(self):
"""
Remove all child elements except the ``<w:rPr>`` element if present.
"""
content_child_elms = self[1:] if self.rPr is not None else self[:]
for child in content_child_elms:
# content_child_elms = self[1:] if self.rPr is not None else self[:]
for child in self[:]:
self.remove(child)


Expand Down
2 changes: 1 addition & 1 deletion docx/text/insrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def rpr(self, value):

@property
def all_runs(self):
return [Run(r, self) for r in self._i.xpath('./w:r')]
return [Run(r, self) for r in self._i.xpath('.//w:r')]


class _Text(object):
Expand Down