Last active
December 17, 2015 04:29
-
-
Save JKring/5550800 to your computer and use it in GitHub Desktop.
GIST OF TEH DAY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b.finished_jobs.where(id: { "$nin" => ids }).each do |j| | |
d = j.document | |
puts "scripted.com/documents/show/#{ d.id }" | |
d.save_file("Cleaned Up") | |
@new_c = [] | |
d.content.each do |c| | |
begin | |
c.gsub!("\n", " ") | |
c.strip! | |
@splitup = c.split(">") | |
@opentag = @splitup.first.gsub("<","") | |
@closetag = @opentag.split(" ").first | |
while Regexp.new(/^<#{ @opentag }>( ?)+<\/#{ @closetag }>/).match(c) | |
c.gsub!(/^<#{ @opentag }>( ?)+<\/#{ @closetag }>/, "") | |
@splitup = c.split(">") | |
@opentag = @splitup.first.gsub("<","") | |
@closetag = @opentag.split(" ").first | |
end | |
r = Regexp.new(/^<#{ @opentag }>(.*?)<\/#{ @closetag }>/) | |
c.gsub!(r, "<h1>" + r.match(c)[1].gsub(/<\/?[^>]*>/, "") + "</h1>") | |
c.gsub!("<h2>", "<h3>") | |
c.gsub!("</h2>", "</h3>") | |
@new_c << c | |
rescue | |
puts "FAIL!!: #{ d.id }" | |
end | |
end | |
d.save_temp(@new_c) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment