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
Binary file added dist/python-docx-1961rc1.tar.gz
Binary file not shown.
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