Skip to content

Commit

Permalink
Merge pull request #5 from mameier/master
Browse files Browse the repository at this point in the history
clear \ul with \ul0
  • Loading branch information
dj2 committed Nov 24, 2015
2 parents 1b5de52 + 72d02a7 commit 6104d3b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/ruby-rtf/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ def handle_control(name, val, src, current_pos)
add_section!(:italic => true)
end

when :ul then add_section!(:underline => true)
when :ul then
if val
@formatting_stack.pop
add_section!
else
add_section!(:underline => true)
end
when :ulnone then
current_section[:modifiers][:underline] = false
@formatting_stack.pop
Expand Down
12 changes: 12 additions & 0 deletions spec/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@
section[2][:modifiers].has_key?(:italic).should be_false
section[2][:text].should == 'Goodbye, cruel world.'
end

it 'clears ul with ul0' do
src = '{\rtf1 \ul\b Hello\b0\ul0 World}'
section = parser.parse(src).sections
section[0][:modifiers][:bold].should be_true
section[0][:modifiers][:underline].should be_true
section[0][:text].should == 'Hello'

section[1][:modifiers].has_key?(:bold).should be_false
section[1][:modifiers].has_key?(:underline).should be_false
section[1][:text].should == 'World'
end
end

context '#parse_control' do
Expand Down

0 comments on commit 6104d3b

Please sign in to comment.