Skip to content

Commit e04ebef

Browse files
author
System Administrator
committed
Interactive landing page
1 parent 473d357 commit e04ebef

File tree

5 files changed

+404
-17
lines changed

5 files changed

+404
-17
lines changed

app/models/draft.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,21 @@ def reviewify
1313
strt, brk, ul, ol, li = false, false, false, false, false
1414
chars = ["?", ",", ".", ":", ";", "...", "''", "'"]
1515
sent = sentences[i] = sent.join(" ")
16-
sent = sentences[i] = sent.gsub(/(``[^'']+$)/) {|s| "#{$1}\""}
16+
if sentences[i + 1] and sentences[i + 1].join(" ").index(/<\/p>\s+<p>/)
17+
sent = sentences[i] = sent.gsub(/([``|''][^'']+$)/) {|s| "#{$1}\""}
18+
end
1719
sent = sentences[i] = sent.gsub("`` ", ' "').gsub("--", "&mdash;")
1820
chars.each {|chr| sent = sentences[i] = sent.gsub(" " + chr, chr)}
1921
if sent.index(/<\/p>\s+<p>/)
2022
sent = sentences[i] = sent.gsub(/<\/p>\s+<p>/) {|s| ""}
2123
brk = true
2224
end
25+
if sent.index("<em>") and !sent.index("</em>")
26+
sent = sentences[i] = sent + "</em>"
27+
end
28+
if (sent.index("</em>") and sent.index("<em>") and sent.index("</em>") < sent.index("<em>")) or (sent.index("</em>") and !sent.index("<em>"))
29+
sent = sentences[i] = sent.gsub(/(<\/em>.*?\s)/, "")
30+
end
2331
if sent.index("<p>")
2432
sent = sentences[i] = sent.gsub("<p>", "")
2533
strt = true
@@ -48,10 +56,14 @@ def reviewify
4856
end
4957
end
5058
glob = HTMLEntities.new.decode(sentences.compact.join(" "))
59+
glob = glob.gsub(" n't", "n't")
60+
glob = glob.gsub(/<em> (.*?) <\/em>/) {|s| "<em>#{$1}</em>"}
61+
glob = glob.gsub(" !", "!")
5162
glob = glob.gsub(/<a class="sentence" href="#" id="sent\-\d">\.<\/a>/) {|s| ""}.gsub("</p>.", "</p>")
5263
glob = glob.gsub("< span style =", "<span class=\"heading\" style=").gsub("< \\\/ span >.", "</span>").gsub("< br >", "<br>").gsub("'' >", "\">")
5364
glob = glob.gsub("-LRB- ", "(").gsub(" -RRB-", ")")
5465
glob = glob.gsub("</p></a>", "</a></p>")
66+
glob = glob.gsub(",'' ", ", \"")
5567
return {:content => glob, :n_sentences => "0" * (sentences.length + 1)}
5668
end
5769
end

0 commit comments

Comments
 (0)