module Infoboxer::Parser::HTML
Public Instance Methods
html()
click to toggle source
# File lib/infoboxer/parser/html.rb, line 8 def html case when @context.check(%r{/[a-z]+>}) html_closing_tag when @context.check(/br\s*>/) html_br when @context.check(%r{[a-z]+[^/>]*/>}) html_auto_closing_tag when @context.check(%r{[a-z]+[^>/]*>}) html_opening_tag else # not an HTML tag at all! nil end end
html_auto_closing_tag()
click to toggle source
# File lib/infoboxer/parser/html.rb, line 36 def html_auto_closing_tag tag = @context.scan(/[a-z]+/) attrs = @context.scan(%r{[^/>]*}) @context.skip(%r{/>}) HTMLTag.new(tag, parse_params(attrs)) end
html_br()
click to toggle source
# File lib/infoboxer/parser/html.rb, line 31 def html_br @context.skip(/br\s*>/) HTMLTag.new('br', {}) end
html_closing_tag()
click to toggle source
# File lib/infoboxer/parser/html.rb, line 24 def html_closing_tag @context.skip(%r{/}) tag = @context.scan(/[a-z]+/) @context.skip(/>/) HTMLClosingTag.new(tag) end
html_opening_tag()
click to toggle source
# File lib/infoboxer/parser/html.rb, line 43 def html_opening_tag tag = @context.scan(/[a-z]+/) attrs = @context.scan(/[^>]+/) @context.skip(/>/) contents = short_inline(%r{</#{tag}>}) if @context.matched =~ %r{</#{tag}>} HTMLTag.new(tag, parse_params(attrs), contents) else [ HTMLOpeningTag.new(tag, parse_params(attrs)), *contents ] end end