Skip to content

Commit 2dd2946

Browse files
committed
Fix: #paragraphs grabs paragraphs in tables
1 parent 8c40b4c commit 2dd2946

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/docx/document.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def self.open(path, &block)
5151
end
5252

5353
def paragraphs
54-
@doc.xpath('//w:document//w:body//w:p').map { |p_node| parse_paragraph_from p_node }
54+
@doc.xpath('//w:document//w:body/w:p').map { |p_node| parse_paragraph_from p_node }
5555
end
5656

5757
def bookmarks

spec/docx/document_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
it "should read embedded links" do
9090
expect(@doc.tables[0].columns[1].cells[1].text).to match(/^Directive/)
9191
end
92+
93+
describe '#paragraphs' do
94+
it 'should not grabs paragraphs in the tables' do
95+
expect(@doc.paragraphs.map(&:text)).to_not include("Second table")
96+
end
97+
end
9298
end
9399

94100
describe 'editing' do

0 commit comments

Comments
 (0)