lib/review/textutils.rb in review-2.0.0.beta1 vs lib/review/textutils.rb in review-2.0.0
- old
+ new
@@ -11,34 +11,28 @@
add += len - 1
' ' * len
}
end
- def convert_inencoding(str, enc)
- case enc
- when /^EUC$/i
- NKF.nkf("-E -w -m0x", str)
- when /^SJIS$/i
- NKF.nkf("-S -w -m0x", str)
- when /^JIS$/i
- NKF.nkf("-J -w -m0x", str)
- when /^UTF-8$/i
- NKF.nkf("-W -w -m0x", str)
- else
- NKF.nkf("-w -m0 -m0x", str)
- end
- end
+ def split_paragraph(lines)
+ pre = pre_paragraph
+ post = post_paragraph
- def convert_outencoding(str, enc)
- case enc
- when /^EUC$/i
- NKF.nkf("-W -e -m0x", str)
- when /^SJIS$/i
- NKF.nkf("-W -s -m0x", str)
- when /^JIS$/i
- NKF.nkf("-W -j -m0x", str)
- else
- str
+ blocked_lines = [[]]
+ lines.each {|element|
+ if element == ""
+ if blocked_lines.last != []
+ blocked_lines << []
+ end
+ else
+ blocked_lines.last << element
+ end
+ }
+
+ if !pre.nil? and !post.nil?
+ blocked_lines.map!{|i| [pre] + i + [post] }
end
+
+ blocked_lines.map{|l| l.join("")}
end
end
end