Skip to content

Commit 045c9f9

Browse files
committed
merges tag levels
1 parent 2af1f17 commit 045c9f9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/boilerpipe/document/text_block.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ def merge_next(other)
6868
@offset_blocks_end = [@offset_blocks_end, other.offset_blocks_end].max
6969
@content |= other.is_content?
7070
@labels.merge(other.labels.clone)
71-
init_densities
72-
7371
@tag_level = [@tag_level, other.tag_level].min
72+
73+
init_densities
7474
end
7575

7676
def to_s

spec/document/text_block_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ module Boilerpipe
133133

134134
expect(block.labels).to eq Set.new(['boom', 'pow'])
135135
end
136+
137+
it 'sets the tag level to the minimum of the two blocks' do
138+
block = Document::TextBlock.new('one')
139+
block.set_tag_level(2)
140+
141+
another_block = Document::TextBlock.new('two')
142+
another_block.set_tag_level(1)
143+
144+
block.merge_next(another_block)
145+
146+
expect(block.tag_level).to eq 1
147+
end
136148
end
137149

138150
describe '#add_label' do

0 commit comments

Comments
 (0)