Sha256: 1321ecc4809c85a3a0c3c84d8f0b99d79537818b66ba581e3fcc2571a8cc6b66
Contents?: true
Size: 530 Bytes
Versions: 2
Compression:
Stored size: 530 Bytes
Contents
require 'nokogiri' module ActionMailer module Textgiri module HtmlToPlainText def convert_to_text(html_body) body_parts = [] Nokogiri::HTML(html_body).traverse do |node| if node.text? and !(content = node.content ? node.content.strip : nil).empty? body_parts << content elsif node.name == "a" && (href = node.attr("href")) && href.match(/^https?:/) body_parts << href end end body_parts.uniq.join("\n") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
actionmailer-textgiri-0.2.1 | lib/actionmailer-textgiri/html_to_plain_text.rb |
actionmailer-textgiri-0.2 | lib/actionmailer-textgiri/html_to_plain_text.rb |