Class: Agio::HTMLElementDescription
- Inherits:
-
Object
- Object
- Agio::HTMLElementDescription
- Defined in:
- lib/agio/html_element_description.rb
Overview
Agio::HTMLElementDescription is a wrapper around Nokogiri::HTML::ElementDescription to work around a bug with LibXML2 prior to 2.7.7. In HTMLParser.c, the #define of INLINE didn’t have commas, meaning that strings were concatenated instead of forming an array (e.g., what should have been [ "small", "em" ]
ended up being [ "smallem" ]
). This was fixed in libxml2 commit 4b41f15d… on 20 January 2010 by Eugene Pimenov.
Nokogiri includes a DefaultDescription hash that contains the same basic information, so we will use that (with appropriate wrappers) if the version of LibXML2 is not sufficient to have this bug fixed.
Class Method Summary collapse
Instance Method Summary collapse
- #block? ⇒ Boolean
- #default_sub_element ⇒ Object
- #deprecated? ⇒ Boolean
- #deprecated_attributes ⇒ Object
- #description ⇒ Object
- #empty? ⇒ Boolean
- #implied_end_tag? ⇒ Boolean
- #implied_start_tag? ⇒ Boolean
-
#initialize(desc) ⇒ HTMLElementDescription
constructor
A new instance of HTMLElementDescription.
- #inline? ⇒ Boolean
- #inspect ⇒ Object
- #name ⇒ Object
- #optional_attributes ⇒ Object
- #required_attributes ⇒ Object
- #save_end_tag? ⇒ Boolean
- #sub_elements ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(desc) ⇒ HTMLElementDescription
Returns a new instance of HTMLElementDescription.
55 56 57 58 59 |
# File 'lib/agio/html_element_description.rb', line 55 def initialize(desc) @d = desc @name = name.downcase @d = Nokogiri::HTML::ElementDescription::DefaultDescriptions[@name] end |
Class Method Details
.[](name) ⇒ Object
26 27 28 |
# File 'lib/agio/html_element_description.rb', line 26 def self.[](name) Nokogiri::HTML::ElementDescription[name] end |
Instance Method Details
#block? ⇒ Boolean
77 78 79 |
# File 'lib/agio/html_element_description.rb', line 77 def block? !inline? end |
#default_sub_element ⇒ Object
109 110 111 |
# File 'lib/agio/html_element_description.rb', line 109 def default_sub_element @d ? @d.defaultsubelt : nil end |
#deprecated? ⇒ Boolean
101 102 103 |
# File 'lib/agio/html_element_description.rb', line 101 def deprecated? @d ? @d.depr : nil end |
#deprecated_attributes ⇒ Object
117 118 119 |
# File 'lib/agio/html_element_description.rb', line 117 def deprecated_attributes @d ? @d.attrs_depr : [] end |
#description ⇒ Object
105 106 107 |
# File 'lib/agio/html_element_description.rb', line 105 def description @d ? @d.desc : nil end |
#empty? ⇒ Boolean
85 86 87 |
# File 'lib/agio/html_element_description.rb', line 85 def empty? @d ? @d.empty : nil end |
#implied_end_tag? ⇒ Boolean
93 94 95 |
# File 'lib/agio/html_element_description.rb', line 93 def implied_end_tag? @d ? @d.endTag : nil end |
#implied_start_tag? ⇒ Boolean
89 90 91 |
# File 'lib/agio/html_element_description.rb', line 89 def implied_start_tag? @d ? @d.startTag : nil end |
#inline? ⇒ Boolean
81 82 83 |
# File 'lib/agio/html_element_description.rb', line 81 def inline? @d ? @d.isinline : nil end |
#inspect ⇒ Object
69 70 71 |
# File 'lib/agio/html_element_description.rb', line 69 def inspect "#<#{self.class.name}: #{name} #{description}>" end |
#name ⇒ Object
61 62 63 |
# File 'lib/agio/html_element_description.rb', line 61 def name @d ? @d.name : @name end |
#optional_attributes ⇒ Object
113 114 115 |
# File 'lib/agio/html_element_description.rb', line 113 def optional_attributes @d ? @d.attrs_opt : [] end |
#required_attributes ⇒ Object
121 122 123 |
# File 'lib/agio/html_element_description.rb', line 121 def required_attributes @d ? @d.attrs_req : [] end |
#save_end_tag? ⇒ Boolean
97 98 99 |
# File 'lib/agio/html_element_description.rb', line 97 def save_end_tag? @d ? @d.saveEndTag : nil end |
#sub_elements ⇒ Object
73 74 75 |
# File 'lib/agio/html_element_description.rb', line 73 def sub_elements @d ? @d.subelts : [] end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/agio/html_element_description.rb', line 65 def to_s "#{name}: #{description}" end |