Class: Hpricot::Comment
- Defined in:
- lib/hpricot/nodes.rb,
lib/hpricot/tag.rb,
lib/hpricot/modules.rb,
lib/hpricot/modules.rb
Overview
Comment and CData carry a raw_string in addition to their content, which the C extension did not. Their #content excludes the delimiters, so preserve-mode output had to reconstruct ""; for an UNTERMINATED comment there is no "-->" in the source and that reconstruction corrupts the document. The C scanner got this wrong in the other direction, dropping the opening "<!--" and losing four bytes:
input: <p>a</p><!-- never closed
C: <p>a</p> never closed (4 bytes lost)
Byte-identical round-tripping is this library's reason to exist, so the raw span is kept and emitted verbatim. For well-formed comments the two are the same string, so nothing else changes.
Defined Under Namespace
Modules: Trav
Constant Summary
Constants included from Hpricot
AttrCore, AttrEvents, AttrFocus, AttrHAlign, AttrI18n, AttrVAlign, Attrs, ElementContent, ElementExclusions, ElementInclusions, FORM_TAGS, NamedCharacters, NamedCharactersPattern, OmittedAttrName, SELF_CLOSING_TAGS
Instance Attribute Summary collapse
-
#raw_string ⇒ Object
See CData#raw_string: the recorded span wins, because an unterminated comment has no "-->" to reconstruct.
Attributes inherited from BasicNode
Instance Method Summary collapse
Methods included from Leaf::Trav
#traverse_all_element, #traverse_some_element, #traverse_text_internal
Methods included from Traverse
#after, #at, #before, #bogusetag?, #children_of_type, #clean_path, #comment?, #css_path, #doc?, #doctype?, #elem?, filter, #following, #get_subnode, #html, #index, #inner_html=, #inner_text, #make, #next, #node_position, #nodes_at, #position, #preceding, #previous, #procins?, #search, #swap, #text?, #to_html, #to_original_html, #to_plain_text, #traverse_element, #traverse_text, #xmldecl?, #xpath
Methods included from Leaf
Methods included from Node
#altered!, #html_quote, #if_output, #inspect_tree
Methods included from Hpricot
Instance Attribute Details
#raw_string ⇒ Object
See CData#raw_string: the recorded span wins, because an unterminated comment has no "-->" to reconstruct.
247 |
# File 'lib/hpricot/tag.rb', line 247 def raw_string; @raw_string || "<!--#{content}-->" end |
Instance Method Details
#clear_raw ⇒ Object
58 59 60 |
# File 'lib/hpricot/nodes.rb', line 58 def clear_raw self.raw_string = nil end |
#output(out, opts = {}) ⇒ Object
248 249 250 251 252 253 |
# File 'lib/hpricot/tag.rb', line 248 def output(out, opts = {}) out << if_output(opts) do "<!--#{content}-->" end end |
#pathname ⇒ Object
244 |
# File 'lib/hpricot/tag.rb', line 244 def pathname; "comment()" end |