Skip to content

Commit 6b0f2fd

Browse files
authored
Added paragraph property to get text after changes
Added paragraph property `Paragraph.accepted_text` to get text after accepting changes (insertion and deletion).
1 parent da75fcf commit 6b0f2fd

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

docx/text/paragraph.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ def text(self, text):
136136
self.clear()
137137
self.add_run(text)
138138

139+
@property
140+
def accepted_text(self):
141+
"""
142+
String formed by accepting all changes and concatenating
143+
the text of each run in the paragraph.
144+
Tabs and line breaks in the XML are mapped to ``\\t`` and ``\\n``
145+
characters respectively.
146+
"""
147+
text = ''
148+
for run_text in self._p.xpath(".//w:t"):
149+
text += run_text.text
150+
return text
151+
139152
def _insert_paragraph_before(self):
140153
"""
141154
Return a newly created paragraph, inserted directly before this

0 commit comments

Comments
 (0)