Skip to content

Commit bbb6a00

Browse files
committed
allowed removing paragraphs nodes from structure with paragraph.remove
1 parent 26523fb commit bbb6a00

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/docx/containers/container.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ def properties
1414
def blank!
1515
@node.xpath(".//w:t").each {|t| t.content = '' }
1616
end
17+
18+
def remove!
19+
@node.remove
20+
end
1721
end
1822
end
1923
end
20-
end
24+
end

spec/docx/document_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@
152152
@doc.paragraphs.first.blank!
153153
@doc.paragraphs.first.text.should eq ''
154154
end
155+
156+
it 'should allow content deletion' do
157+
expect{@doc.paragraphs.first.remove!}.to change{@doc.paragraphs.size}.by(-1)
158+
159+
end
155160
end
156161

157162
describe 'read formatting' do

0 commit comments

Comments
 (0)