diff --git a/HISTORY.rst b/HISTORY.rst index 8c984b3cd..f0ee74da3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -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 diff --git a/dist/python-docx-1961rc1.tar.gz b/dist/python-docx-1961rc1.tar.gz new file mode 100644 index 000000000..2e00da528 Binary files /dev/null and b/dist/python-docx-1961rc1.tar.gz differ diff --git a/dist/python_docx-0.4.7-py3-none-any.whl b/dist/python_docx-0.4.7-py3-none-any.whl new file mode 100644 index 000000000..d3515fa25 Binary files /dev/null and b/dist/python_docx-0.4.7-py3-none-any.whl differ diff --git a/docx/__init__.py b/docx/__init__.py index bfc807594..d9917564c 100644 --- a/docx/__init__.py +++ b/docx/__init__.py @@ -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 diff --git a/docx/oxml/table.py b/docx/oxml/table.py index 387b05063..436d7a929 100644 --- a/docx/oxml/table.py +++ b/docx/oxml/table.py @@ -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 diff --git a/docx/oxml/text/delrun.py b/docx/oxml/text/delrun.py index 9f897ca44..0245da98f 100644 --- a/docx/oxml/text/delrun.py +++ b/docx/oxml/text/delrun.py @@ -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): @@ -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 ```` 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): diff --git a/docx/oxml/text/insrun.py b/docx/oxml/text/insrun.py index 4b65d001b..5b0e24014 100644 --- a/docx/oxml/text/insrun.py +++ b/docx/oxml/text/insrun.py @@ -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): @@ -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() @@ -86,8 +88,8 @@ def clear_content(self): """ Remove all child elements except the ```` 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) diff --git a/docx/text/insrun.py b/docx/text/insrun.py index b8a3d71dd..7d809ae3e 100644 --- a/docx/text/insrun.py +++ b/docx/text/insrun.py @@ -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):