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(-) (limited to 'lib/sisu/v2/shared_txt.rb') 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 From 78e75a4cb1a2e959c1a960be5659219a241d461f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 3 May 2010 17:29:14 -0400 Subject: shared_txt, text wrap,
related, revert, issues when indented, revisit --- lib/sisu/v2/shared_txt.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/sisu/v2/shared_txt.rb') diff --git a/lib/sisu/v2/shared_txt.rb b/lib/sisu/v2/shared_txt.rb index 1e77acb7..abf5e035 100644 --- a/lib/sisu/v2/shared_txt.rb +++ b/lib/sisu/v2/shared_txt.rb @@ -79,7 +79,8 @@ module SiSU_text_utils out[line] unless out[line].empty? #check break elsif word =~/
/ - word="\n" + ' '*@n_indent + word=nil + out[line]=out[line].gsub(/
/,'') line=line elsif word =~/\n\n/ word="\n" -- cgit v1.2.3