Module: Infoboxer::Parser::HTML
Instance Method Summary collapse
- #html ⇒ Object
- #html_auto_closing_tag ⇒ Object
- #html_br ⇒ Object
- #html_closing_tag ⇒ Object
- #html_opening_tag ⇒ Object
Instance Method Details
#html ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/infoboxer/parser/html.rb', line 6 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 ⇒ Object
34 35 36 37 38 39 |
# File 'lib/infoboxer/parser/html.rb', line 34 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 ⇒ Object
29 30 31 32 |
# File 'lib/infoboxer/parser/html.rb', line 29 def html_br @context.skip(/br\s*>/) HTMLTag.new('br', {}) end |
#html_closing_tag ⇒ Object
22 23 24 25 26 27 |
# File 'lib/infoboxer/parser/html.rb', line 22 def html_closing_tag @context.skip(%r{/}) tag = @context.scan(/[a-z]+/) @context.skip(/>/) HTMLClosingTag.new(tag) end |
#html_opening_tag ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/infoboxer/parser/html.rb', line 41 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 |