Skip to content

Instantly share code, notes, and snippets.

@j-manu
Created December 3, 2011 21:50
Show Gist options
  • Save j-manu/1428254 to your computer and use it in GitHub Desktop.
Save j-manu/1428254 to your computer and use it in GitHub Desktop.
doc = Nokogiri::HTML(doc,nil,'UTF-8')
doc.search('script').remove
doc.search('meta').remove
doc.search('style').remove
doc.search('link').remove
doc.search('base').remove
doc.search('iframe').remove
doc.search('embed').remove
doc.search('object').remove
doc.css("a.blippr-inline-smiley").remove
doc.xpath('//@href|//@src').each do |link|
unless link.value =~ /^(http|mailto|javascript)/i
begin
link.value = URI.join(print.url, URI.encode(link.value)).to_s
rescue Exception => e
next
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment