Skip to content
Closed
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
14 changes: 14 additions & 0 deletions docx/oxml/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def get_or_add_pPr(self):
if pPr is None:
pPr = self._add_pPr()
return pPr

def clear_r(self):
"""
Remove all run elements in this paragraph.
"""
for r in self.r_lst:
self.remove(r)

@staticmethod
def new():
Expand Down Expand Up @@ -253,6 +260,13 @@ def get_or_add_rPr(self):
rPr = self._add_rPr()
return rPr

def clear_t(self):
"""
Remove all text elements in this run.
"""
for t in self.t_lst:
self.remove(t)

@classmethod
def new(cls):
"""
Expand Down
12 changes: 12 additions & 0 deletions docx/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def add_run(self, text=None):
if text:
run.add_text(text)
return run

def clear_runs(self):
"""
Remove all runs in this paragraph.
"""
self._p.clear_r()

@property
def runs(self):
Expand Down Expand Up @@ -140,6 +146,12 @@ def add_text(self, text):
t = self._r.add_t(text)
return Text(t)

def clear_texts(self):
"""
Remove all text in this run.
"""
self._r.clear_t()

@boolproperty
def all_caps(self):
"""
Expand Down