Class: PrettyXML::XHTML
- Inherits:
-
PrettyPrint
- Object
- PrettyPrint
- PrettyXML::XHTML
- Defined in:
- lib/printers/xhtml.rb
Constant Summary collapse
- VOID =
%w(area base br col embed hr img input keygen link meta param source track wbr)
Instance Attribute Summary
Attributes inherited from PrettyPrint
Instance Method Summary collapse
- #explicit_closing_tags ⇒ Object
-
#initialize(options) ⇒ XHTML
constructor
A new instance of XHTML.
- #parsed_doc?(doc) ⇒ Boolean
- #verify_doc(doc) ⇒ Object
Methods inherited from PrettyPrint
Constructor Details
#initialize(options) ⇒ XHTML
Returns a new instance of XHTML.
5 6 7 8 9 10 11 |
# File 'lib/printers/xhtml.rb', line 5 def initialize() @elements = PrettyXML.load_config('xhtml.yml') [:close_tags] = [:control_chars] = :hex .merge!(@elements) super end |
Instance Method Details
#explicit_closing_tags ⇒ Object
13 14 15 |
# File 'lib/printers/xhtml.rb', line 13 def @elements.values.flatten - VOID end |
#parsed_doc?(doc) ⇒ Boolean
17 18 19 |
# File 'lib/printers/xhtml.rb', line 17 def parsed_doc?(doc) doc.is_a?(Nokogiri::HTML::Document) or doc.is_a?(Nokogiri::XML::Document) end |
#verify_doc(doc) ⇒ Object
21 22 23 |
# File 'lib/printers/xhtml.rb', line 21 def verify_doc(doc) parsed_doc?(doc) ? doc.to_xml : doc end |