Sha256: 59b97410f4e7e5a4b48ac2844c59aaea51c961ef25616b76f401c236a86aea81
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
# encoding: utf-8 module Infoboxer module Tree module HTMLTagCommons BLOCK_TAGS = %w[div p br] # FIXME: are some other used in WP? def text super + (BLOCK_TAGS.include?(tag) ? "\n" : '') end end # Represents HTML tag, surrounding some contents. class HTMLTag < Compound def initialize(tag, attrs, children = Nodes.new) super(children, attrs) @tag = tag end attr_reader :tag alias_method :attrs, :params include HTMLTagCommons # Internal, used by {Parser}. def empty? # even empty tag, for ex., <br>, should not be dropped! false end private def descr "#{clean_class}:#{tag}(#{show_params})" end end # Represents orphan opening HTML tag. # # NB: Infoboxer not tries to parse entire structure of HTML-heavy # MediaWiki articles. So, if you have `<div>` at line 150 and closing # `</div>` at line 875, there would be orphane `HTMLOpeningTag` and # {HTMLClosingTag}. It is not always convenient, but reasonable enough. # class HTMLOpeningTag < Node def initialize(tag, attrs) super(attrs) @tag = tag end attr_reader :tag alias_method :attrs, :params include HTMLTagCommons private def descr "#{clean_class}:#{tag}(#{show_params})" end end # Represents orphan closing HTML tag. See {HTMLOpeningTag} for # explanation. class HTMLClosingTag < Node def initialize(tag) @tag = tag end attr_reader :tag def descr "#{clean_class}:#{tag}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
infoboxer-0.1.0 | lib/infoboxer/tree/html.rb |