From 719627cb3e0a416fb508a5de28eba7e7fe5576bd Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 30 Apr 2010 21:14:19 -0400 Subject: shared_txt, text wrap, deal with
markers where they occur --- lib/sisu/v2/shared_txt.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/sisu/v2/shared_txt.rb b/lib/sisu/v2/shared_txt.rb index 9d35743b..1e77acb7 100644 --- a/lib/sisu/v2/shared_txt.rb +++ b/lib/sisu/v2/shared_txt.rb @@ -62,9 +62,7 @@ module SiSU_text_utils @para,@n_char_max,@n_indent=para,n_char_max,n_indent @n_char_max_extend = n_char_max @br="\n" - @n_hang=unless n_hang; @n_hang=@n_indent - else n_hang - end + @n_hang=n_hang ? n_hang : @n_indent end def line_wrap space=' ' @@ -72,13 +70,17 @@ module SiSU_text_utils line=0 out=[] out[line]='' + @para.gsub!(/
/,'
') @para.gsub!(/#{Mx[:br_nl]}/,"\n\n") - words=@para.scan(/\n\n|\S+/m) + words=@para.scan(/\n\n|
|\S+/m) while words != '' word=words.shift if not word out[line] unless out[line].empty? #check break + elsif word =~/
/ + word="\n" + ' '*@n_indent + line=line elsif word =~/\n\n/ word="\n" @n_char_max_extend = @n_char_max + out[line].length -- cgit v1.2.3