Sha256: c18a4af8390008f5dd9b65d6d3b7c1d8e5dbcc1cf4c2a35d23127fb1b7da567a
Contents?: true
Size: 526 Bytes
Versions: 1
Compression:
Stored size: 526 Bytes
Contents
require 'nokogiri' module ActionMailer module Text 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
actionmailer-textgiri-0.1.2 | lib/actionmailer-text/html_to_plain_text.rb |