adjust html to text
This commit is contained in:
@@ -10,7 +10,7 @@ module HtmlToPlainText
|
|||||||
|
|
||||||
doc = Nokogiri::HTML.fragment(cleaned)
|
doc = Nokogiri::HTML.fragment(cleaned)
|
||||||
|
|
||||||
doc.css('script').each(&:remove)
|
doc.xpath('.//script').each(&:remove)
|
||||||
|
|
||||||
result = process_nodes(doc, line_length)
|
result = process_nodes(doc, line_length)
|
||||||
|
|
||||||
@@ -33,12 +33,9 @@ module HtmlToPlainText
|
|||||||
result = +''
|
result = +''
|
||||||
|
|
||||||
node.children.each do |child|
|
node.children.each do |child|
|
||||||
case child
|
if child.text? || child.cdata?
|
||||||
when Nokogiri::XML::Text
|
|
||||||
result << child.text
|
result << child.text
|
||||||
when Nokogiri::XML::Comment
|
elsif child.element?
|
||||||
next
|
|
||||||
when Nokogiri::XML::Element
|
|
||||||
result << process_element(child, line_length)
|
result << process_element(child, line_length)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user