From e1ec4bd2dad2bd22ad97cea398ae1cfcfae183a2 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 15 Oct 2007 19:27:16 +0100 Subject: mostly the arrangement of conditionals --- lib/sisu/v0/plaintext.rb | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'lib/sisu/v0/plaintext.rb') diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 86a17089..18486803 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -71,11 +71,17 @@ module SiSU_Plaintext def initialize(opt) @opt=opt @@dostype=if @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/ - if @opt.mod.inspect =~ /--footnote/ and @opt.mod.inspect =~ /--dos/; 'msdos footnotes' - elsif @opt.mod.inspect =~ /--endnote/ and @opt.mod.inspect =~ /--dos/; 'msdos endnotes' - elsif @opt.mod.inspect =~ /--footnote/; 'unix footnotes' - elsif @opt.mod.inspect =~ /--endnote/; 'unix endnotes' - else 'unix footnotes' + if @opt.mod.inspect =~ /--footnote/ \ + and @opt.mod.inspect =~ /--dos/ + 'msdos footnotes' + elsif @opt.mod.inspect =~ /--endnote/ \ + and @opt.mod.inspect =~ /--dos/ + 'msdos endnotes' + elsif @opt.mod.inspect =~ /--footnote/ + 'unix footnotes' + elsif @opt.mod.inspect =~ /--endnote/ + 'unix endnotes' + else 'unix footnotes' end else puts "#{sf} not a processed file type" end @@ -162,10 +168,12 @@ module SiSU_Plaintext @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m # 2004w18 pb pn removal added @tab="\t" - @br=if md.mod.inspect =~ /--footnote/ and md.mod.inspect =~ /--dos/ + @br=if md.mod.inspect =~ /--footnote/ \ + and md.mod.inspect =~ /--dos/ @@dostype='msdos footnotes' "\r\n" - elsif md.mod.inspect =~ /--endnote/ and md.mod.inspect =~ /--dos/ + elsif md.mod.inspect =~ /--endnote/ \ + and md.mod.inspect =~ /--dos/ @@dostype='msdos endnotes' "\r\n" elsif md.mod.inspect =~ /--footnote/ @@ -291,10 +299,12 @@ WOK else @plaintext[:body] << wrapped << @br # main text, contents, body KEEP end - if @@endnotes[:para] and @@dostype =~/footnote/ #edit out to switch off endnotes following paragraph to which they belong + if @@endnotes[:para] \ + and @@dostype =~/footnote/ #edit out to switch off endnotes following paragraph to which they belong @plaintext[:body] << @br @@endnotes[:para].each {|e| @plaintext[:body] << e << @br} - elsif @@endnotes[:para] and @@dostype =~/endnote/ + elsif @@endnotes[:para] \ + and @@dostype =~/endnote/ @plaintext[:body] << @br*2 end @@endnotes[:para]=[] @@ -365,7 +375,8 @@ WOK @sto=Split_text_object.new(para).lev_segname_para_ocn ### problem in scroll, it appears tables are getting paragraph numbers m=/<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - if para =~m and para=~/\S+/ + if para =~m \ + and para=~/\S+/ para=case @sto.format when /^(1)~(?:(\S+))?/ plaintext_structure(para,$1,@sto.ocn,$2) @@ -410,11 +421,14 @@ WOK end elsif para =~/#{table_message}/ @plaintext[:body] << para << @br - elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - elsif para =~/(MetaData)/ and para =~/<~(\d+);[um]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info ####suspect visit + elsif para =~/(Note|Endnotes?)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(MetaData)/ \ + and para =~/<~(\d+);[um]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info ####suspect visit #formatMono=MonoSiSU.new('
MetaData') #para=formatMono.bold_para - elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para.include? 'Owner Details' \ + and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #formatMono=MonoSiSU.new('
Owner Details') #@plaintext[:owner_details]=formatMono.bold_para #para='' @@ -424,7 +438,8 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if (para =~// and para =~/^(-\{{2}~\d+|)/) # -endnote + para='' if (para =~// \ + and para =~/^(-\{{2}~\d+|)/) # -endnote case para when /<:i[1-9]>/ if para =~/.*<:#>.*$/m @@ -473,7 +488,8 @@ WOK filename_plaintext=SiSU_Env::SiSU_file.new(@md,@md.fn[:plain]).mkfile @sisu=[] @content.each do |para| # this is a hack - if para.class == Array and para.length > 0 + if para.class == Array \ + and para.length > 0 para.each do |line| line.gsub!(/\s+$/m,'') filename_plaintext.puts line #unix plaintext -- cgit v1.2.3