Module: FriendlyFormat::NokogiriAdapter
- Defined in:
- lib/friendly_format/adapter/nokogiri_adapter.rb
Class Method Summary collapse
Class Method Details
.empty?(node) ⇒ Boolean
22 23 24 |
# File 'lib/friendly_format/adapter/nokogiri_adapter.rb', line 22 def empty? node node.children.empty? end |
.parse(html) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/friendly_format/adapter/nokogiri_adapter.rb', line 8 def parse html # root is html, children is [body], first is body # drop zzz with .children.first since it would wrap a tag p for the article Nokogiri::HTML.parse( "<zzz>#{html.gsub("\n", '
')}</zzz>", nil, # url? html.respond_to?(:encoding) ? html.encoding.name : 'utf-8' ).root.children.first.children.first end |
.to_xhtml(node) ⇒ Object
18 19 20 |
# File 'lib/friendly_format/adapter/nokogiri_adapter.rb', line 18 def to_xhtml node node.to_xhtml end |