aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/shared_txt.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v0/shared_txt.rb')
-rw-r--r--lib/sisu/v0/shared_txt.rb31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb
index ceeaa4ce..6af436b0 100644
--- a/lib/sisu/v0/shared_txt.rb
+++ b/lib/sisu/v0/shared_txt.rb
@@ -58,6 +58,7 @@ module SiSU_text_utils
class Wrap
def initialize(para='',n_char_max=76,n_indent=0,n_hang=nil)
@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
@@ -69,21 +70,33 @@ module SiSU_text_utils
line=0
out=[]
out[line]=''
- #line=0,out,out[line]=0,[],''
- #@para.gsub!(/<br(?: \/)?>/,"\n") #watch #added
- words=@para.scan(/\S+/)
+ @para.gsub!(/<:br>/,"\n\n")
+ words=@para.scan(/\n\n|\S+/m)
while words != ''
word=words.shift
if not word
- out[line].strip!.squeeze!(' ') unless out[line].empty? #check
+ out[line] unless out[line].empty? #check
break
- elsif (out[line].length + word.length) > (@n_char_max - @n_indent) and out[line] =~/\S+/
- out[line].strip!.squeeze!(' ')
+ elsif word =~/\n\n/
+ word="\n"
+ @n_char_max_extend = @n_char_max + out[line].length
+ line=line
+ elsif (out[line].length + word.length) > (@n_char_max_extend - @n_indent) and out[line] =~/\S+/
+ @n_char_max_extend = @n_char_max
+ out[line].squeeze!(' ')
line += 1
end
- out[line]="#{out[line]} #{word}" if word
+ if word
+ out[line]=if out[line] and out[line] !~/\S+$/m
+ "#{out[line]}#{word}"
+ elsif out[line] and out[line] =~/\S+/
+ "#{out[line]} #{word}"
+ else "#{word.strip}"
+ end
+ end
+ @oldword=word if word =~/\S+/
end
- out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang)
+ x=out.join(spaces_indent).gsub(/\A\n+/m,'').insert(0,spaces_hang)
end
def line_wrap_indent1
@n_indent,@n_hang=2,2
@@ -94,8 +107,6 @@ module SiSU_text_utils
line_wrap
end
end
-#end
-#module SiSU_scan
class Header_scan
def initialize(md,para)
@regxcl=/<~\d+;\w\d+;\w\d+><(?:[0-9a-f]{32}|[0-9a-f]{64}):(?:[0-9a-f]{32}|[0-9a-f]{64})>/