aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2010-04-30 21:14:19 -0400
committerRalph Amissah <ralph@amissah.com>2010-04-30 21:14:19 -0400
commit719627cb3e0a416fb508a5de28eba7e7fe5576bd (patch)
treeb95baeee0fa7abe4bde0c879f1fc0a891df83e28
parentmanifest, expand on description of book indexes in manifest (diff)
shared_txt, text wrap, deal with <br> markers where they occur
-rw-r--r--lib/sisu/v2/shared_txt.rb10
1 files 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!(/<br>/,' <br> ')
@para.gsub!(/#{Mx[:br_nl]}/,"\n\n")
- words=@para.scan(/\n\n|\S+/m)
+ words=@para.scan(/\n\n|<br>|\S+/m)
while words != ''
word=words.shift
if not word
out[line] unless out[line].empty? #check
break
+ elsif word =~/<br>/
+ word="\n" + ' '*@n_indent
+ line=line
elsif word =~/\n\n/
word="\n"
@n_char_max_extend = @n_char_max + out[line].length