class Boilerpipe::SAX::TagActions::Font

Special TagAction for the <FONT> tag, which keeps track of the absolute and relative font size.

Constants

FONT_SIZE

Public Instance Methods

changes_tag_level?() click to toggle source
# File lib/boilerpipe/sax/tag_actions/font.rb, line 25
def changes_tag_level?
  false
end
end_tag(handler, name) click to toggle source
# File lib/boilerpipe/sax/tag_actions/font.rb, line 20
def end_tag(handler, name)
  handler.font_size_stack.pop
  false
end
relative(font_size_stack, rel, val) click to toggle source
# File lib/boilerpipe/sax/tag_actions/font.rb, line 29
def relative(font_size_stack, rel, val)
  prev_size = font_size_stack.reverse_each.find { |s| !s.nil? }
  prev_size = 3 if prev_size.nil?

  size = if rel == '+'
           prev_size + val
         else
           prev_size - val
         end
end
start(handler, name, attrs) click to toggle source
# File lib/boilerpipe/sax/tag_actions/font.rb, line 7
def start(handler, name, attrs)
  m = FONT_SIZE.match attrs['size']
  if m
    rel = m[1]
    val = m[2].to_i # absolute
    size = rel.empty? ? val : relative(handler.font_size_stack, rel, val)
    handler.font_size_stack << size
  else
    handler.font_size_stack << nil
  end
  false
end