Top Level Namespace
Defined Under Namespace
Modules: HashRecursiveMerge, Qipowl, TypoLogging Classes: Array, Fixnum, Hash, Object, String, Symbol
Instance Method Summary collapse
Instance Method Details
#postpare(str) ⇒ Object
168 169 170 171 172 |
# File 'lib/qipowl/bowlers/htmldoc.rb', line 168 def postpare str str.gsub(/\R{2,}/, "\n\n") .gsub(/\A(\s|⏎)*/, '') .gsub(/(\s|⏎)*\Z/, '') end |
#prepare(str) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/qipowl/bowlers/htmldoc.rb', line 146 def prepare str str.gsub(/&[nm]dash;/, '—') # dashes .gsub(/ /, ' ') # dashes .gsub(/\s+--\s+/, ' — ') # dashes .gsub(/^\s*/, '') # leading spaces .gsub(/<img src="\/i\/>/, '') .gsub(/™/, '™') # other entities .gsub(/©/, '©') # other entities .gsub(/([email protected]|[email protected])/, '[email protected]') .gsub(/http:\/\/(www\.)?(secondiary|1stone|matiouchkine.net)\.ru/, 'http://mudasobwa.ru') # obsolete site name .gsub(/\[(http[^\]]*)\]/, '\1') # obsolete markdown pics .gsub(/<span>\s*<\/span>/, 'λ\1λ') # obsolete markdown pics .gsub(/<lj (?:comm|user)="(.*?)">/, '✎ \1') # obsolete markdown pics .gsub(/<([^<>]*?@[^<>]*?)>/, '\1') # obsolete markdown pics .gsub(/<imgsrc=/, '<img src=') # obsolete markdown pics .gsub(/<ahref=/, '<a href=') # obsolete markdown pics .gsub(/<\/p>\s*<p>\s*—/, " ⏎\n—") # direct speech .gsub(/<br(?:\s*\/?\s*)>\s*<br(?:\s*\/?\s*)>/, "\n\n") # old-fashioned carriage .gsub(/<[!]--[^<>]*?-->/, '') # comments # .gsub(/([\.,:;!?])(?=\S)/, '\1 ') # fix punctuation end |