aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/plaintext.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-10-15 19:27:16 +0100
committerRalph Amissah <ralph@amissah.com>2007-10-15 19:27:16 +0100
commite1ec4bd2dad2bd22ad97cea398ae1cfcfae183a2 (patch)
tree6ffe3ae1b2453578a032ce053934a31f980645e9 /lib/sisu/v0/plaintext.rb
parentregex matching of images, (and rearrangement of conditionals) (diff)
mostly the arrangement of conditionals
Diffstat (limited to 'lib/sisu/v0/plaintext.rb')
-rw-r--r--lib/sisu/v0/plaintext.rb46
1 files changed, 31 insertions, 15 deletions
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('<br /><a name="metadata">MetaData</a>')
#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('<br /><a name="owner.details">Owner Details</a>')
#@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 =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote
+ para='' if (para =~/<a name="n\d+">/ \
+ and para =~/^(-\{{2}~\d+|<!e[:_]\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