Sha256: a6336183d066fa391aba5c609ae396cb753d43ba8e02ce8708cf7792e0ce3f20
Contents?: true
Size: 1.68 KB
Versions: 11
Compression:
Stored size: 1.68 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 # @private # 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
11 entries across 11 versions & 1 rubygems