From 4ef892c96f0e707085789ae4f2082565a9363c71 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 15 Oct 2007 11:06:50 +0100 Subject: remote server configuration info set in sisurc.yml for multiple hosts, sysenv and help sisurc.yml remote host settings takes both old and new configuration notation new being through use of Array for each host '-' separator, [example is provided] --- lib/sisu/v0/help.rb | 44 ++++++++++++++++++++++++++++++++++++++++++-- lib/sisu/v0/sysenv.rb | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/help.rb b/lib/sisu/v0/help.rb index e9f3906b..50539d9d 100644 --- a/lib/sisu/v0/help.rb +++ b/lib/sisu/v0/help.rb @@ -1015,6 +1015,47 @@ WOK else puts 'SiSU version information not available' end end + def rhost + @ls=leading_spaces=' '*49 + @rhost=SiSU_Env::Info_remote_host.new.rhost + def r1 + if @rhost.r1; @rhost.r1 + "\n" + else '' + end + end + def r2 + if @rhost.r2; @ls + @rhost.r2 + "\n" + else '' + end + end + def r3 + if @rhost.r3; @ls + @rhost.r3 + "\n" + else '' + end + end + def r4 + if @rhost.r4; @ls + @rhost.r4 + "\n" + else '' + end + end + def r5 + if @rhost.r5; @ls + @rhost.r5 + "\n" + else '' + end + end + def r6 + if @rhost.r6; @ls + @rhost.r6 + "\n" + else '' + end + end + def note + msg='(remote settings user and host set in sisurc.yml under remote:)' + if @rhost.r1; @ls + msg + else msg + end + end + self + end def environment cf_defaults=SiSU_Env::Info_processing_flag.new sisu_version @@ -1022,8 +1063,7 @@ WOK #{@cX.green}current and output directories#{@cX.off} user: #{@cX.blue}#{@env.user}#{@cX.off} home: #{@cX.blue}#{@env.path.home}#{@cX.off} - remote set [remote user]@[remote host]: #{@cX.blue}#{SiSU_Env::Info_remote_host.new.remote_host[:name]}#{@cX.off} - (remote settings user and host set in sisurc.yml under remote:) + remote set [remote user]@[remote host]: #{@cX.blue}#{rhost.r1}#{rhost.r2}#{rhost.r3}#{rhost.r4}#{rhost.r5}#{rhost.r6}#{@cX.off}#{rhost.note} locale (encoding, UTF-8 desired): #{@cX.blue}#{@env.locale}#{@cX.off} current directory: #{@cX.blue}#{@env.path.pwd}#{@cX.off} document output root directory set to: #{@cX.blue}#{@env.path.webserv}#{@cX.off} diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index 510324c7..a06af89d 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -2021,15 +2021,17 @@ WOK end r elsif (defined? @rc['remote'] and @rc['remote'].class==Hash and defined? @rc['remote']['user'] and defined? @rc['remote']['host']) + r[0]={} r[0][:user]=@rc['remote']['user'] r[0][:host]=@rc['remote']['host'] r[0][:path]=if defined? @rc['remote']['path'] @rc['remote']['path'] else '' end - r[0][:name]="#{r[:user]}@#{r[:host]}:#{r[:path]}" + r[0][:name]="#{r[0][:user]}@#{r[0][:host]}:#{r[0][:path]}" r else + r[0]={} r[0][:name]='.' r[0][:user]='' r[0][:host]='' @@ -2038,6 +2040,45 @@ WOK r end end + def rhost + def r1 + rhost1=if defined? SiSU_Env::Info_remote_host.new.remote_host[0][:name] + SiSU_Env::Info_remote_host.new.remote_host[0][:name] + else nil + end + end + def r2 + rhost2=if defined? SiSU_Env::Info_remote_host.new.remote_host[1][:name] + SiSU_Env::Info_remote_host.new.remote_host[1][:name] + else nil + end + end + def r3 + rhost3=if defined? SiSU_Env::Info_remote_host.new.remote_host[2][:name] + SiSU_Env::Info_remote_host.new.remote_host[2][:name] + else nil + end + end + def r4 + rhost4=if defined? SiSU_Env::Info_remote_host.new.remote_host[3][:name] + SiSU_Env::Info_remote_host.new.remote_host[3][:name] + else nil + end + end + def r5 + rhost5=if defined? SiSU_Env::Info_remote_host.new.remote_host[4][:name] + SiSU_Env::Info_remote_host.new.remote_host[4][:name] + else nil + end + end + def r6 + rhost6=if defined? SiSU_Env::Info_remote_host.new.remote_host[5][:name] + @ls + SiSU_Env::Info_remote_host.new.remote_host[5][:name] + else nil + end + end + self + end end class Info_remote < File_map @@flag_remote=false -- cgit v1.2.3 From 33adab3a3b496ca4b654eda0f033e9ed77c0371b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 15 Oct 2007 19:13:31 +0100 Subject: remote_conn, accepting multiple remote hosts, sysenv also beginning of rearrangement of conditionals --- lib/sisu/v0/embedded.rb | 51 ++-- lib/sisu/v0/sysenv.rb | 634 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 458 insertions(+), 227 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/embedded.rb b/lib/sisu/v0/embedded.rb index 22835e8f..b5d33ac2 100644 --- a/lib/sisu/v0/embedded.rb +++ b/lib/sisu/v0/embedded.rb @@ -83,13 +83,16 @@ module SiSU_Embedded def images src="#{Dir.pwd}/_sisu/image" ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" - rdest="#@rhost/#{@env.path.stub_pwd}/_sisu/image" - if @md.cmd.inspect =~/[vVMR]/ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:image].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync - if @md.cmd.inspect =~/R/ #rsync to remote image directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + @rhost.each do |remote_conn| + rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/image" + if @md.cmd.inspect =~/[vVMR]/ \ + and FileTest.directory?(src) + File.mkpath(ldest) unless FileTest.directory?(ldest) + src_ec="#{src}/" + @md.ec[:image].join(" #{src}/") + SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + if @md.cmd.inspect =~/R/ #rsync to remote image directory + SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + end end end end @@ -97,13 +100,16 @@ module SiSU_Embedded #p @md.ec[:audio] src="#{Dir.pwd}/_sisu/mm/audio" ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/mm/audio" - rdest="#@rhost/#{@env.path.stub_pwd}/_sisu/mm/audio" - if @md.cmd.inspect =~/[vVMR]/ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync - if @md.cmd.inspect =~/R/ #rsync to remote audio directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + @rhost.each do |remote_conn| + rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/audio" + if @md.cmd.inspect =~/[vVMR]/ \ + and FileTest.directory?(src) + File.mkpath(ldest) unless FileTest.directory?(ldest) + src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") + SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + if @md.cmd.inspect =~/R/ #rsync to remote audio directory + SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + end end end end @@ -111,13 +117,16 @@ module SiSU_Embedded #p @md.ec[:multimedia] src="#{Dir.pwd}/_sisu/mm/video" ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/mm/video" - rdest="#@rhost/#{@env.path.stub_pwd}/_sisu/mm/video" - if @md.cmd.inspect =~/[vVMR]/ and FileTest.directory?(src) - File.mkpath(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") - SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync - if @md.cmd.inspect =~/R/ #rsync to remote video directory - SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + @rhost.each do |remote_conn| + rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/mm/video" + if @md.cmd.inspect =~/[vVMR]/ \ + and FileTest.directory?(src) + File.mkpath(ldest) unless FileTest.directory?(ldest) + src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") + SiSU_Env::System_call.new(src_ec,"#{ldest}/.",'q').rsync + if @md.cmd.inspect =~/R/ #rsync to remote video directory + SiSU_Env::System_call.new(src_ec,"#{rdest}/.",'q').rsync + end end end end diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index a06af89d..e5c2c394 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -101,9 +101,11 @@ module SiSU_Env prcss_dir='_sisu_processing' prcss_dir_tmp_root="/tmp/#{prcss_dir}" prcss_dir_stub="#{prcss_dir}/#{@stub_pwd}" - @processing_dir=if @@home and File.writable?("#{@@home}/."); "#{@@home}/#{prcss_dir_stub}" + @processing_dir=if @@home \ + and File.writable?("#{@@home}/.") + "#{@@home}/#{prcss_dir_stub}" #elsif File.writable?("#{@@pwd}/."); "#{@@pwd}/#{prcss_dir}" - else prcss_dir_stub + else prcss_dir_stub end tmp_processing_base=if @@user; "#{prcss_dir_tmp_root}/#{@@user}/#{@stub_pwd}" else "#{prcss_dir_stub}" @@ -115,7 +117,11 @@ module SiSU_Env else "/tmp/#{prcss_dir_stub}" end user=ENV['USER'] - port_pgsql=if defined? ENV['PGPORT'] and not (ENV['PGPORT'].nil? or ENV['PGPORT'].empty?) and ENV['PGPORT']=~/^\d+$/; ENV['PGPORT'] + port_pgsql=if defined? ENV['PGPORT'] \ + and not (ENV['PGPORT'].nil? \ + or ENV['PGPORT'].empty?) \ + and ENV['PGPORT']=~/^\d+$/ + ENV['PGPORT'] else '5432' end IMAGES=:images @@ -230,7 +236,9 @@ module SiSU_Env break end end - if load_prog and @prog=~/dbi/; require 'dbi' #revisit + if load_prog \ + and @prog=~/dbi/ + require 'dbi' #revisit end if load_prog; require @prog else @@ -269,7 +277,8 @@ module SiSU_Env def yamlrc unless @@rc @yamlrc_path.each do |v| - if @@noyaml or FileTest.exist?("#{v}/noyaml") + if @@noyaml \ + or FileTest.exist?("#{v}/noyaml") puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml @@noyaml=true break @@ -298,7 +307,8 @@ module SiSU_Env def ads #WORK AREA tell_no_yaml='WARNING - YAML loading switched off, to enable delete the file:' @ad_path.each do |v| - if @@noyaml or FileTest.exist?("#{v}/noyaml") + if @@noyaml \ + or FileTest.exist?("#{v}/noyaml") puts tell_no_yaml + "\n\t#{v}/noyaml\n" unless @@noyaml @@noyaml=true break @@ -317,7 +327,8 @@ module SiSU_Env end end @ad_path.each do |v| - if @@noyaml or FileTest.exist?("#{v}/noyaml") + if @@noyaml \ + or FileTest.exist?("#{v}/noyaml") puts tell_no_yaml + "\n\t#{v}/noyaml\n" unless @@noyaml @@noyaml=true break @@ -348,10 +359,13 @@ module SiSU_Env @sys=Info_system.instance @rc=Get_init.instance.yamlrc @ad=Get_init.instance.ads - if @fns and @fns != '' and @fns !=@@fns + if @fns \ + and @fns != '' \ + and @fns !=@@fns @@fns,@@fnn,@@fnb,@@fnt,@@flv,@@fnz=@fns,nil,nil,nil,nil,nil end - if @fns and @fns != '' #watch + if @fns \ + and @fns != '' #watch if multilingual m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst|ssm)$/ @@fnn ||=@fns[m,1] @@ -373,13 +387,16 @@ module SiSU_Env @fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz end def multilingual - if defined? @rc['default']['multilingual'] and @rc['default']['multilingual'] != nil; @rc['default']['multilingual'] - else true + if defined? @rc['default']['multilingual'] \ + and @rc['default']['multilingual'] != nil + @rc['default']['multilingual'] + else true end end def document_language_versions_found @fn={} - unless (@fns.nil? or @fns.empty?) + unless (@fns.nil? \ + or @fns.empty?) if multilingual m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst$)/ @fn[:b],@fn[:m],@fn[:t]=@fns[m,1],@fns[m,2],@fns[m,3] @@ -409,7 +426,8 @@ module SiSU_Env ob=output_base @fn={} @m=[] - unless (@fns.nil? or @fns.empty?) + unless (@fns.nil? \ + or @fns.empty?) if multilingual m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst$)/ @fn[:b],@fn[:m],@fn[:t]=@fns[m,1],@fns[m,2],@fns[m,3] @@ -510,7 +528,9 @@ module SiSU_Env if program_found?(program) encoding=%x{file #{fnsp}}.strip encoding.gsub!(/#{fnsp}:(\s+|$)/,'') - encoding=if encoding and not encoding.empty?; encoding + encoding=if encoding \ + and not encoding.empty? + encoding else 'UTF-8 assumed, encoding undetermined' end puts encoding if cmd =~/[VM]/ @@ -520,7 +540,9 @@ module SiSU_Env end def wc #word count program='wc' - if program_found?(program) and locale !~/utf-?8/i; true + if program_found?(program) \ + and locale !~/utf-?8/i + true else program_ref="(not available)" unless program_found?(program) program_ref="(UTF-8)" if locale =~/utf-?8/i @@ -764,9 +786,14 @@ module SiSU_Env super() #you may not want to re-execute this tatic info so frequently! @fns,@md=fns,md @env=Env_call.new(fns) if fns - fnb=if @md and defined? @md.fnb; @md.fnb - elsif defined? @env.fnb and @env.fnb; @env.fnb - elsif not @fns.nil? and not @fns.empty? + fnb=if @md \ + and defined? @md.fnb + @md.fnb + elsif defined? @env.fnb \ + and @env.fnb + @env.fnb + elsif not @fns.nil? \ + and not @fns.empty? m=/(.+)?\.(?:(?:-|ssm\.)?sst|ssm)$/m @fns[m,1] if not @fns.empty? end @@ -799,7 +826,8 @@ module SiSU_Env @sys.locale end def concord_max - concord_max=if defined? @rc['processing']['concord_max'] and @rc['processing']['concord_max'] + concord_max=if defined? @rc['processing']['concord_max'] \ + and @rc['processing']['concord_max'] @rc['processing']['concord_max'] else defaults[:concord_max] end @@ -826,7 +854,10 @@ module SiSU_Env # doc [relevant skin if any other than default] # image [all images for specific document gathered here] sisupod_processing_path="#{path.processing}/sisupod" - rm_rf(sisupod_processing_path) if FileTest.directory?(sisupod_processing_path) or FileTest.file?(sisupod_processing_path) + if FileTest.directory?(sisupod_processing_path) \ + or FileTest.file?(sisupod_processing_path) + rm_rf(sisupod_processing_path) + end paths=[] paths=["#{path.processing}/sisupod/_sisu/skin/doc","#{path.processing}/sisupod/_sisu/skin/dir","#{path.processing}/sisupod/_sisu/skin/site","#{path.processing}/sisupod/_sisu/image"] paths.each {|x| File.mkpath(x) unless FileTest.directory?(x) } @@ -846,10 +877,15 @@ module SiSU_Env @flag[:ad]=if @md.flag_promo && @ad[:flag_promo] @flag[:md]=true true - elsif defined? @vz.widget_promo and not @vz.widget_promo.nil? and @vz.widget_promo.class == Array and @vz.widget_promo.length > 0 + elsif defined? @vz.widget_promo \ + and not @vz.widget_promo.nil? \ + and @vz.widget_promo.class == Array \ + and @vz.widget_promo.length > 0 @flag[:sk]=true true - elsif defined? @rc['promo'] and not @rc['promo'].nil? and @rc['promo'].length > 0 + elsif defined? @rc['promo'] \ + and not @rc['promo'].nil? \ + and @rc['promo'].length > 0 @flag[:rc]=true true else @@ -862,16 +898,17 @@ module SiSU_Env flag=false if defined? @rc['search'] searches.each do |type| - flag=if defined? @rc['search'][type] and - defined? @rc['search'][type]['action'] and - @rc['search'][type]['flag']==true and - @rc['search'][type]['action'] =~/https?:\/\// #and - #defined? @rc['search'][type]['db'] and @rc['search'][type]['db'] =~/\S+/ # and + flag=if defined? @rc['search'][type] \ + and defined? @rc['search'][type]['action'] \ + and @rc['search'][type]['flag']==true \ + and @rc['search'][type]['action'] =~/https?:\/\// flag=if promo?[:ad] false - elsif defined? @vz.widget_search and @vz.widget_search == true + elsif defined? @vz.widget_search \ + and @vz.widget_search == true true - elsif defined? @rc['search'][type]['flag'] and @rc['search'][type]['flag'] == true + elsif defined? @rc['search'][type]['flag'] \ + and @rc['search'][type]['flag'] == true true else false end @@ -887,14 +924,18 @@ module SiSU_Env searches=['sisu','hyperestraier'] flag=if defined? @rc['search'] searches.each do |type| - if defined? @rc['search'][type] and - defined? @rc['search'][type]['action'] and @rc['search'][type]['action'] =~/https?:\/\// and - defined? @rc['search'][type]['db'] and @rc['search'][type]['db'] =~/\S+/ # and + if defined? @rc['search'][type] \ + and defined? @rc['search'][type]['action'] \ + and @rc['search'][type]['action'] =~/https?:\/\// \ + and defined? @rc['search'][type]['db'] \ + and @rc['search'][type]['db'] =~/\S+/ flag=if promo?[:ad] false - elsif defined? @vz.widget_search and @vz.widget_search == true + elsif defined? @vz.widget_search \ + and @vz.widget_search == true true - elsif defined? @rc['search'][type]['flag'] and @rc['search'][type]['flag'] == true + elsif defined? @rc['search'][type]['flag'] \ + and @rc['search'][type]['flag'] == true true else false end @@ -906,17 +947,24 @@ module SiSU_Env end def search_form(type='sisusearch',action=nil,db=nil,table=false) rc=SiSU_Env::Get_init.instance.yamlrc - create_form_hyperestraier=if defined? rc['search']['sisu']['flag'] and - rc['search']['sisu']['flag']==true and - action and action =~/https?:\/\//; true + create_form_hyperestraier=if defined? rc['search']['sisu']['flag'] \ + and rc['search']['sisu']['flag']==true \ + and action \ + and action =~/https?:\/\// + true else false end - create_form_sisu=if action and db and action =~/https?:\/\// and db =~/\S+/ + create_form_sisu=if action \ + and db \ + and action =~/https?:\/\// \ + and db =~/\S+/ true elsif widget.search? - db=if rc['search']['sisu']['flag']==true and - rc['search']['sisu']['db']=~/\S+/ - rc['search']['sisu']['db']=~/^SiSU_\S+/ ? rc['search']['sisu']['db'] : "SiSU_#{rc['search']['sisu']['db']}" + db=if rc['search']['sisu']['flag']==true \ + and rc['search']['sisu']['db']=~/\S+/ + rc['search']['sisu']['db']=~/^SiSU_\S+/ \ + ? rc['search']['sisu']['db'] \ + : "SiSU_#{rc['search']['sisu']['db']}" else nil end action=rc['search']['sisu']['action'] @@ -930,9 +978,10 @@ module SiSU_Env table_open='' table_close='
' end - form=if create_form_sisu and type=~/sisusearch/ and - defined? rc['search']['sisu'] and - defined? rc['search']['sisu']['action'] + form=if create_form_sisu \ + and type=~/sisusearch/ \ + and defined? rc['search']['sisu'] \ + and defined? rc['search']['sisu']['action'] < #{table_open} @@ -952,8 +1001,9 @@ module SiSU_Env #{table_close} WOK - elsif create_form_hyperestraier and type=~/hyperestraier/ and - defined? rc['search']['hyperestraier'] + elsif create_form_hyperestraier \ + and type=~/hyperestraier/ \ + and defined? rc['search']['hyperestraier'] < #{table_open} @@ -976,12 +1026,18 @@ WOK end def search_form_static(action=nil,db=nil) rc=SiSU_Env::Get_init.instance.yamlrc - create_form=if rc['search']['sisu']['flag']==true and - action and db and action =~/https?:\/\// and db =~/\S+/ + create_form=if rc['search']['sisu']['flag']==true \ + and action \ + and db \ + and action =~/https?:\/\// \ + and db =~/\S+/ true elsif widget.search_fixed? - db=if rc['search']['sisu']['flag']==true and rc['search']['sisu']['db']=~/\S+/ - rc['search']['sisu']['db']=~/^SiSU_\S+/ ? rc['search']['sisu']['db'] : "SiSU_#{rc['search']['sisu']['db']}" + db=if rc['search']['sisu']['flag']==true \ + and rc['search']['sisu']['db']=~/\S+/ + rc['search']['sisu']['db']=~/^SiSU_\S+/ \ + ? rc['search']['sisu']['db'] \ + : "SiSU_#{rc['search']['sisu']['db']}" else nil end action=rc['search']['sisu']['action'] @@ -1022,14 +1078,19 @@ WOK @vz=SiSU_Env::Get_init.instance.skin @flag={ :ad=>false,:md=>false,:sk=>false,:rc=>false } def search? - flag=if defined? @rc['search'] and - defined? @rc['search']['sisu'] and - defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/https?:\/\// and - defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ - defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ - flag=if defined? @vz.widget_search and @vz.widget_search == true + flag=if defined? @rc['search'] \ + and defined? @rc['search']['sisu'] \ + and defined? @rc['search']['sisu']['action'] \ + and @rc['search']['sisu']['action'] =~/https?:\/\// \ + and defined? @rc['search']['sisu']['db'] \ + and @rc['search']['sisu']['db'] =~/\S+/ \ + and defined? @rc['search']['sisu']['db'] \ + and @rc['search']['sisu']['db'] =~/\S+/ + flag=if defined? @vz.widget_search \ + and @vz.widget_search == true true - elsif defined? @rc['search']['sisu']['flag'] and @rc['search']['sisu']['flag'] == true + elsif defined? @rc['search']['sisu']['flag'] \ + and @rc['search']['sisu']['flag'] == true true else false @@ -1039,14 +1100,19 @@ WOK end end def search_fixed? - flag=if defined? @rc['search'] and - defined? @rc['search']['sisu'] and - defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/https?:\/\// and - defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ - defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ - flag=if defined? @vz.widget_search and @vz.widget_search == true + flag=if defined? @rc['search'] \ + and defined? @rc['search']['sisu'] \ + and defined? @rc['search']['sisu']['action'] \ + and @rc['search']['sisu']['action'] =~/https?:\/\// \ + and defined? @rc['search']['sisu']['db'] \ + and @rc['search']['sisu']['db'] =~/\S+/ \ + and defined? @rc['search']['sisu']['db'] \ + and @rc['search']['sisu']['db'] =~/\S+/ + flag=if defined? @vz.widget_search \ + and @vz.widget_search == true true - elsif defined? @rc['search']['sisu']['flag'] and @rc['search']['sisu']['flag'] == true + elsif defined? @rc['search']['sisu']['flag'] \ + and @rc['search']['sisu']['flag'] == true true else false @@ -1057,11 +1123,15 @@ WOK end def search_form(action=nil,db=nil) rc=SiSU_Env::Get_init.instance.yamlrc - create_form=if defined? rc['search']['sisu']['flag'] and - rc['search']['sisu']['flag']==true and - action and db and action =~/https?:\/\// and db =~/\S+/ + create_form=if defined? rc['search']['sisu']['flag'] \ + and rc['search']['sisu']['flag']==true \ + and action \ + and db \ + and action =~/https?:\/\// \ + and db =~/\S+/ true - elsif widget_static.search? and rc['search']['sisu']['flag']==true + elsif widget_static.search? \ + and rc['search']['sisu']['flag']==true db=if rc['search']['sisu']['db']=~/\S+/ rc['search']['sisu']['db']=~/^SiSU_\S+/ ? rc['search']['sisu']['db'] : "SiSU_#{rc['search']['sisu']['db']}" else nil @@ -1070,7 +1140,9 @@ WOK true else false end - if create_form and @fnb and @fnb=~/\S+/ + if create_form \ + and @fnb \ + and @fnb=~/\S+/ %{
@@ -1191,17 +1263,23 @@ WOK end def webserv #separation required for webrick which cannot use path.output (different requirements as no file is passed) man_path=if @@man_path.nil? - man_path=if defined? @rc['webserv']['path'] and @rc['webserv']['path'] =~/\S\S+/ + man_path=if defined? @rc['webserv']['path'] \ + and @rc['webserv']['path'] =~/\S\S+/ man_path=@@man_path=File.expand_path(@rc['webserv']['path']) else nil end else manpath=@@man_path end - @webserv_path=if defined? man_path and File.writable?("#{man_path}/."); man_path #web server path as configured in rc file - elsif FileTest.directory?(defaults[:webserv_path]) and File.writable?("#{defaults[:webserv_path]}/.") #web server path default + @webserv_path=if defined? man_path \ + and File.writable?("#{man_path}/.") + man_path #web server path as configured in rc file + elsif FileTest.directory?(defaults[:webserv_path]) \ + and File.writable?("#{defaults[:webserv_path]}/.") #web server path default defaults[:webserv_path] else #create default directory under home and place output there - File.mkpath(defaults[:output_local]) unless FileTest.directory?(defaults[:output_local]) + unless FileTest.directory?(defaults[:output_local]) + File.mkpath(defaults[:output_local]) + end defaults[:output_local] end end @@ -1252,8 +1330,11 @@ WOK end File.mkpath(defaults[:processing_path]) unless FileTest.directory?(defaults[:processing_path]) File.mkpath(defaults[:processing_path_tmp]) unless FileTest.directory?(defaults[:processing_path_tmp]) - path_processing=if defined? @rc['processing']['path'] and @rc['processing']['path'] - File.mkpath("#{path.home}/#{@rc['processing']['path']}") unless FileTest.directory?("#{path.home}/#{@rc['processing']['path']}") + path_processing=if defined? @rc['processing']['path'] \ + and @rc['processing']['path'] + unless FileTest.directory?("#{path.home}/#{@rc['processing']['path']}") + File.mkpath("#{path.home}/#{@rc['processing']['path']}") + end ["#{path.home}/#{@rc['processing']['path']}",defaults[:processing_path],defaults[:processing_path_tmp]] else [defaults[:processing_path],defaults[:processing_path_tmp]] end @@ -1346,7 +1427,8 @@ WOK url.webserv_map_pwd end def image_source #image repository source directory - image_path=if defined? @rc['image']['path'] and defined? @rc['image']['public'] + image_path=if defined? @rc['image']['path'] \ + and defined? @rc['image']['public'] pth="#{@rc['image']['path']}" "#{pth}/#{@rc['image']['public']}" else @@ -1354,7 +1436,8 @@ WOK end end def image_source_tex #image repository source directory - image_path=if defined? @rc['image']['path'] and defined? @rc['image']['public'] + image_path=if defined? @rc['image']['path'] \ + and defined? @rc['image']['public'] pth="#{@rc['image']['path']}" "#{pth}/#{@rc['image']['public']}" else @@ -1389,8 +1472,12 @@ WOK "http://#{hostname}/#@stub_pwd" end def root - if defined? @rc['webserv']['url_root'] and @rc['webserv']['url_root'] =~/https?:\/\//; "#{@rc['webserv']['url_root']}/#@stub_pwd" - elsif defined? @rc['webserv']['url_root'] and @rc['webserv']['url_root'] =~/localhost/; "http://localhost/#@stub_pwd" + if defined? @rc['webserv']['url_root'] \ + and @rc['webserv']['url_root'] =~/https?:\/\// + "#{@rc['webserv']['url_root']}/#@stub_pwd" + elsif defined? @rc['webserv']['url_root'] \ + and @rc['webserv']['url_root'] =~/localhost/ + "http://localhost/#@stub_pwd" else "file://#{path.output}" end end @@ -1408,11 +1495,16 @@ WOK end end def webrick_port - if @md and @md.cmd.inspect=~/-F/ and @md.mod.inspect=~/port=(\d+)/ + if @md \ + and @md.cmd.inspect=~/-F/ \ + and @md.mod.inspect=~/port=(\d+)/ $1 else if defined? @rc['webserv_cgi']['port'] - if @rc['webserv_cgi']['port'].nil? and (defined? @md.mod and not @md.mod.nil? and @md.mod.inspect=~/webrick/) + if @rc['webserv_cgi']['port'].nil? \ + and (defined? @md.mod \ + and not @md.mod.nil? \ + and @md.mod.inspect=~/webrick/) defaults[:webserv_port_cgi] elsif not @rc['webserv_cgi']['port'].nil? @rc['webserv_cgi']['port'] @@ -1423,11 +1515,16 @@ WOK end end def webserv_port_cgi - if @md and @md.cmd.inspect=~/-F/ and @md.mod.inspect=~/port=(\d+)/ + if @md \ + and @md.cmd.inspect=~/-F/ \ + and @md.mod.inspect=~/port=(\d+)/ $1 else if defined? @rc['webserv_cgi']['port'] - if @rc['webserv_cgi']['port'].nil? and (defined? @md.mod and not @md.mod.nil? and @md.mod.inspect=~/webrick/) + if @rc['webserv_cgi']['port'].nil? \ + and (defined? @md.mod \ + and not @md.mod.nil? \ + and @md.mod.inspect=~/webrick/) defaults[:webserv_port_cgi] elsif not @rc['webserv_cgi']['port'].nil? @rc['webserv_cgi']['port'] @@ -1438,7 +1535,8 @@ WOK end end def webserv_cgi #web url for local webserv (localhost, or hostname) - if defined? @rc['webserv_cgi']['host'] and not @rc['webserv_cgi']['host'].nil? + if defined? @rc['webserv_cgi']['host'] \ + and not @rc['webserv_cgi']['host'].nil? http=@rc['webserv_cgi']['host'] =~ /https?:\/\// ? '' : 'http://' #check https? missing if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#@stub_pwd" @@ -1453,7 +1551,8 @@ WOK end end def webserv_base_cgi #web url for local webserv (localhost, or hostname) - if defined? @rc['webserv_cgi']['host'] and not @rc['webserv_cgi']['host'].nil? + if defined? @rc['webserv_cgi']['host'] \ + and not @rc['webserv_cgi']['host'].nil? http=@rc['webserv_cgi']['host'] =~ /https?:\/\// ? '' : 'http://' if webserv_port_cgi "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" @@ -1469,7 +1568,8 @@ WOK end def webrick #must have a port #REMOVE #port=":#{webserv_port_cgi}" - if defined? @rc['webserv_cgi']['host'] and not @rc['webserv_cgi']['host'].nil? + if defined? @rc['webserv_cgi']['host'] \ + and not @rc['webserv_cgi']['host'].nil? http=if @rc['webserv_cgi']['host'] =~/http:\/\// 'http://' elsif @rc['webserv_cgi']['host'] =~/https:\/\// @@ -1477,14 +1577,17 @@ WOK else defaults end "#{http}#{@rc['webserv_cgi']['host']}" - elsif webserv_host_base and not webserv_host_base.nil? + elsif webserv_host_base \ + and not webserv_host_base.nil? "#{http}#{webserv_host_base}" else "#{http}localhost" end end def webserv #web url for local webserv (localhost, or hostname) - if path.webserv_dir and path.webserv =~ /#{path.webserv_dir}/ #revisit + if path.webserv_dir \ + and path.webserv =~ /#{path.webserv_dir}/ #revisit "#{path.webserv}/#@stub_pwd".gsub(/#{path.webserv_dir}/,"#{url.hostname}/#@stub_pwd") - elsif defined? @rc['webserv']['webrick_url'] and @rc['webserv']['webrick_url'] == false + elsif defined? @rc['webserv']['webrick_url'] \ + and @rc['webserv']['webrick_url'] == false "file://#{path.webserv}/#@stub_pwd" elsif webserv_port_cgi =~/\S+/ "#{url.hostname}:#{webserv_port_cgi}/#@stub_pwd" @@ -1492,9 +1595,11 @@ WOK end end def webserv_base #web url for local webserv (localhost, or hostname) - if path.webserv_dir and path.webserv =~ /#{path.webserv_dir}/ #revisit + if path.webserv_dir \ + and path.webserv =~ /#{path.webserv_dir}/ #revisit "#{path.webserv}/#@stub_pwd".gsub(/#{path.webserv_dir}/,"#{url.hostname}") - elsif defined? @rc['webserv']['webrick_url'] and @rc['webserv']['webrick_url'] == false + elsif defined? @rc['webserv']['webrick_url'] \ + and @rc['webserv']['webrick_url'] == false "file://#{path.webserv}" else "#{url.webrick_base}" end @@ -1512,13 +1617,15 @@ WOK end end def sample_search_form_title - if defined? @rc['search']['sisu']['title'] and @rc['search']['sisu']['title'] =~/\S+/ + if defined? @rc['search']['sisu']['title'] \ + and @rc['search']['sisu']['title'] =~/\S+/ @rc['search']['sisu']['title'] else %{SiSU search form (sample):} end end def output_tell - output_type=if defined? @rc['show_output_on'] and @rc['show_output_on'] =~/^(?:filesystem|webserv|(?:local|remote)(?:_webserv)?|webrick)/ + output_type=if defined? @rc['show_output_on'] \ + and @rc['show_output_on'] =~/^(?:filesystem|webserv|(?:local|remote)(?:_webserv)?|webrick)/ @rc['show_output_on'] else 'filesystem' end @@ -1587,7 +1694,8 @@ WOK end def digest def type - if defined? @rc['default']['digest'] and @rc['default']['digest'] != nil + if defined? @rc['default']['digest'] \ + and @rc['default']['digest'] != nil case @rc['default']['digest'] when /^sha(?:2|256)?$/; 'sha256' when /^md5$/; 'md5' @@ -1610,23 +1718,28 @@ WOK end def program def text_editor - if defined? @rc['program_select']['editor'] and @rc['program_select']['editor'] =~/\S\S+/ + if defined? @rc['program_select']['editor'] \ + and @rc['program_select']['editor'] =~/\S\S+/ @rc['program_select']['editor'] - elsif defined? @rc['program_select']['text_editor'] and @rc['program_select']['text_editor'] =~/\S\S+/ + elsif defined? @rc['program_select']['text_editor'] \ + and @rc['program_select']['text_editor'] =~/\S\S+/ @rc['program_select']['text_editor'] else 'editor' #'gvim -c :R -c :S' end end def pdf_viewer - if defined? @rc['program_select']['pdf_viewer'] and @rc['program_select']['pdf_viewer'] =~/\S\S+/ + if defined? @rc['program_select']['pdf_viewer'] \ + and @rc['program_select']['pdf_viewer'] =~/\S\S+/ @rc['program_select']['pdf_viewer'] else 'pdf-viewer' #'evince' end end def web_browser - if defined? @rc['program_select']['www_browser'] and @rc['program_select']['www_browser'] =~/\S\S+/ + if defined? @rc['program_select']['www_browser'] \ + and @rc['program_select']['www_browser'] =~/\S\S+/ @rc['program_select']['www_browser'] - elsif defined? @rc['program_select']['web_browser'] and @rc['program_select']['web_browser'] =~/\S\S+/ + elsif defined? @rc['program_select']['web_browser'] \ + and @rc['program_select']['web_browser'] =~/\S\S+/ @rc['program_select']['web_browser'] else 'x-www-browser' #'kazehakase' 'galeon' end @@ -1635,9 +1748,11 @@ WOK web_browser end def console_web_browser - if defined? @rc['program_select']['console_www_browser'] and @rc['program_select']['console_www_browser'] =~/\S\S+/ + if defined? @rc['program_select']['console_www_browser'] \ + and @rc['program_select']['console_www_browser'] =~/\S\S+/ @rc['program_select']['console_www_browser'] - elsif defined? @rc['program_select']['console_web_browser'] and @rc['program_select']['console_web_browser'] =~/\S\S+/ + elsif defined? @rc['program_select']['console_web_browser'] \ + and @rc['program_select']['console_web_browser'] =~/\S\S+/ @rc['program_select']['console_web_browser'] else 'console-www-browser' #'links2' 'elinks' 'epiphany' end @@ -1646,7 +1761,8 @@ WOK web_browser end def xml_viewer - if defined? @rc['program_select']['xml_viewer'] and @rc['program_select']['xml_viewer'] =~/\S\S+/ + if defined? @rc['program_select']['xml_viewer'] \ + and @rc['program_select']['xml_viewer'] =~/\S\S+/ @rc['program_select']['xml_viewer'] else text_editor end @@ -1655,44 +1771,58 @@ WOK xml_viewer end def odf_viewer - if defined? @rc['program_select']['odf_viewer'] and @rc['program_select']['odf_viewer'] =~/\S\S+/ + if defined? @rc['program_select']['odf_viewer'] \ + and @rc['program_select']['odf_viewer'] =~/\S\S+/ @rc['program_select']['odf_viewer'] else 'oowriter' #'odf-viewer','oowriter' end end def manpage_generator - if defined? @rc['program_select']['man'] and @rc['program_select']['man'] =~/\S\S+/ + if defined? @rc['program_select']['man'] \ + and @rc['program_select']['man'] =~/\S\S+/ @rc['program_select']['man'] else 'nroff -man' #'nroff -man' #'groff -man -Tascii' end end def file_encoding #file encoding is='' - if defined? @rc['program_set']['file_encoding']; is=@rc['program_set']['encoding'] + if defined? @rc['program_set']['file_encoding'] + is=@rc['program_set']['encoding'] end - if is.nil? or is==true; is='encoding' + if is.nil? \ + or is==true + is='encoding' end is end def wc #wordcount is='' - if defined? @rc['program_set']['wc']; is=@rc['program_set']['wc'] + if defined? @rc['program_set']['wc'] + is=@rc['program_set']['wc'] end - if is.nil? or is==true; is='wc' + if is.nil? \ + or is==true + is='wc' end is end def tidy - if defined? @rc['program_set']['tidy']; is=@rc['program_set']['tidy'] + if defined? @rc['program_set']['tidy'] + is=@rc['program_set']['tidy'] end - if is.nil? or is==true; is='tidy' + if is.nil? \ + or is==true + is='tidy' end is end def rmagick - if defined? @rc['program_set']['rmagick']; is=@rc['program_set']['rmagick'] + if defined? @rc['program_set']['rmagick'] + is=@rc['program_set']['rmagick'] end - if is.nil? or is==true; is='rmagick' + if is.nil? \ + or is==true + is='rmagick' end is end @@ -1704,7 +1834,9 @@ WOK is=if defined? @rc['program_set']['rexml']; @rc['program_set']['rexml'] else '' end - if is.nil? or is==true; is='rexml' + if is.nil? \ + or is==true + is='rexml' end is end @@ -1712,7 +1844,9 @@ WOK is=if defined? @rc['program_set']['pdflatex']; @rc['program_set']['pdflatex'] else '' end - if is.nil? or is==true; is='pdflatex' + if is.nil? \ + or is==true + is='pdflatex' end is end @@ -1720,7 +1854,9 @@ WOK is=if defined? @rc['program_set']['postgresql']; @rc['program_set']['postgresql'] else '' end - if is.nil? or is==true; is='postgresql' + if is.nil? \ + or is==true + is='postgresql' end is end @@ -1728,7 +1864,9 @@ WOK is=if defined? @rc['program_set']['sqlite']; @rc['program_set']['sqlite'] else '' end - if is.nil? or is==true; is='sqlite' + if is.nil? \ + or is==true + is='sqlite' end is end @@ -1749,19 +1887,22 @@ WOK SiSU_Env::Standardise_language.new(l) end def multilingual - if defined? @rc['default']['multilingual'] and @rc['default']['multilingual'] != nil; @rc['default']['multilingual'] + if defined? @rc['default']['multilingual'] \ + and @rc['default']['multilingual'] != nil; @rc['default']['multilingual'] else defaults[:multilingual] end end def lang_filename(l) @lang={} x=if multilingual - x=if defined? @rc['default']['language_file'] and @rc['default']['language_file'] != nil; @rc['default']['language_file'] + x=if defined? @rc['default']['language_file'] \ + and @rc['default']['language_file'] != nil; @rc['default']['language_file'] else 1 end else 0 end - if (l != defaults[:language_code]) or (language.code != defaults[:language_code]) #watch + if (l != defaults[:language_code]) \ + or (language.code != defaults[:language_code]) #watch if x==1; @lang[:pre],@lang[:mid],@lang[:post]="#{l}.",'','' elsif x==2; @lang[:pre],@lang[:mid],@lang[:post]='',".#{l}",'' elsif x==3; @lang[:pre],@lang[:mid],@lang[:post]='','',".#{l}" @@ -1777,7 +1918,8 @@ WOK is='' if defined? @rc['program_set']['file_encoding']; is=@rc['program_set']['encoding'] end - if is.nil? or is==true; is='encoding' + if is.nil? \ + or is==true; is='encoding' end is end @@ -1793,8 +1935,13 @@ WOK def sisupod_gen(fns_pod) pwd=Dir.pwd sisupod_processing_path="#{path.processing}/sisupod" - rm_rf(sisupod_processing_path) if FileTest.directory?(sisupod_processing_path) or FileTest.file?(sisupod_processing_path) - File.mkpath(sisupod_processing_path) unless FileTest.directory?(sisupod_processing_path) + if FileTest.directory?(sisupod_processing_path) \ + or FileTest.file?(sisupod_processing_path) + rm_rf(sisupod_processing_path) + end + unless FileTest.directory?(sisupod_processing_path) + File.mkpath(sisupod_processing_path) + end if FileTest.file?("#{Dir.pwd}/#{fns_pod}") system("unzip -q #{Dir.pwd}/#{fns_pod} -d #{path.processing}") else @@ -1815,43 +1962,49 @@ WOK end end def cf_0 #processing flag shortcuts - if defined? @rc['flag']['default'] and - not (@rc['flag']['default'].nil? or @rc['flag']['default'].empty?) + if defined? @rc['flag']['default'] \ + and not (@rc['flag']['default'].nil? \ + or @rc['flag']['default'].empty?) @rc['flag']['default'] else '-NhwpaobxXyYv' end end def cf_1 #processing flag shortcuts - if defined? @rc['flag']['i'] and - not (@rc['flag']['i'].nil? or @rc['flag']['i'].empty?) + if defined? @rc['flag']['i'] \ + and not (@rc['flag']['i'].nil? \ + or @rc['flag']['i'].empty?) @rc['flag']['i'] else '-hwpoy' end end def cf_2 #processing flag shortcuts - if defined? @rc['flag']['ii'] and - not (@rc['flag']['ii'].nil? or @rc['flag']['ii'].empty?) + if defined? @rc['flag']['ii'] \ + and not (@rc['flag']['ii'].nil? \ + or @rc['flag']['ii'].empty?) @rc['flag']['ii'] else '-NhwpaobxXy' end end def cf_3 #processing flag shortcuts - if defined? @rc['flag']['iii'] and - not (@rc['flag']['iii'].nil? or @rc['flag']['iii'].empty?) + if defined? @rc['flag']['iii'] \ + and not (@rc['flag']['iii'].nil? \ + or @rc['flag']['iii'].empty?) @rc['flag']['iii'] else '-NhwpaobxXyY' end end def cf_4 #processing flag shortcuts - if defined? @rc['flag']['iv'] and - not (@rc['flag']['iv'].nil? or @rc['flag']['iv'].empty?) + if defined? @rc['flag']['iv'] \ + and not (@rc['flag']['iv'].nil? \ + or @rc['flag']['iv'].empty?) @rc['flag']['iv'] else '-NhwpaobxXDyY --import' end end def cf_5 #processing flag shortcuts - if defined? @rc['flag']['v'] and - not (@rc['flag']['v'].nil? or @rc['flag']['v'].empty?) + if defined? @rc['flag']['v'] \ + and not (@rc['flag']['v'].nil? \ + or @rc['flag']['v'].empty?) @rc['flag']['v'] else '-NhwpaobxXDyY --update' end @@ -1875,7 +2028,8 @@ WOK super() @opt=opt #,opt.fns,opt.cmd #@file=@opt.fns #not always fns - @env=if @opt.fns and not @opt.fns.empty? + @env=if @opt.fns \ + and not @opt.fns.empty? SiSU_Env::Info_env.new(@opt.fns) else SiSU_Env::Info_env.new('dummy.sst') @@ -1883,74 +2037,85 @@ WOK if @opt.cmd =~/m/; @md=SiSU_Param::Parameters.new(@opt).get end ft=[] - if @md and defined? @md.fn and @md.fn # used for multilingual - if @md.cmd =~ /[hH]/; ft << @md.fn[:html] + if @md \ + and defined? @md.fn \ + and @md.fn # used for multilingual + if @md.cmd =~ /[hH]/ + ft << @md.fn[:html] end - if @md.cmd =~ /w/ and @md.cmd !~ /[hH]/; ft << @md.fn[:concordance] + if @md.cmd =~ /w/ \ + and @md.cmd !~ /[hH]/ + ft << @md.fn[:concordance] end - if @md.cmd =~ /y/ and @md.cmd !~ /[hH]/; ft << @md.fn[:manifest] + if @md.cmd =~ /y/ \ + and @md.cmd !~ /[hH]/ + ft << @md.fn[:manifest] end - if @md.cmd =~ /p/; ft << @md.fn[:pdf_l] << @md.fn[:pdf_p] + if @md.cmd =~ /p/; ft << @md.fn[:pdf_l] << @md.fn[:pdf_p] end - if @md.cmd =~ /x/; ft << @md.fn[:sax] + if @md.cmd =~ /x/; ft << @md.fn[:sax] end - if @md.cmd =~ /X/; ft << @md.fn[:dom] + if @md.cmd =~ /X/; ft << @md.fn[:dom] end - if @md.cmd =~ /b/; ft << @md.fn[:xhtml] + if @md.cmd =~ /b/; ft << @md.fn[:xhtml] end - if @md.cmd =~ /a/; ft << @md.fn[:plain] + if @md.cmd =~ /a/; ft << @md.fn[:plain] end - if @md.cmd =~ /i/; ft << @md.fn[:manpage] + if @md.cmd =~ /i/; ft << @md.fn[:manpage] end - if @md.cmd =~ /[g]/; ft << @md.fn[:wiki] + if @md.cmd =~ /[g]/; ft << @md.fn[:wiki] end - if @md.cmd =~ /N/; ft << @md.fn[:digest] + if @md.cmd =~ /N/; ft << @md.fn[:digest] end - if @md.cmd =~ /o/; ft << @md.fn[:odf] + if @md.cmd =~ /o/; ft << @md.fn[:odf] end - if @md.cmd =~ /O/; ft << @md.fn[:oai_pmh] + if @md.cmd =~ /O/; ft << @md.fn[:oai_pmh] end - if @md.cmd =~ /s/; ft << @md.fns + if @md.cmd =~ /s/; ft << @md.fns end - if @md.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi' + if @md.cmd =~ /S/; ft << @md.fn[:sisupod] << '.kdi' end @fnb=@md.fnb else # still needed where/when param is not parsed - if @opt.cmd =~ /[hH]/; ft << '.html' << '.html.??' + if @opt.cmd =~ /[hH]/; ft << '.html' << '.html.??' end - if @opt.cmd =~ /w/ and @opt.cmd !~ /[hH]/; ft << 'concordance.html' << '??.concordance.html' << 'concordance.??.html' + if @opt.cmd =~ /w/ \ + and @opt.cmd !~ /[hH]/ + ft << 'concordance.html' << '??.concordance.html' << 'concordance.??.html' end - if @opt.cmd =~ /y/ and @opt.cmd !~ /[hH]/; ft << 'sisu_manifest.html' << '??.sisu_manifest.html' << 'sisu_manifest.??.html' + if @opt.cmd =~ /y/ \ + and @opt.cmd !~ /[hH]/ + ft << 'sisu_manifest.html' << '??.sisu_manifest.html' << 'sisu_manifest.??.html' end - if @opt.cmd =~ /p/; ft << 'landscape.pdf' << 'portrait.pdf' << '.pdf' + if @opt.cmd =~ /p/; ft << 'landscape.pdf' << 'portrait.pdf' << '.pdf' end - if @opt.cmd =~ /x/; ft << 'sax.xml' << '??.sax.xml' << 'sax.??.xml' + if @opt.cmd =~ /x/; ft << 'sax.xml' << '??.sax.xml' << 'sax.??.xml' end - if @opt.cmd =~ /X/; ft << 'dom.xml' << '??.dom.xml' << 'dom.??.xml' + if @opt.cmd =~ /X/; ft << 'dom.xml' << '??.dom.xml' << 'dom.??.xml' end - if @opt.cmd =~ /b/; ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' + if @opt.cmd =~ /b/; ft << 'scroll.xhtml' << '??.scroll.xhtml' << 'scroll.??.xhtml' end - if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' + if @opt.cmd =~ /i/; ft << '.1' << '??.man.1' << 'man.??.1' end - if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' + if @opt.cmd =~ /a/; ft << 'plain.txt' << '??.plain.txt' << 'plain.??.txt' end - if @opt.cmd =~ /[g]/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' + if @opt.cmd =~ /[g]/; ft << 'wiki.txt' << '??.wiki.txt' << 'wiki.??.txt' end - if @opt.cmd =~ /N/; ft << 'digest.txt' << '??.digest.txt' << 'digest.??.txt' + if @opt.cmd =~ /N/; ft << 'digest.txt' << '??.digest.txt' << 'digest.??.txt' end - if @opt.cmd =~ /o/; ft << 'opendocument.odt' << '??.opendocument.odt' << 'opendocument.??.odt' + if @opt.cmd =~ /o/; ft << 'opendocument.odt' << '??.opendocument.odt' << 'opendocument.??.odt' end - if @opt.cmd =~ /O/; ft << 'oai_pmh.xml' + if @opt.cmd =~ /O/; ft << 'oai_pmh.xml' end - if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm' + if @opt.cmd =~ /s/; ft << '.sst' << '.ssi' << '.ssm' end - if @opt.cmd =~ /S/; ft << '.zip' << '.kdi' + if @opt.cmd =~ /S/; ft << '.zip' << '.kdi' end - if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml' + if @opt.mod.inspect =~ /sxm|sxs|xml/; ft << @fnb << '.sxs.xml' end - if @opt.mod.inspect =~ /sxd/; ft << @fnb << '.sxd.xml' + if @opt.mod.inspect =~ /sxd/; ft << @fnb << '.sxd.xml' end - if @opt.mod.inspect =~ /sxn/; ft << @fnb << '.sxn.xml' + if @opt.mod.inspect =~ /sxn/; ft << @fnb << '.sxn.xml' end end ft=ft.uniq @@ -1960,11 +2125,15 @@ WOK elsif filetypes =~/\S+?,\S+/; '*{' + filetypes + '}' # more than one relevant file type else '*' + filetypes # one relevant file type end - @source_path=if @fnb and not @fnb.empty?; "#{@env.path.output}/#@fnb" - else @env.path.output + @source_path=if @fnb \ + and not @fnb.empty? + "#{@env.path.output}/#@fnb" + else @env.path.output end - @source_path_src=if @fnb and not @fnb.empty?; "#{@env.path.output}/src" - else @env.path.output_src + @source_path_src=if @fnb \ + and not @fnb.empty? + "#{@env.path.output}/src" + else @env.path.output_src end @local_sisu_source=if @filetypes =~/\S/; "#@source_path/#@filetypes" else @source_path @@ -1993,7 +2162,8 @@ WOK #System_call.new(@zap,'',@cmd).rm end def zap_map - if @opt.fnb and not @opt.fnb.empty? + if @opt.fnb \ + and not @opt.fnb.empty? sm="#{@env.path.output}/sitemaps/sitemap_#{@opt.fnb}.xml" rm(sm) if FileTest.file?(sm) end @@ -2005,11 +2175,13 @@ WOK end def remote_host #see Info_remote remote_host_base_general r=[] - r=if (defined? @rc['remote'] and @rc['remote'].class==Array) + r=if (defined? @rc['remote'] \ + and @rc['remote'].class==Array) r_array=@rc['remote'] r_array.each_with_index do |renv,i| r[i]={} - if defined? renv['user'] and defined? renv['host'] + if defined? renv['user'] \ + and defined? renv['host'] end r[i][:user]=renv['user'] r[i][:host]=renv['host'] @@ -2020,7 +2192,10 @@ WOK r[i][:name]="#{r[i][:user]}@#{r[i][:host]}:#{r[i][:path]}" end r - elsif (defined? @rc['remote'] and @rc['remote'].class==Hash and defined? @rc['remote']['user'] and defined? @rc['remote']['host']) + elsif (defined? @rc['remote'] \ + and @rc['remote'].class==Hash \ + and defined? @rc['remote']['user'] \ + and defined? @rc['remote']['host']) r[0]={} r[0][:user]=@rc['remote']['user'] r[0][:host]=@rc['remote']['host'] @@ -2112,15 +2287,22 @@ WOK remote_src="#{remote_conn[:name]}/#{@env.path.stub_src}/." src_txt=@opt.fnc src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.zip') - if (local_gen =~/\S/ and local_gen !~/\/\//) and (remote_gen =~/\S/ and remote_gen !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ + if (local_gen =~/\S/ \ + and local_gen !~/\/\//) \ + and (remote_gen =~/\S/ \ + and remote_gen !~/\/\//) \ + and @@flag_remote==true \ + and @opt.cmd !~/U/ System_call.new(local_gen,remote_gen).scp - if FileTest.file?("#{local_src}/#{src_txt}") or FileTest.file?("#{local_src}/#{src_pod}") + if FileTest.file?("#{local_src}/#{src_txt}") \ + or FileTest.file?("#{local_src}/#{src_pod}") System_call.new("#{local_src}/#{src_txt} #{local_src}/#{src_pod}",remote_src).scp end elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "#{local_gen} -> #{remote_gen}" - if FileTest.file?("#{local_src}/#{src_doc}") or FileTest.file?("#{local_src}/#{src_doc}.zip") + if FileTest.file?("#{local_src}/#{src_doc}") \ + or FileTest.file?("#{local_src}/#{src_doc}.zip") puts "#{local_src}/#{src_doc}* -> #{remote_src}" end else @@ -2138,15 +2320,22 @@ WOK remote_src="#{remote_conn[:name]}/#{@env.path.stub_src}/." src_txt=@opt.fnc src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.zip') - if (local_gen =~/\S/ and local_gen !~/\/\//) and (remote_gen =~/\S/ and remote_gen !~/\/\//) and @@flag_remote==true and @opt.cmd !~/U/ + if (local_gen =~/\S/ \ + and local_gen !~/\/\//) \ + and (remote_gen =~/\S/ \ + and remote_gen !~/\/\//) \ + and @@flag_remote==true \ + and @opt.cmd !~/U/ System_call.new(local_gen,remote_gen,@opt.cmd).rsync('--delete-after') - if FileTest.file?("#{local_src}/#{src_txt}") or FileTest.file?("#{local_src}/#{src_pod}") + if FileTest.file?("#{local_src}/#{src_txt}") \ + or FileTest.file?("#{local_src}/#{src_pod}") System_call.new("#{local_src}/#{src_txt} #{local_src}/#{src_pod}",remote_src,@opt.cmd).rsync end elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "#{local_gen} -> #{remote_gen}" - if FileTest.file?("#{local_src}/#{src_doc}") or FileTest.file?("#{local_src}/#{src_doc}.zip") + if FileTest.file?("#{local_src}/#{src_doc}") \ + or FileTest.file?("#{local_src}/#{src_doc}.zip") puts "#{local_src}/#{src_doc}* -> #{remote_src}" end else @@ -2160,7 +2349,10 @@ WOK self.remote_host_base.each do |remote_conn| local=@source_path remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." - if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ + if defined? @rc['permission_set']['remote_base_site'] \ + and @rc['permission_set']['remote_base_site'] \ + and @@flag_remote==true \ + and @opt.cmd !~/U/ puts "begin scp_base: #{local} -> #{remote}" System_call.new("#{local}/#{@env.path.style}/",remote).scp elsif @opt.cmd =~/U/ @@ -2175,7 +2367,10 @@ WOK self.remote_host_base.each do |remote_conn| local=@source_path remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." - if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ + if defined? @rc['permission_set']['remote_base_site'] \ + and @rc['permission_set']['remote_base_site'] \ + and @@flag_remote==true \ + and @opt.cmd !~/U/ puts "begin scp_base_all: #{local} -> #{remote}" System_call.new("#{local}/_sisu/image/",remote).scp System_call.new("#{local}/_sisu/image_local/",remote).scp @@ -2191,14 +2386,18 @@ WOK end end def rsync_base #base site + ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu" + image_sys="#{@env.path.webserv}/_sisu/image_sys" self.remote_host_base.each do |remote_conn| - local=@source_path remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." - if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ + remote_sys="#{remote_conn[:name]}/_sisu" + if defined? @rc['permission_set']['remote_base_site'] \ + and @rc['permission_set']['remote_base_site'] \ + and @@flag_remote==true \ + and @opt.cmd !~/U/ #puts "begin rsync_base: #{local} -> #{remote}" - #System_call.new("#{local}/_sisu/image/",remote).rsync - #System_call.new("#{local}/_sisu/image_local/",remote).rsync - #System_call.new("#{local}/#{@env.path.style}/",remote).rsync + System_call.new("#{image_sys}","#{remote_sys}").rsync + System_call.new("#{ldest}","#{remote}").rsync elsif @opt.cmd =~/U/ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ puts "rsync_base: #{local} -> #{remote}" @@ -2213,7 +2412,10 @@ WOK self.remote_host_base.each do |remote_conn| local=@source_path remote="#{remote_conn[:name]}/#{@env.path.stub_pwd}/." - if defined? @rc['permission_set']['remote_base_site'] and @rc['permission_set']['remote_base_site'] and @@flag_remote==true and @opt.cmd !~/U/ + if defined? @rc['permission_set']['remote_base_site'] \ + and @rc['permission_set']['remote_base_site'] \ + and @@flag_remote==true \ + and @opt.cmd !~/U/ puts "begin rsync_base_sync: #{local} -> #{remote}" System_call.new("#{local}/_sisu/image/",remote).rsync('--delete-after') System_call.new("#{local}/_sisu/image_local/",remote).rsync('--delete-after') @@ -2265,8 +2467,13 @@ WOK @env=SiSU_Env::Info_env.new end def images - File.mkpath("#{@env.path.output}/_sisu") unless FileTest.directory?("#{@env.path.output}/_sisu") - File.symlink("../../_sisu/image_sys", "#{@env.path.output}/_sisu/image_sys") unless File.exist?("#{@env.path.output}/_sisu/image_sys") or File.symlink?("#{@env.path.output}/_sisu/image_sys") + unless FileTest.directory?("#{@env.path.output}/_sisu") + File.mkpath("#{@env.path.output}/_sisu") + end + unless File.exist?("#{@env.path.output}/_sisu/image_sys") \ + or File.symlink?("#{@env.path.output}/_sisu/image_sys") + File.symlink("../../_sisu/image_sys", "#{@env.path.output}/_sisu/image_sys") + end end def man_forms #File.symlink("../../man/form", "#{@env.path.output}/man/form") unless File.symlink?("#{@env.path.output}/man/form") == true @@ -2324,7 +2531,8 @@ WOK "#{@env.path.webserv}/#@pwd_stub/sisu_sqlite.db" end def port_psql #PGPORT - if defined? @rc['db']['postgresql']['port'] and @rc['db']['postgresql']['port'] =~/\d+/ + if defined? @rc['db']['postgresql']['port'] \ + and @rc['db']['postgresql']['port'] =~/\d+/ @rc['db']['postgresql']['port'] else @defaults[:postgresql_port] end @@ -2361,7 +2569,9 @@ WOK def initialize(md=nil,skin=nil) @md=md @d_sk=if skin.class==String ; skin - elsif defined? md.doc_skin and md.doc_skin; md.doc_skin + elsif defined? md.doc_skin \ + and md.doc_skin + md.doc_skin else nil end @home,@pwd=ENV['HOME'],ENV['PWD'] @@ -2376,7 +2586,9 @@ WOK skin_path << "#{@env.path.processing}/external_document/skin" #skin_path << "#{@env.path.processing}/external_document/_sisu/skin" #revisit skin=true - if @pwd_stub =~/^sisupod$/ and @md.mod.inspect !~/--trust/; skin=false #security only run skins on sisupod if --trust flag is provided + if @pwd_stub =~/^sisupod$/ \ + and @md.mod.inspect !~/--trust/ + skin=false #security only run skins on sisupod if --trust flag is provided end doc_skin,dir_skin=nil,nil if skin @@ -2436,7 +2648,8 @@ WOK @env=SiSU_Env::Info_env.new end def html - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_html.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_html.css") "#{@md.doc_css}_html.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html.css") "#{@env.path.stub_pwd}_html.css" @@ -2444,7 +2657,8 @@ WOK end end def html_tables - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_html_tables.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_html_tables.css") "#{@md.doc_css}_html_tables.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_html_tables.css") "#{@env.path.stub_pwd}_html_tables.css" @@ -2452,7 +2666,8 @@ WOK end end def xhtml - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xhtml.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xhtml.css") "#{@md.doc_css}_xhtml.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xhtml.css") "#{@env.path.stub_pwd}_xhtml.css" @@ -2460,7 +2675,8 @@ WOK end end def xml_sax - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xml_sax.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xml_sax.css") "#{@md.doc_css}_xml_sax.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_sax.css") "#{@env.path.stub_pwd}_xml_sax.css" @@ -2468,7 +2684,8 @@ WOK end end def xml_dom - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xml_dom.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_xml_dom.css") "#{@md.doc_css}_xml_dom.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_xml_dom.css") "#{@env.path.stub_pwd}_xml_dom.css" @@ -2476,7 +2693,8 @@ WOK end end def docbook_xml - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_docbook.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_docbook.css") "#{@md.doc_css}_xml_dom.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_docbook.css") "#{@env.path.stub_pwd}_docbook.css" @@ -2484,7 +2702,8 @@ WOK end end def homepage - css=if @md.doc_css and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_homepage.css") + css=if @md.doc_css \ + and FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@md.doc_css}_homepage.css") "#{@md.doc_css}_homepage.css" elsif FileTest.file?("#{@env.path.output}/#{@env.path.style}/#{@env.path.stub_pwd}_homepage.css") "#{@env.path.stub_pwd}_homepage.css" @@ -2575,7 +2794,8 @@ WOK when /sql/ when /xml|plaintext|ascii/; @env_out="#{@env.path.output}/#@fnb" #check change of name to plaintext from ascii else - if defined? @md.sfx_src and @md.sfx_src =~/ss[ftsumc]/ + if defined? @md.sfx_src \ + and @md.sfx_src =~/ss[ftsumc]/ @env_suf='lm' @env_out_root=@env.path.output @env_out="#{@env.path.output}/#@fnb" @@ -2670,7 +2890,8 @@ WOK end end File.mkpath("#{@env.path.webserv}/#{@env.path.stub_pwd}") unless FileTest.directory?("#{@env.path.webserv}/#{@env.path.stub_pwd}") - if homepage_path and FileTest.file?(homepage_path) + if homepage_path \ + and FileTest.file?(homepage_path) cp(homepage_path,"#{@env.path.webserv}/#{@env.path.stub_pwd}/index.html") cp(homepage_path,"#{@env.path.webserv}/#{@env.path.stub_pwd}/toc.html") else @@ -2726,7 +2947,8 @@ WOK def cp_css File.mkpath("#{@env.path.output}/#{@env.path.style}") unless FileTest.directory?("#{@env.path.output}/#{@env.path.style}") css_path=['/etc/sisu/css',"#@home/.sisu/css","#@pwd/_sisu/css"] #BROKEN - if defined? @rc['permission_set']['css_modify'] and @rc['permission_set']['css_modify'] + if defined? @rc['permission_set']['css_modify'] \ + and @rc['permission_set']['css_modify'] tell=SiSU_Screen::Ansi.new(@cmd,"modify is css set to: #{@rc['permission_set']['css_modify']}") css_path.each do |x| if FileTest.directory?(x) -- cgit v1.2.3 From 8e092e0f3acc154f60f296419d1fab4d59f65e53 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 15 Oct 2007 19:22:03 +0100 Subject: regex matching of images, (and rearrangement of conditionals) --- lib/sisu/v0/composite.rb | 7 +-- lib/sisu/v0/param.rb | 104 +++++++++++++++++++++++++++++++------------- lib/sisu/v0/remote.rb | 8 ++-- lib/sisu/v0/sisupod_make.rb | 23 ++++++---- 4 files changed, 97 insertions(+), 45 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/composite.rb b/lib/sisu/v0/composite.rb index 4768522a..ebad049e 100644 --- a/lib/sisu/v0/composite.rb +++ b/lib/sisu/v0/composite.rb @@ -148,8 +148,8 @@ module SiSU_Assemble end def insertion(fni,insert_array) file={ :prepared=>[],:images=>[] } - rgx_image=/([a-zA-Z0-9._-]+?\.(?:png|jpg|gif))/ - #file[:prepared] << "#% Date " << "\n" + rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + #rgx_image=/([a-zA-Z0-9._-]+?\.(?:png|jpg|gif))/ file[:prepared] << "\n% |#{fni}|@|^|>>ok\n" @code_flag=false insert_array.each do |i| @@ -202,7 +202,8 @@ module SiSU_Assemble @@imager[image_uri] ||=[] @@imager[image_uri] << file[:images] file[:prepared] - elsif loadfile =~ /\.ss[ti]$/ and FileTest.file?(loadfile) + elsif loadfile =~ /\.ss[ti]$/ \ + and FileTest.file?(loadfile) insert_array=IO.readlines(loadfile,'') file=insertion(loadfile,insert_array) file[:prepared] diff --git a/lib/sisu/v0/param.rb b/lib/sisu/v0/param.rb index fec253d0..8a95942a 100644 --- a/lib/sisu/v0/param.rb +++ b/lib/sisu/v0/param.rb @@ -88,7 +88,8 @@ module SiSU_Param @@fns=@fns @@md=nil end - if @@md.nil? or @cmd =~/M/ #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file + if @@md.nil? \ + or @cmd =~/M/ #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file if File.exist?(@pstorefile) param_msg='Parameters from pstore' retrieve_store=PStore.new(@pstorefile) @@ -127,7 +128,7 @@ module SiSU_Param @markup=@markup_instruction #use @markup_instruction @doc,@fn,@make_italic,@make_bold,@tag_hash,@ec={},{},{},{},{},{},{} @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} - @rgx_image=/\{\s*(\S+?\.(?:png|jpg|gif))/ + @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg begin @@ -153,7 +154,8 @@ module SiSU_Param @prog=SiSU_Env::Info_settings.new @sys=SiSU_Env::System_call.new @env=SiSU_Env::Info_env.new(@fns) #watch - if @prog.wc and @sys.wc + if @prog.wc \ + and @sys.wc wc=%x{wc #{fns}} wca=wc.scan(/\d+/) @wc_lines,@wc_words,@wc_bytes=wca[0].to_i,wca[1].to_i,wca[2].to_i @@ -226,9 +228,12 @@ module SiSU_Param end ok=if s_a.to_i > sm_a.to_i true - elsif s_a.to_i == sm_a.to_i and s_b.to_i >= sm_b.to_i + elsif s_a.to_i == sm_a.to_i \ + and s_b.to_i >= sm_b.to_i true - elsif s_a.to_i == sm_a.to_i and s_b.to_i == sm_b.to_i and s_c.to_i >= sm_c.to_i + elsif s_a.to_i == sm_a.to_i \ + and s_b.to_i == sm_b.to_i \ + and s_c.to_i >= sm_c.to_i true else false end @@ -248,7 +253,8 @@ module SiSU_Param end @code_flag=false fns_array.each do |para| #% Scan document - if para !~/^\%+\s/ and para =~/= 0.38) or (para=~/^1~/ and @markup_version < 0.38) + if (para=~/^:?A~/ and @markup_version >= 0.38) \ + or (para=~/^1~/ and @markup_version < 0.38) if @title.nil? @title=para[/^:?[A1]~\S*(.+)$/m,1] @html_title=@title.gsub(/(

|

|
|
)/,'') @@ -580,15 +596,25 @@ module SiSU_Param if para =~/table\{|/i; @flag_tables=true end end - if (@markup_version >= 0.38 and para =~/^:?A~/) or (@markup_version < 0.38 and para =~/^1~/) + if (@markup_version >= 0.38 and para =~/^:?A~/) \ + or (@markup_version < 0.38 and para =~/^1~/) @set_heading_top=true end - if (@markup_version >= 0.38 and para =~/^1~/) or (@markup_version < 0.38 and para =~/^4~/) + if (@markup_version >= 0.38 and para =~/^1~/) \ + or (@markup_version < 0.38 and para =~/^4~/) m=nil - if @markup_version >= 0.38 and para =~/^1~(\S+)\s+(.+)$/; m,t=$1,$2 - elsif @markup_version < 0.38 and para =~/^4~(\S+)\s+(.+)$/; m,t=$1,$2 - elsif @markup_version >= 0.38 and para =~/^1~\s+(.+)$/; t=$1 - elsif @markup_version < 0.38 and para =~/^4~\s+(.+)$/; t=$1 + if @markup_version >= 0.38 \ + and para =~/^1~(\S+)\s+(.+)$/ + m,t=$1,$2 + elsif @markup_version < 0.38 \ + and para =~/^4~(\S+)\s+(.+)$/ + m,t=$1,$2 + elsif @markup_version >= 0.38 \ + and para =~/^1~\s+(.+)$/ + t=$1 + elsif @markup_version < 0.38 \ + and para =~/^4~\s+(.+)$/ + t=$1 end unless @heading_seg_first_flag # extract first segment name @heading_seg_first=t @@ -597,7 +623,10 @@ module SiSU_Param if m # list all segment names @seg_names << m @set_heading_seg=true - @seg_autoname_safe=false if m=~/^\d{1,3}/ and m !~/^0/ + if m=~/^\d{1,3}/ \ + and m !~/^0/ + @seg_autoname_safe=false + end end end @ec[:image] << para.scan(@rgx_image).uniq if para =~@rgx_image #embedded content @@ -650,7 +679,8 @@ module SiSU_Param @markup.gsub!(/num_top\s*=\s*([\dA-C])/,"num_top=#@num_top") @markup.gsub!(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#@toc_lev_limit") end - if @mod.inspect =~/--papersize[=-]\S+|--pdf[=-]\S+/ or @mod.inspect =~/--(?:a4|letter|legal|book|a5|b5)\b/i #command line config/header override + if @mod.inspect =~/--papersize[=-]\S+|--pdf[=-]\S+/ \ + or @mod.inspect =~/--(?:a4|letter|legal|book|a5|b5)\b/i #command line config/header override @papersize=determine_papersize(@mod.inspect) end if @sys.openssl !=false @@ -672,7 +702,8 @@ module SiSU_Param end @dc_publisher ||= "#@@publisher (this copy)" fn_set_lang=SiSU_Env::Standardise_language.new.file_to_language(@fns) - unless @dc_language[:code] and @dc_language[:name] + unless @dc_language[:code] \ + and @dc_language[:name] lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml @dc_language[:code] ||= lang.code @dc_language[:name] ||= lang.title @@ -694,13 +725,15 @@ module SiSU_Param @lang.uniq! @fn=SiSU_Env::Env_call.new(@fns).lang(fn_set_lang[:c]) @dc_identifier="#{@env.url.root}/#@fnb/#{@fn[:toc]}" #DC note constructed dc identifier - if @en[:note] > 0 and @en[:sum] > 0 + if @en[:note] > 0 \ + and @en[:sum] > 0 if @en[:sum] > 0 else tell=SiSU_Screen::Ansi.new(@cmd,'both endnote styles used',"~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}") tell.warn if @cmd !~/q/ end end - if @en[:mark] != @en[:note] and @en[:note] > 0 + if @en[:mark] != @en[:note] \ + and @en[:note] > 0 @en[:mismatch]=@en[:note] - @en[:mark] SiSU_Screen::Ansi.new(@cmd,'endnote number mismatch',"endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})").warn if @cmd !~/q/ footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') @@ -718,7 +751,9 @@ module SiSU_Param if @title.nil? title_trigger=nil fns_array.each do |para| - if para !~/0~|@\S+:[+-]?\s/ and para =~/\S/ and title_trigger.nil? + if para !~/0~|@\S+:[+-]?\s/ \ + and para =~/\S/ \ + and title_trigger.nil? @title=para[/(\S.+)/m,1] @html_title=@title.gsub(/(

|

|
|
)/,'') @title.chomp!("\n") @@ -760,7 +795,9 @@ module SiSU_Param end if doc_struct[:article] > 2 #%~level 4 @lv4=/^(?:Article|ARTICLE)\b/ - elsif doc_struct[:chapter] > 2 and doc_struct[:article] and doc_struct[:article] < 3 + elsif doc_struct[:chapter] > 2 \ + and doc_struct[:article] \ + and doc_struct[:article] < 3 @lv4=/^(?:Chapter|CHAPTER)\b/ elsif doc_struct[:clause] > 2 @lv4=/^(?:Clause|CLAUSE)\b/ @@ -770,13 +807,18 @@ module SiSU_Param if doc_struct[:section] > 2 #%~level 3 @lv3=/^(?:Section|SECTION)\b/ end - if doc_struct[:chapter] > 2 and doc_struct[:article] and doc_struct[:article] > 2 + if doc_struct[:chapter] > 2 \ + and doc_struct[:article] \ + and doc_struct[:article] > 2 @lv2=/^(?:Chapter|CHAPTER)\b/ end - if doc_struct[:part] > 2 and @lv[2].nil? + if doc_struct[:part] > 2 \ + and @lv[2].nil? @lv2=/^(?:Part|PART)\b/ end - if doc_struct[:part] > 2 and @lv[2].to_s !~/Part/ and @lv[1].nil? + if doc_struct[:part] > 2 \ + and @lv[2].to_s !~/Part/ \ + and @lv[1].nil? @lv1=/^(Part|PART)\b/ end end diff --git a/lib/sisu/v0/remote.rb b/lib/sisu/v0/remote.rb index 2a45e3cb..efa49dc0 100644 --- a/lib/sisu/v0/remote.rb +++ b/lib/sisu/v0/remote.rb @@ -113,7 +113,7 @@ module SiSU_Remote require 'open-uri' require 'pp' require "#{SiSU_lib}/composite" - @rgx_image=/\{\s*(\S+?\.(?:png|jpg|gif))/ + @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_skin=/(?:0~|@)skin:?\s+(\S+)/ #@rgx_skin=/^0~skin\s+(\S+)/ threads=[] for requested_page in @get_s @@ -133,10 +133,12 @@ module SiSU_Remote images << r.scan(@rgx_image).uniq if r =~@rgx_image downloaded_file << r end - if skin and skin.length > 0 + if skin \ + and skin.length > 0 SiSU_Assemble::Remote_image.new.download_doc_skin(skin) end - if images and images.length > 1 + if images \ + and images.length > 1 images.flatten!.uniq! @msg,@msgs='downloading images:', [ images.join(',') ] @tell.call.warn unless @opt.cmd =~/q/ diff --git a/lib/sisu/v0/sisupod_make.rb b/lib/sisu/v0/sisupod_make.rb index 392aee7d..277358c4 100644 --- a/lib/sisu/v0/sisupod_make.rb +++ b/lib/sisu/v0/sisupod_make.rb @@ -158,7 +158,7 @@ module SiSU_Doc end def sisupod_build #see also sisupod in sysenv @rgx_rb_image=/["'](\S+?\.(?:png|jpg|gif))["']/ - @rgx_image=/\{\s*(\S+?\.(?:png|jpg|gif))/ + @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ @rgx_skin=/^(?:@skin:|0~skin)\s+(\S+)/ @rgx_doc_import=/^%\s\s*\|(\S+?\.ss[ti])\|@\|\^\|>>ok/ use_file=if @opt.fns =~/(?:\.ssm|\.ssm\.sst)$/; "#{@env.path.composite_file}/#{@opt.fnb}.ssm.sst" @@ -170,12 +170,14 @@ module SiSU_Doc if f !~/^%\s/ skin << f.scan(@rgx_skin).uniq.flatten if f =~@rgx_skin images << f.scan(@rgx_image).uniq if f =~@rgx_image - elsif f =~/^%\s/ and @opt.fns =~/\.ssm\.sst$/ + elsif f =~/^%\s/ \ + and @opt.fns =~/\.ssm\.sst$/ doc_import << f.scan(@rgx_doc_import).uniq if f =~@rgx_doc_import end end docskin=nil - if skin and skin.length > 0 + if skin \ + and skin.length > 0 docskin=skin.pop.flatten.join skin_source=select(docskin) else @@ -187,8 +189,10 @@ module SiSU_Doc docskin=[docskin_with_path.gsub(/.+?\/(skin_\S+?)\.rb/,'\1')] docskin='skin_sisupod' end - if skin_source and docskin #imperfect, revisit - unless skin_source[:name].nil? or skin_source[:name].empty? + if skin_source \ + and docskin #imperfect, revisit + unless skin_source[:name].nil? \ + or skin_source[:name].empty? cp_r(skin_source[:name],"#{docskin_place}/#{docskin}.rb") skinfile_array=IO.readlines(skin_source[:name],'') para_images=[] @@ -202,7 +206,8 @@ module SiSU_Doc end #1. mapping in doc dir? #2. need images used by skin, scan skin?? - if images and images.length > 1 + if images \ + and images.length > 1 images.flatten!.uniq! image_path_pwd='_sisu/image' path_pod_conf="#{@env.path.processing}/sisupod/_sisu" @@ -228,12 +233,14 @@ module SiSU_Doc end end x=@env.document_language_versions_found #check multiple document language versions (param not used) - if doc_import.flatten.length > 0 and @opt.fns =~/\.ssm\.sst$/ + if doc_import.flatten.length > 0 \ + and @opt.fns =~/\.ssm\.sst$/ doc_import.flatten.each do |f| cp_r("#{@env.path.pwd}/#{f}","#{@env.path.processing}/sisupod/#{f}") end end - if x[:f] and x[:f].length > 1 #store multiple document language versions, sisupod + if x[:f] \ + and x[:f].length > 1 #store multiple document language versions, sisupod x[:f].each do |f| cp_r("#{@env.path.pwd}/#{f}","#{@env.path.processing}/sisupod/#{f}") end -- cgit v1.2.3 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/cgi_pgsql.rb | 3 +- lib/sisu/v0/cgi_sql_common.rb | 9 +++-- lib/sisu/v0/cgi_sqlite.rb | 6 ++- lib/sisu/v0/concordance.rb | 12 ++++-- lib/sisu/v0/dal.rb | 64 +++++++++++++++++++++--------- lib/sisu/v0/dal_doc_str.rb | 30 ++++++++++---- lib/sisu/v0/dal_doc_str_code.rb | 37 +++++++++++------ lib/sisu/v0/dal_doc_str_tables.rb | 12 ++++-- lib/sisu/v0/dal_syntax.rb | 41 +++++++++++++------ lib/sisu/v0/db_import.rb | 67 ++++++++++++++++++++----------- lib/sisu/v0/db_load_tuple.rb | 10 ++++- lib/sisu/v0/dbi.rb | 20 +++++++--- lib/sisu/v0/defaults.rb | 6 ++- lib/sisu/v0/digests.rb | 15 ++++--- lib/sisu/v0/help.rb | 5 ++- lib/sisu/v0/html.rb | 43 ++++++++++++++------ lib/sisu/v0/html_format.rb | 14 +++++-- lib/sisu/v0/html_format_css.rb | 3 +- lib/sisu/v0/html_promo.rb | 31 ++++++++++----- lib/sisu/v0/html_scroll.rb | 19 ++++++--- lib/sisu/v0/html_segments.rb | 24 ++++++++---- lib/sisu/v0/html_tune.rb | 9 +++-- lib/sisu/v0/hub.rb | 72 ++++++++++++++++++++++------------ lib/sisu/v0/manifest.rb | 28 ++++++++----- lib/sisu/v0/manpage.rb | 26 ++++++++---- lib/sisu/v0/odf.rb | 37 ++++++++++++----- lib/sisu/v0/options.rb | 7 +++- lib/sisu/v0/param_identify_markup.rb | 15 ++++--- lib/sisu/v0/plaintext.rb | 46 +++++++++++++++------- lib/sisu/v0/rexml.rb | 3 +- lib/sisu/v0/screen_text_color.rb | 8 ++-- lib/sisu/v0/share_src_kdissert.rb | 3 +- lib/sisu/v0/shared_html_lite.rb | 6 ++- lib/sisu/v0/shared_txt.rb | 12 ++++-- lib/sisu/v0/shared_xml.rb | 6 ++- lib/sisu/v0/sitemaps.rb | 3 +- lib/sisu/v0/sst_convert_markup.rb | 19 +++++---- lib/sisu/v0/sst_do_inline_footnotes.rb | 25 ++++++++---- lib/sisu/v0/sst_identify_markup.rb | 35 +++++++++++------ lib/sisu/v0/sst_to_s_xml_dom.rb | 38 ++++++++++++++---- lib/sisu/v0/sst_to_s_xml_node.rb | 31 +++++++++++---- lib/sisu/v0/sst_to_s_xml_sax.rb | 10 ++++- lib/sisu/v0/texinfo.rb | 27 ++++++++----- lib/sisu/v0/texpdf.rb | 20 +++++++--- lib/sisu/v0/texpdf_format.rb | 33 ++++++++++------ lib/sisu/v0/urls.rb | 43 ++++++++++++++------ lib/sisu/v0/wikispeak.rb | 17 +++++--- lib/sisu/v0/xhtml.rb | 20 +++++++--- lib/sisu/v0/xml.rb | 19 ++++++--- lib/sisu/v0/xml_dom.rb | 46 +++++++++++++++++----- 50 files changed, 796 insertions(+), 339 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/cgi_pgsql.rb b/lib/sisu/v0/cgi_pgsql.rb index d4c620a5..796c49c8 100644 --- a/lib/sisu/v0/cgi_pgsql.rb +++ b/lib/sisu/v0/cgi_pgsql.rb @@ -73,7 +73,8 @@ module SiSU_CGI_pgsql if @sys.psql available_db_table=`psql --list` # system call requires psql available_db=available_db_table.scan(/(SiSU_\S+)/) if not available_db_table.nil? - if available_db and available_db.class == Array + if available_db \ + and available_db.class == Array available_db.flatten.each do |x| serve << x.gsub(/SiSU_(\S+)/,'\1') end diff --git a/lib/sisu/v0/cgi_sql_common.rb b/lib/sisu/v0/cgi_sql_common.rb index 73cb2342..7df73901 100644 --- a/lib/sisu/v0/cgi_sql_common.rb +++ b/lib/sisu/v0/cgi_sql_common.rb @@ -815,9 +815,12 @@ module SiSU_CGI_sql if @text_search_flag if cgi['view']=~/text/ #% txt body text=if c['suffix'] !~/1/ #seg - if @search_for.text1 =~/\S+/ or q['s1'] =~/\S+/ #% only this branch is working !! - unescaped_search=if @search_for.text1 =~/\S+/; CGI.unescape(@search_for.text1) - elsif q['s1'] =~/\S+/; CGI.unescape(q['s1']) + if @search_for.text1 =~/\S+/ \ + or q['s1'] =~/\S+/ #% only this branch is working !! + unescaped_search=if @search_for.text1 =~/\S+/ + CGI.unescape(@search_for.text1) + elsif q['s1'] =~/\S+/ + CGI.unescape(q['s1']) else nil end @search_regx=if unescaped_search #check diff --git a/lib/sisu/v0/cgi_sqlite.rb b/lib/sisu/v0/cgi_sqlite.rb index 7a8bfe41..27c20163 100644 --- a/lib/sisu/v0/cgi_sqlite.rb +++ b/lib/sisu/v0/cgi_sqlite.rb @@ -68,8 +68,10 @@ module SiSU_CGI_sqlite def sqlite serve=[] Dir.foreach(@env.path.webserv) do |x| - if x !~/^\./ and FileTest.directory?("#{@env.path.webserv}/#{x}") - if FileTest.file?("#{@env.path.webserv}/#{x}/sisu_sqlite.db"); serve << x unless x =~/^_\S+/ + if x !~/^\./ \ + and FileTest.directory?("#{@env.path.webserv}/#{x}") + if FileTest.file?("#{@env.path.webserv}/#{x}/sisu_sqlite.db") + serve << x unless x =~/^_\S+/ end end end diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index d60ffc2f..08b25195 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -241,7 +241,8 @@ WOK end if line =~@rxp_to; toy=line[@rxp_to,1] end - if toy =~/\d+/ and toy !~/^0$/ + if toy =~/\d+/ \ + and toy !~/^0$/ for word in line.scan(@rgx_scanlist) #%take in word or other match word=nil if word =~@rxp_excluded0 #watch word=nil if word =~@rxp_excluded1 #watch @@ -260,12 +261,17 @@ WOK word.gsub!(/^(\d+\.?)+$/, '') word=nil if word =~/^\s*$/ #watch if word - word.capitalize! unless word =~/[A-Z][A-Z]/ or word =~/\w+\s\w+/ + unless word =~/[A-Z][A-Z]/ \ + or word =~/\w+\s\w+/ + word.capitalize! + end #word.downcase! if word =~lesser #word.capitalize! if word =~greater @freq[word] +=1 @word_map[word] ||= [] - if line !~@rxp_lv1 and line !~@rxp_lv2 and line !~@rxp_lv3 + if line !~@rxp_lv1 \ + and line !~@rxp_lv2 \ + and line !~@rxp_lv3 @word_map[word] << location_seg("#@seg\##{toy}",toy) else @word_map[word] << case line diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index 3631a77c..0b445832 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -448,7 +448,8 @@ module SiSU_DAL para.gsub!(/^@(\S+?):\s+/,'0~\1 ') para.gsub!(/^@(\S+?):([+-])\s+/,'0~\1\2 ') end - if para =~/<:insert\d+!?>/ and para !~/^%\s+/ + if para =~/<:insert\d+!?>/ \ + and para !~/^%\s+/ @skin.select ins=SiSU_Viz::Inserts.new case para @@ -530,7 +531,8 @@ module SiSU_DAL @tuned_file << para end # debug 2003w46 adding revision control info - if @md.flag_auto_endnotes and @md.flag_separate_endnotes_make + if @md.flag_auto_endnotes \ + and @md.flag_separate_endnotes_make @tuned_file << "\n4~endnotes Endnotes <-#> <~0;0:0;u0>" end @tuned_file << "\n" @@ -549,14 +551,16 @@ module SiSU_DAL para.gsub!(/^#{num}~ /,"#{num}~#{title_no} ") #where title contains title number else para.gsub!(/^#{num}~ /,"#{num}~#{title_no} #{title_no} ") #main, where title number is to be provided end - if @md.toc_lev_limit and @md.toc_lev_limit < num + if @md.toc_lev_limit \ + and @md.toc_lev_limit < num para.gsub!(/^[5-8]~(?:~\S+)?\s*/,'!_ ') end para end def auto_number_heading_ie_title(data) #also does some segment naming @tuned_file=[] - if @md.markup =~/num_top/ or @md.num_top # watch, 2003w23 + if @md.markup =~/num_top/ \ + or @md.num_top # watch, 2003w23 input="#{@md.markup}"[/num_top\=([1-6])/,1] if @md.markup input||=@md.num_top if @md.num_top !~/^$/ end @@ -565,8 +569,12 @@ module SiSU_DAL no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3) t_not=0 data.each do |para| #@md.seg_names << [additions to segment names] - if (@md.markup =~/num_top/ or (@md.num_top and @md.num_top !~/^$/)) and para !~/^0~/ - if (para =~/^(?:#{no1}|^#{no2}|^#{no3}#{no4})~#/ and para !~/^4~endnotes?/) + if (@md.markup =~/num_top/ \ + or (@md.num_top \ + and @md.num_top !~/^$/)) \ + and para !~/^0~/ + if (para =~/^(?:#{no1}|^#{no2}|^#{no3}#{no4})~#/ \ + and para !~/^4~endnotes?/) t_not+=1 #; t_no2=0; t_no3=0 para.gsub!(/^(#{no1})~#\s*/,"\\1~ps#{t_not} ") para.gsub!(/^(#{no2})~#\s*/,"\\1~ps#{t_not} ") @@ -577,11 +585,14 @@ module SiSU_DAL @subnumber=1 @subnumber=0 if para =~/#{no1}~/ end - if para =~/^[0-6]~[ \w-]/ and para !~ /(?:[0-6]~[\w-]+-|4~endnotes|^[0-6]~([a-z_\.]+)\s+[\d.]+)\s/ and para !~/<~#>|<-#>/ + if para =~/^[0-6]~[ \w-]/ \ + and para !~ /(?:[0-6]~[\w-]+-|4~endnotes|^[0-6]~([a-z_\.]+)\s+[\d.]+)\s/ \ + and para !~/<~#>|<-#>/ if para =~/^#{no1}~/ t_no1+=1; t_no2=0; t_no3=0 title_no="#{t_no1}" - if not @md.seg_names.nil? and not @md.seg_names.include?(title_no) + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(title_no) para.gsub!(/^#{no1}~\s+(\S+)#/,"#{no1}~#{title_no} \\1 #{title_no} ") #shift placement of auto-number to after first word, e.g. Article # not # Article, added on occasion of ABF (20040329) para.gsub!(/^#{no1}\{\s+(Article|Clause|Section)\s+#/i,%{#{no1}~#{title_no} \\1 #{title_no}. }) unless para =~/^#{no1}~\s+[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review @@ -677,18 +688,22 @@ module SiSU_DAL art_filename_auto=1 @counter=1 @unique_auto_name=[] - puts 'manual segment names, numbers used as names, risk warning (segmented html)' if not @md.seg_autoname_safe and @md.cmd =~/[MV]/ + if not @md.seg_autoname_safe and @md.cmd =~/[MV]/ + puts 'manual segment names, numbers used as names, risk warning (segmented html)' + end data.each do |para| para=SiSU_document_structure::Structure.new(@md,para).structure_markup if para =~/^[456]~ / - if para=~/^4/ and not @md.set_heading_seg + if para=~/^4/ \ + and not @md.set_heading_seg @md.set_heading_seg=true end if para =~/^[456]~(?:\s\S+)?\s+([\d.,:-]+)/m #heading starts with a recognised numeric or word followed by a recognised numerical construct, use that as name pattern=$1 pattern.gsub!(/(?:[:,-]|\W)/,'.') pattern.gsub!(/\.$/,'') - if not @md.seg_names.nil? and not @md.seg_names.include?(pattern) + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(pattern) para.gsub!(/^([456])~\s*/,"\\1~#{pattern} ") @md.seg_names << pattern else puts 'warn, there may be a conflicting numbering scheme' if @md.cmd =~/[VM]/ @@ -698,7 +713,8 @@ module SiSU_DAL pattern=$1 pattern.gsub!(/(?:[:,-]|\W)/,'.') pattern.gsub!(/\.$/,'') - if not @md.seg_names.nil? and not @md.seg_names.include?(pattern) + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(pattern) para.gsub!(/^(4)~\s*/,"\\1~#{pattern} ") @md.seg_names << pattern else @@ -707,7 +723,8 @@ module SiSU_DAL end end if para =~/^4~\s+/ #if still not segment name, provide a numerical one - if not @md.seg_names.nil? and not @md.seg_names.include?(art_filename_auto) + if not @md.seg_names.nil? \ + and not @md.seg_names.include?(art_filename_auto) para.gsub!(/^4~\s+/,%{4~_#{art_filename_auto} }) @md.seg_names << art_filename_auto else puts 'segment name (numbering) error' @@ -715,7 +732,10 @@ module SiSU_DAL art_filename_auto+=1 end end - @tuned_file << if para =~/^([1-6])~/m and (@md.pagenew or @md.pagebreak); m=$1 #watch ref~ + @tuned_file << if para =~/^([1-6])~/m \ + and (@md.pagenew \ + or @md.pagebreak) + m=$1 #watch ref~ para_tmp=[] if @md.pagenew.to_s =~/#{m}/; para_tmp << "<:pn>\n" << para end @@ -738,7 +758,8 @@ module SiSU_DAL @tuned_file=[] data.each do |para| unless @md.set_heading_top - if para !~/^(?:@\S+:|0~\S+)\s/m and para !~/\A\s*\Z/m + if para !~/^(?:@\S+:|0~\S+)\s/m \ + and para !~/\A\s*\Z/m @md.set_heading_top=true head=if @md.title ; "1~ #{@md.title}" else '1~ [no title provided]' @@ -757,7 +778,9 @@ module SiSU_DAL @tuned_file=[] data.each do |para| unless @md.set_heading_seg - if para !~/^(?:@\S+:|0~\S+|[123]~)/m and para !~/\A\s*\Z/m and para !~/<:p[bn]>/ + if para !~/^(?:@\S+:|0~\S+|[123]~)/m \ + and para !~/\A\s*\Z/m \ + and para !~/<:p[bn]>/ @md.set_heading_seg=true head=if @md.title ; "4~seg [#{@md.title}]" else '4~seg [segment]' @@ -776,7 +799,8 @@ module SiSU_DAL @tuned_file=[] data.each do |para| unless @md.set_header_title - if para !~/^%{1,2}\s/m and para !~/\A\s*\Z/m + if para !~/^%{1,2}\s/m \ + and para !~/\A\s*\Z/m @tuned_file << "0~title #{@md.heading_seg_first}" @md.title=@md.heading_seg_first @md.set_header_title=true @@ -957,12 +981,14 @@ module SiSU_DAL end if true #default version information ocnm+=1; ocnv+=1 - if @md.sc_filename and @md.sc_filename.length > 3 + if @md.sc_filename \ + and @md.sc_filename.length > 3 @rc << "#{@tr.sourcefile}: #{@md.sc_filename} <~0;m#{ocnm};v#{ocnv}>" else @rc << "#{@tr.sourcefile}: #{@md.fns} <~0;m#{ocnm};v#{ocnv}>" end ocnm+=1; ocnv+=1 - if @md.file_encoding and @md.file_encoding.length > 3 #translate + if @md.file_encoding \ + and @md.file_encoding.length > 3 #translate @rc << "Filetype: #{@md.file_encoding} <~0;m#{ocnm};v#{ocnv}>" end ocnm+=1; ocnv+=1 diff --git a/lib/sisu/v0/dal_doc_str.rb b/lib/sisu/v0/dal_doc_str.rb index 57b9ca23..bd31f40c 100644 --- a/lib/sisu/v0/dal_doc_str.rb +++ b/lib/sisu/v0/dal_doc_str.rb @@ -151,26 +151,40 @@ module SiSU_document_structure o={} if para =~/\w|\S|<|\(/ if para !~ regex_exclude_ocn_and_node - if node_count_flag or para=~/^1~/ + if node_count_flag \ + or para=~/^1~/ node_count_flag=true end node+=1 if node_count_flag if para !~ regex_exclude_ocn # regex_exclude_large previously excluded unless para=~/<:#>|~#|-#/ # |^\s*\*\s*\*\s*\*\s*$ <-consider leaving un-numbered ocn+=1 - if para=~/^[1-8]~(?:\s+|\S)/ or para =~@md.lv1 or para =~@md.lv2 or para =~@md.lv3 or para =~@md.lv4 or para =~@md.lv5 or para =~@md.lv6 + if para=~/^[1-8]~(?:\s+|\S)/ \ + or para =~@md.lv1 \ + or para =~@md.lv2 \ + or para =~@md.lv3 \ + or para =~@md.lv4 \ + or para =~@md.lv5 \ + or para =~@md.lv6 ocnh+=1 - if para=~/^1~(?:\s+|\S)/ or para =~@md.lv1; ocnh1+=1 + if para=~/^1~(?:\s+|\S)/ \ + or para =~@md.lv1 + ocnh1+=1 ocn_dv,ocn_sp="1:#{ocnh1}","h#{ocnh}" - elsif para=~/^2~(?:\s+|\S)/ or para =~@md.lv2; ocnh2+=1 + elsif para=~/^2~(?:\s+|\S)/ \ + or para =~@md.lv2; ocnh2+=1 ocn_dv,ocn_sp="2:#{ocnh2}","h#{ocnh}" - elsif para=~/^3~(?:\s+|\S)/ or para =~@md.lv3; ocnh3+=1 + elsif para=~/^3~(?:\s+|\S)/ \ + or para =~@md.lv3; ocnh3+=1 ocn_dv,ocn_sp="3:#{ocnh3}","h#{ocnh}" - elsif para=~/^4~(?:\s+|\S)/ or para =~@md.lv4; ocnh4+=1 + elsif para=~/^4~(?:\s+|\S)/ \ + or para =~@md.lv4; ocnh4+=1 ocn_dv,ocn_sp="4:#{ocnh4}","h#{ocnh}" - elsif para=~/^5~(?:\s+|\S)/ or para =~@md.lv5; ocnh5+=1 + elsif para=~/^5~(?:\s+|\S)/ \ + or para =~@md.lv5; ocnh5+=1 ocn_dv,ocn_sp="5:#{ocnh5}","h#{ocnh}" - elsif para=~/^6~(?:\s+|\S)/ or para =~@md.lv6; ocnh6+=1 + elsif para=~/^6~(?:\s+|\S)/ \ + or para =~@md.lv6; ocnh6+=1 ocn_dv,ocn_sp="6:#{ocnh6}","h#{ocnh}" end else diff --git a/lib/sisu/v0/dal_doc_str_code.rb b/lib/sisu/v0/dal_doc_str_code.rb index c45d95f1..9032d54e 100644 --- a/lib/sisu/v0/dal_doc_str_code.rb +++ b/lib/sisu/v0/dal_doc_str_code.rb @@ -82,19 +82,23 @@ module SiSU_document_structure_code @@flag['code']=true @@counter=1 para.gsub!(/^code\{.*/,'<:code>') - elsif para =~/^(?:poem)\{/ and not @@flag['code'] + elsif para =~/^(?:poem)\{/ \ + and not @@flag['code'] @@flag['poem']=true para.gsub!(/^(poem)\{.*/,'<:verse>') - elsif para =~/^(?:alt|group)\{/ and not @@flag['code'] #group not tested, stub 2005 + elsif para =~/^(?:alt|group)\{/ \ + and not @@flag['code'] #group not tested, stub 2005 @@flag['group']=true para.gsub!(/^(alt|group)\{.*/,'<:\1>') end if @@flag['code'] - if @@flag['code'] and para =~/^\}code/ + if @@flag['code'] \ + and para =~/^\}code/ para.gsub!(/^\}code.*/,'<:code-end>') @@flag['code']=false end - if @@flag['code'] or para =~/<:code-end>/ #and para =~/\S/ + if @@flag['code'] \ + or para =~/<:code-end>/ #and para =~/\S/ sub_array=if para !~/<:code(?:-end)?>/; para.dup + '<:br>' else para.dup end @@ -104,15 +108,22 @@ module SiSU_document_structure_code SiSU_document_structure_code::Code.new(@md,@line_mode).code_lines('code') para=@line_mode.join end - elsif ( @@flag['poem'] or @@flag['group'] ) and not @@flag['code'] - if @@flag['poem'] and para =~/^\}(?:poem)/ + elsif ( @@flag['poem'] \ + or @@flag['group'] ) \ + and not @@flag['code'] + if @@flag['poem'] \ + and para =~/^\}(?:poem)/ para.gsub!(/^\}(poem).*/,"\n<:verse-end>") @@flag['poem']=false - elsif ( @@flag['group'] and para =~/^\}(?:alt|group)/ ) and not @@flag['code'] + elsif ( @@flag['group'] \ + and para =~/^\}(?:alt|group)/ ) \ + and not @@flag['code'] para.gsub!(/^\}(alt|group).*/,'<:\1-end>') @@flag['group']=false end - if @@flag['poem'] or @@flag['group'] and para =~/\S/ \ + if @@flag['poem'] \ + or @@flag['group'] \ + and para =~/\S/ \ and para !~/<:(verse|code|alt|group)(-end)?>/ \ and not @@flag['code'] sub_array=para.dup @@ -121,7 +132,8 @@ module SiSU_document_structure_code else 'group' end SiSU_document_structure_code::Code.new(@md,@line_mode).code_lines(type) - div=if @@flag['poem'] and @verse_count > 0 + div=if @@flag['poem'] \ + and @verse_count > 0 "\n" + '<:verse-end>' + "\n\n" + '<:verse>' else '' end @@ -130,7 +142,9 @@ module SiSU_document_structure_code else para end end - if @@flag['code'] or @@flag['poem'] or @@flag['group'] + if @@flag['code'] \ + or @@flag['poem'] \ + or @@flag['group'] @tuned_group << para if para =~/\S+/ elsif para =~/<:(?:code|alt|group|verse)-end>/ @verse_count=0 @@ -150,7 +164,8 @@ module SiSU_document_structure_code def code_lines(type='') data=@data data.each do |line| - if line =~/\S/ and line !~/^code\{|^\}code|<:code.+/ + if line =~/\S/ \ + and line !~/^code\{|^\}code|<:code.+/ line.gsub!(/\s\s/,'  ') line.gsub!(/^/,'<:codeline>') if type=='code' # try sort for texpdf special case if line =~/(?:https?|file|ftp):\/\/\S+$/ diff --git a/lib/sisu/v0/dal_doc_str_tables.rb b/lib/sisu/v0/dal_doc_str_tables.rb index e0d019bb..52b53e4f 100644 --- a/lib/sisu/v0/dal_doc_str_tables.rb +++ b/lib/sisu/v0/dal_doc_str_tables.rb @@ -131,7 +131,8 @@ module SiSU_document_structure_tables if para =~/^\{(?:t|table)(?:~h)?(?:\sc\d+;)?[\d; ]*\}/ @tuned_file << table_visual(para) @tuned_file=@tuned_file.flatten - elsif @@flag['table_to'] or para[/^table\{(?:~h)?/] + elsif @@flag['table_to'] \ + or para[/^table\{(?:~h)?/] if para[/table\{(?:~h)?\s+c(\d+;.+)/] instructions=$1 @@column=instructions.split(/;\s*/) @@ -140,7 +141,8 @@ module SiSU_document_structure_tables para.gsub!(/^table\{\s+(c\d+?;.+?)$/,'') @@flag['table_to']=true end - if @@flag['table_to'] and para =~/\}table/ + if @@flag['table_to'] \ + and para =~/\}table/ para.gsub!(/^\}table\s*$/,"\n") para.gsub!(/\n/,' ') #newlines taken out para.strip! @@ -151,7 +153,8 @@ module SiSU_document_structure_tables @tuned_table=[] @@flag['table_to']=false end - if @@flag['table_to'] and para =~/\S/ + if @@flag['table_to'] \ + and para =~/\S/ @@counter=1 sub_array=para.dup @@line_mode=sub_array.scan(/.+/) @@ -174,7 +177,8 @@ module SiSU_document_structure_tables def tr_td data=@data data.each do |line| - if @@counter <= @@columns.to_i and line !~/(\}T\s*$|<:table[-_](close|end)>|)/ + if @@counter <= @@columns.to_i \ + and line !~/(\}T\s*$|<:table[-_](close|end)>|)/ line.gsub!(/(.+)/,"¡¡#{@@column[@@counter]}¡\\1") unless line =~/)?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} bold_line=%q{^!_\s.+?(?:
|\n|$)} - @line_scan_ital=if defined? @md.make_italic[:str] and defined? @vz.markup_make_italic[:str] + @line_scan_ital=if defined? @md.make_italic[:str] \ + and defined? @vz.markup_make_italic[:str] /#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|(?:#{@md.make_italic[:str]}|#{@vz.markup_make_italic[:str]})#{tail_m_ital}|\S+|\n/ elsif defined? @md.make_italic[:str] /#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|#{@md.make_italic[:str]}#{tail_m_ital}|\S+|\n/ @@ -80,11 +81,16 @@ module Syntax /#@http_m|#{bold_line}|#@manmkp_ital#{tail_m_ital}|#{@vz.markup_make_italic[:str]}#{tail_m_ital}|\S+|\n/ end @manmkp_bold='^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]' - @line_scan_bold=if (defined? @md.make_bold[:str] and @md.make_bold[:str]) and (defined? @vz.markup_make_bold[:str] and @vz.markup_make_bold[:str]) + @line_scan_bold=if (defined? @md.make_bold[:str] \ + and @md.make_bold[:str]) \ + and (defined? @vz.markup_make_bold[:str] \ + and @vz.markup_make_bold[:str]) /#@http_m|#{bold_line}|(?:#@manmkp_bold|#{@md.make_bold[:str]}|#{@vz.markup_make_bold[:str]})#{tail_m_bold}|\S+|\n/ - elsif defined? @md.make_bold[:str] and @md.make_bold[:str] + elsif defined? @md.make_bold[:str] \ + and @md.make_bold[:str] /#@http_m|#{bold_line}|(?:#@manmkp_bold|#{@md.make_bold[:str]})#{tail_m_bold}|\S+|\n/ - elsif defined? @vz.markup_make_bold[:str] and @vz.markup_make_bold[:str] + elsif defined? @vz.markup_make_bold[:str] \ + and @vz.markup_make_bold[:str] /#@http_m|#{bold_line}|(?:#@manmkp_bold|#{@vz.markup_make_bold[:str]})#{tail_m_bold}|\S+|\n/ end end @@ -106,8 +112,10 @@ module Syntax end def wordlist_italics(line) line=line.dup - if (defined? @md.make_italic[:str] and @md.make_italic[:str]) \ - or (defined? @vz.markup_make_italic[:str] and @vz.markup_make_italic[:str]) + if (defined? @md.make_italic[:str] \ + and @md.make_italic[:str]) \ + or (defined? @vz.markup_make_italic[:str] \ + and @vz.markup_make_italic[:str]) line= if line !~/^(?:0~|%{1,4}\s|<:code)/ #!~/^(?:[0-6]~|!_|%+\s)/ word=line.scan(@line_scan_ital) word.flatten! @@ -115,9 +123,11 @@ module Syntax line_array=[] word.each do |w| unless /#@manmkp_ital|#@http_m/.match(w) - if defined? @md.make_italic[:regx] and @md.make_italic[:regx] + if defined? @md.make_italic[:regx] \ + and @md.make_italic[:regx] w.gsub!(@md.make_italic[:regx],'\1') - elsif defined? @vz.markup_make_italic and @vz.markup_make_italic + elsif defined? @vz.markup_make_italic \ + and @vz.markup_make_italic w.gsub!(@vz.markup_make_italic,'\1') end end @@ -137,7 +147,10 @@ module Syntax end def wordlist_bold(line) line=line.dup - if (defined? @md.make_bold[:str] and @md.make_bold[:str]) or (defined? @vz.markup_make_bold[:str] and @vz.markup_make_bold[:str]) + if (defined? @md.make_bold[:str] \ + and @md.make_bold[:str]) \ + or (defined? @vz.markup_make_bold[:str] \ + and @vz.markup_make_bold[:str]) line=if line !~/^(?:[0-9]~|%+\s|<:code)/ line_array=[] word=line.scan(@line_scan_bold) @@ -145,9 +158,11 @@ module Syntax word.compact! word.each do |w| unless /#@manmkp_bold|#@http_m/.match(w) - if defined? @md.make_bold[:regx] and @md.make_bold[:regx] #document header: 0~bold [bold word list] + if defined? @md.make_bold[:regx] \ + and @md.make_bold[:regx] #document header: 0~bold [bold word list] w.gsub!(@md.make_bold[:regx],'\1') - elsif defined? @vz.markup_make_bold and @vz.markup_make_bold #defaults and skin adjusted bold word list + elsif defined? @vz.markup_make_bold \ + and @vz.markup_make_bold #defaults and skin adjusted bold word list w.gsub!(@vz.markup_make_bold,'\1') end else @@ -160,7 +175,9 @@ module Syntax else line end else - if line !~/^(?:[0-9]~|%+\s)/ and line =~ /(?:^!_|^[7-9]~)\s+/; embolden(line) + if line !~/^(?:[0-9]~|%+\s)/ \ + and line =~ /(?:^!_|^[7-9]~)\s+/ + embolden(line) end end line diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 91729e3a..6d50fb2b 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -398,7 +398,8 @@ module SiSU_DB_import @col[:lv4]+=1 @col[:lid]+=1 @col[:lev]=4 - @hname=if @col[:seg] and not @col[:seg].to_s.empty? + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? @@hname=@col[:seg].to_s else @@hname end @@ -436,7 +437,8 @@ module SiSU_DB_import @col[:lv5]+=1 @col[:lid]+=1 @col[:lev]=5 - @hname=if @col[:seg] and not @col[:seg].to_s.empty? + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? @@hname=@col[:seg].to_s else @@hname end @@ -474,7 +476,8 @@ module SiSU_DB_import @col[:lv6]+=1 @col[:lid]+=1 @col[:lev]=6 - @hname=if @col[:seg] and not @col[:seg].to_s.empty? + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? @@hname=@col[:seg].to_s else @@hname end @@ -507,7 +510,8 @@ module SiSU_DB_import @col[:lid]+=1 txt='' txt,@col[:ocn],@col[:ocnd],@col[:ocns],@col[:digest_clean],@col[:digest_all]=(/(.+?)<~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)><([0-9a-f]{#{@@dl}}):([0-9a-f]{#{@@dl}})>/m).match(data).captures - @hname=if @col[:seg] and not @col[:seg].to_s.empty? + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? @@hname=@col[:seg].to_s else @@hname end @@ -523,7 +527,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - if @sql_type=~/pg/ and txt.size > (document_clean - 1) #% examine pg build & remove limitation + if @sql_type=~/pg/ \ + and txt.size > (document_clean - 1) #% examine pg build & remove limitation puts "\n\nTOO LARGE (TXT - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nTEXT BODY\n#{@col[:body].size} object #{@col[:ocn]} -> #{@col[:body].slice(0..500)}") @@ -700,54 +705,72 @@ module SiSU_DB_import out=@env.path.output markup,meta,latex,plaintext,html_toc,html_doc,xml_sax,xml_dom,pdf_p,pdf_l,concordance,sisupod='','','','','','','','','','','','' markup_li,meta_li,latex_li,plaintext_li,html_li,xml_sax_li,xml_dom_li,pdf_p_li,pdf_l_li,concordance_li,sisupod_li='','','','','','','','','','','' - if @fnb.empty? or @fnb.nil?; p 'file output path error' #remove + if @fnb.empty? \ + or @fnb.nil? + p 'file output path error' #remove end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:plain]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:plain]}")==true) plaintext,plaintext_li='plaintext,', "'#{base}/#@fnb/#{@md.fn[:plain]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:toc]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:toc]}")==true) html_toc,html_toc_li='html_toc,', "'#{base}/#@fnb/#{@md.fn[:toc]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:doc]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:doc]}")==true) html_doc,html_doc_li='html_doc,', "'#{base}/#@fnb/#{@md.fn[:doc]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:xhtml]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:xhtml]}")==true) xhtml,xhtml_li='xhtml,', "'#{base}/#@fnb/#{@md.fn[:xhtml]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:sax]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:sax]}")==true) xml_sax,xml_sax_li='xml_sax,', "'#{base}/#@fnb/#{@md.fn[:sax]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:dom]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:dom]}")==true) xml_dom,xml_dom_li='xml_dom,', "'#{base}/#@fnb/#{@md.fn[:dom]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:odf]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:odf]}")==true) odf,odf_li='odf,', "'#{base}/#@fnb/#{@md.fn[:odf]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:pdf_p]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:pdf_p]}")==true) pdf_p,pdf_p_li='pdf_p,', "'#{base}/#@fnb/#{@md.fn[:pdf_p]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:pdf_l]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:pdf_l]}")==true) pdf_l,pdf_l_li='pdf_l,', "'#{base}/#@fnb/#{@md.fn[:pdf_l]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:concordance]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:concordance]}")==true) concordance,concordance_li='concordance,', "'#{base}/#@fnb/#{@md.fn[:concordance]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.tex")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.tex")==true) latex_p,latex_p_li='latex_p,', "'#{base}/#@fnb/#{@opt.fns}.tex'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.landscape.tex")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.landscape.tex")==true) latex_l,latex_l_li='latex_l,', "'#{base}/#@fnb/#@opt.fns}.landscape.tex'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:digest]}")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:digest]}")==true) digest,digest_li='digest,', "'#{base}/#@fnb/#{@md.fn[:digest]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:manifest]}")==true) #revisit, was to be text, this is html + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@md.fn[:manifest]}")==true) #revisit, was to be text, this is html manifest,manifest_li='manifest,', "'#{base}/#@fnb/#{@md.fn[:manifest]}'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.meta")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.meta")==true) markup,markup_li='markup,', "'#{base}/#@fnb/#{@opt.fns}.meta'," end - if @opt.cmd !~/e/ or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.tgz")==true) + if @opt.cmd !~/e/ \ + or (@opt.cmd=~/e/ and FileTest.file?("#{out}/#@fnb/#{@opt.fns}.tgz")==true) sisupod,sisupod_li='sisupod,', "'#{base}/#@fnb/#{@opt.fns}.tgz'," end @conn.execute(%{ diff --git a/lib/sisu/v0/db_load_tuple.rb b/lib/sisu/v0/db_load_tuple.rb index a140ea14..3baf2f82 100644 --- a/lib/sisu/v0/db_load_tuple.rb +++ b/lib/sisu/v0/db_load_tuple.rb @@ -62,7 +62,15 @@ module SiSU_DB_tuple def initialize(conn,col,opt) @conn,@col,@opt=conn,col,opt @col[:lev]=@col[:lev].to_i - @col[:lev]=0 unless @col[:lev]=~/^[1-6]/ or @col[:lev]==1 or @col[:lev]==2 or @col[:lev]==3 or @col[:lev]==4 or @col[:lev]==5 or @col[:lev]==6 #changed from \d+ ?? + unless @col[:lev]=~/^[1-6]/ \ + or @col[:lev]==1 \ + or @col[:lev]==2 \ + or @col[:lev]==3 \ + or @col[:lev]==4 \ + or @col[:lev]==5 \ + or @col[:lev]==6 #changed from \d+ ?? + @col[:lev]=0 + end @col[:ocn]=0 unless @col[:ocn]=~/\d+/ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX end diff --git a/lib/sisu/v0/dbi.rb b/lib/sisu/v0/dbi.rb index 0ad4880a..17568ce6 100644 --- a/lib/sisu/v0/dbi.rb +++ b/lib/sisu/v0/dbi.rb @@ -70,13 +70,21 @@ module SiSU_DBI SiSU_Env::Load.new('dbi',true).prog @opt=opt @db=SiSU_Env::Info_db.new - if @opt.cmd =~/d/i or @opt.mod.inspect =~/--pg(?:sql)?|(?:sq)?lite/ - @sql_type=if @opt.cmd=~/D/ or @opt.mod.inspect =~/--pg(?:sql)?/; 'pg' - elsif @opt.cmd =~/d/ and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/; 'pg' - elsif @opt.mod.inspect =~/--(?:sq)?lite/; 'sqlite' - elsif @opt.cmd =~/d/ and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/; 'sqlite' + if @opt.cmd =~/d/i \ + or @opt.mod.inspect =~/--pg(?:sql)?|(?:sq)?lite/ + @sql_type=if @opt.cmd=~/D/ \ + or @opt.mod.inspect =~/--pg(?:sql)?/ + 'pg' + elsif @opt.cmd =~/d/ \ + and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/ + 'pg' + elsif @opt.mod.inspect =~/--(?:sq)?lite/ + 'sqlite' + elsif @opt.cmd =~/d/ \ + and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/ + 'sqlite' #elsif @opt.cmd =~/d/ and @opt.mod.select =~/--my(?:sql)?/; 'mysql' - else 'sqlite' + else 'sqlite' end end end diff --git a/lib/sisu/v0/defaults.rb b/lib/sisu/v0/defaults.rb index 46a55775..e75ba2e3 100644 --- a/lib/sisu/v0/defaults.rb +++ b/lib/sisu/v0/defaults.rb @@ -526,7 +526,8 @@ module SiSU_Viz 'SiSU' end def markup_make_italic - if defined? italics_list and italics_list + if defined? italics_list \ + and italics_list #make=italics_list.split(/;\s+/).join('|').strip make={} if italics_list @@ -547,7 +548,8 @@ module SiSU_Viz end end def markup_make_bold - if defined? bold_list and not bold_list.empty? + if defined? bold_list \ + and not bold_list.empty? make={} if bold_list #make=bold_list.split(/;\s+/).join('|').strip diff --git a/lib/sisu/v0/digests.rb b/lib/sisu/v0/digests.rb index 7324b93b..1adc8582 100644 --- a/lib/sisu/v0/digests.rb +++ b/lib/sisu/v0/digests.rb @@ -184,7 +184,8 @@ module SiSU_Digest_view @n,@s=/MD5\((\S+?\.sst)\)=\s*([0-9a-f]{#@dl})<\/u>/.match(para)[1,2] end x=unless ocn =~ /^0$/ - if images and images.length > 0 # then get path of image & produce digest + if images \ + and images.length > 0 # then get path of image & produce digest @image_name,@image_dgst,@img=[],[],[] images.each do |i| image_source=if FileTest.file?("#{@env.path.image_source_local_tex}/#{i}") @@ -227,7 +228,8 @@ module SiSU_Digest_view metad=[@tr.dc_title,@tr.creator,@tr.translator,@tr.illustrator,@tr.prepared_by,@tr.digitized_by,@tr.description,@tr.subject,@tr.abstract,@tr.publisher,@tr.contributor,@tr.date_created,@tr.date_issued,@tr.date_available,@tr.date_modified,@tr.date_valid,@tr.date,@tr.type,@tr.format,@tr.rights,@tr.identifier,@tr.source,@tr.language,@tr.language_original,@tr.relation,@tr.coverage,@tr.keywords,@tr.comments,@tr.cls_loc,@tr.cls_dewey,@tr.cls_gutenberg,@tr.cls_isbn,@tr.prefix_a,@tr.prefix_b,@tr.sourcefile,@tr.sourcefile_digest,@tr.last_generated,@tr.sisu_version,@tr.ruby_version,@tr.sc_number,@tr.sc_date,'Skin_Digest: ','Generated by: ','Ruby version: '] metad.each do |n| m=rgx_txt(n) - if m=~/\S+/ and para=~/^#{m}:/ + if m=~/\S+/ \ + and para=~/^#{m}:/ x,o=0,18 while x < 2; o = o + 2 x=o - n.length @@ -349,15 +351,18 @@ module SiSU_Digest_view dal_structure_summary(" [*] number of headers (@) and of each heading level (:A to :C and 1 to 3)\n") end def supplementary - if defined? @md.sc_number and @md.sc_number + if defined? @md.sc_number \ + and @md.sc_number rcinfo("------------\n") rcinfo("source control information\n") rcinfo(" (the following information while not important for document content certification\n may help the publisher in locating the version referred to)\n") rcinfo(" rcs version number: #{@md.sc_number}\n") - if defined? @md.sc_date and @md.sc_date + if defined? @md.sc_date \ + and @md.sc_date rcinfo(" rcs date: #{@md.sc_date}\n") end - if defined? @md.sc_time and @md.sc_time + if defined? @md.sc_time \ + and @md.sc_time rcinfo(" rcs time: #{@md.sc_time}\n") end end diff --git a/lib/sisu/v0/help.rb b/lib/sisu/v0/help.rb index 50539d9d..1c1fd4d0 100644 --- a/lib/sisu/v0/help.rb +++ b/lib/sisu/v0/help.rb @@ -77,7 +77,8 @@ module SiSU_Help help_info=%{#{@cX.blue_hi}SiSU help#{@cX.off} #{@cX.ruby}~#{@cX.off} #{@request}} help_list=%{#{@cX.blue}sisu --help#{@cX.off} #{@cX.cyan}type keyword else "enter" to exit help:\n\tkeywords include:#{@cX.off} #{@cX.brown}list, (com)mands, short(cuts), (mod)ifiers, (env)ironment, markup, syntax, headers, headings, endnotes, tables, example, customise, skin, (dir)ectories, path, (lang)uage, db, install, setup, (conf)igure, convert, external_programs, dublincore, termsheet, search, sql, hyper(est)raier, features, external_programs, license#{@cX.off} \n} help_prompt=%{#{@cX.fuschia}exit, [or carriage return to exit help] #{@cX.off}\n#{@cX.blue_hi}SiSU help#{@cX.off} #{@cX.ruby}~#{@cX.off} } - until gotten =~/exit|quit|bye|q|^\s*$/ and ( @request.nil? or @request.empty? ) + until gotten =~/exit|quit|bye|q|^\s*$/ \ + and ( @request.nil? or @request.empty? ) @help=Help.new(@request,@color) if @request puts help_info @@ -1435,7 +1436,7 @@ WOK arch: #{@cX.blue}#{@env.arch}#{@cX.off} Directories for installation - bin: #{@cX.blue}#{Config::CONFIG['bindir']}#{@cX.off} or #{@cX.blue}#{Config::CONFIG['sitelibdir']}#{@cX.off} + bin: #{@cX.blue}#{Config::CONFIG['bindir']}#{@cX.off} or #{@cX.blue}#{Config::CONFIG['sitelibdir']}#{@cX.off} lib (site-ruby): #{@cX.blue}#{Config::CONFIG['rubylibdir']}/#{SiSU_lib}#{@cX.off} or #{@cX.blue}#{Config::CONFIG['sitelibdir']}/#{SiSU_lib}#{@cX.off} conf [etc]: #{@cX.blue}#{@env.path.etc}/sisu#{@cX.off} data (document samples, images, README): #{@cX.blue}#{@env.path.sample_data}#{@cX.off} diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index c875614d..930fdb36 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -152,8 +152,10 @@ module SiSU_HTML if @md @md.sfx='' @md.sfx='' if @md.cmd =~/z/ - if @md.cmd =~/h/ or @md.fns =~/\~[a-z]{2,3}\.s?/ #multilingual document protection is a bit arbitrary, (needed by existing server configuration), add configuration overide... - if @md.cmd =~/H/ and @md.fns =~/\~[a-z]{2,3}\.s?/ + if @md.cmd =~/h/ \ + or @md.fns =~/\~[a-z]{2,3}\.s?/ #multilingual document protection is a bit arbitrary, (needed by existing server configuration), add configuration overide... + if @md.cmd =~/H/ \ + and @md.fns =~/\~[a-z]{2,3}\.s?/ SiSU_Screen::Ansi.new(@md.cmd, 'multilingual document, creating internal url links with filetype suffix', "\n\t\t(overriding -H request, using -h mode instead)" @@ -232,7 +234,8 @@ module SiSU_HTML format_head_toc=SiSU_HTML_Format_type::Head_toc.new(@md) guide_type='horzontal' #values: horizontal or vertical @links_guide_toc << format_head_toc.links_guide_open(guide_type) - if defined? @md.lnk and @md.lnk + if defined? @md.lnk \ + and @md.lnk @md.lnk.each do |l| if defined? l[:say] target=if l[:url] !~/^\.(\.)?\//; 'external' @@ -262,7 +265,8 @@ module SiSU_HTML @data.each do |para| pg=para.dup unless pg =~/^<:code>/ - if pg =~/~[{\[][\d*+]+ / + if pg =~/~[{\[][\d*+]+ / endnote_array=[] if pg=~/~\{[\d*+].+?\}\~/m endnote_array << pg.scan(/~\{[\d*+]+(.+?)\}\~/m) @@ -313,7 +317,8 @@ module SiSU_HTML when /^\s*4~!/; Toc.new(para_toc).level_crosslink else end - if @@firstseg.nil? and para=~/^4~\S+?/ + if @@firstseg.nil? \ + and para=~/^4~\S+?/ @@firstseg=/^4~(\S+)?/.match(para)[1] end if toc @@ -372,7 +377,10 @@ WOK end para[@pat_heading] linkname,link=$1,$2 if $& - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link and link !~/#/ #% keep eye on link + if link \ + and link !~/#/ #% keep eye on link + p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + end title=unless para =~/Document Information/; linkname else link='metadata' @@ -412,7 +420,10 @@ WOK end para[@pat_heading] linkname,link=$1,$2 if $& - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link and link !~/#/ + if link \ + and link !~/#/ + p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + end format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,linkname) toc={} toc[:seg]=format_toc.lev2 @@ -432,7 +443,10 @@ WOK para.gsub(/(.*?)<\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect para[@pat_heading] linkname,link=$1,$2 if $& - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link and link !~/#/ + if link \ + and link !~/#/ + p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + end format_toc=SiSU_HTML_Format_type::Format_toc.new(@md,linkname) toc={} toc[:seg]=format_toc.lev3 @@ -489,7 +503,10 @@ WOK end para[@pat_heading] linkname,link=$1,$2 if $& - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link and link !~/#/ + if link \ + and link !~/#/ + p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + end toc={} if para =~/<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ m=/#{$1}/ @@ -514,7 +531,10 @@ WOK end para[@pat_heading] linkname,link=$1,$2 if $& - p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) if link and link !~/#/ + if link \ + and link !~/#/ + p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,link) + end toc={} if para =~/<~0;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ m=/#{$1}/ @@ -593,7 +613,8 @@ WOK format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold - if not @md.subtitle.nil? and not @md.subtitle.empty? + if not @md.subtitle.nil? \ + and not @md.subtitle.empty? tmp_head=@md.subtitle + "\n" format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,tmp_head) toc_shared << format_txt_obj.center_bold diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index e770a339..27e6b817 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -64,12 +64,16 @@ module SiSU_HTML_Format @paranum=paranum[/(\d+)/m,1] @paranum ||='' vz=SiSU_Env::Get_init.instance.skin - @skin_no_ocn=if defined? vz.ocn_display_off and vz.ocn_display_off == true; true + @skin_no_ocn=if defined? vz.ocn_display_off \ + and vz.ocn_display_off == true + true else false end end def ocn_display - if @md.markup.inspect =~/no_ocn/ or @md.mod.inspect =~/--no-ocn/ or @skin_no_ocn + if @md.markup.inspect =~/no_ocn/ \ + or @md.mod.inspect =~/--no-ocn/ \ + or @skin_no_ocn ocn_class='ocn_off' @paranum.gsub(/^(\d+|)$/, %{

@@ -227,7 +231,8 @@ module SiSU_HTML_Format } end def pdf - pdf=if @md.programs[:pdf] and @cf_defaults.cf_0 =~/p/ + pdf=if @md.programs[:pdf] \ + and @cf_defaults.cf_0 =~/p/ %{ @@ -255,7 +260,8 @@ module SiSU_HTML_Format end end def concordance(text) - if @md.concord_make and @md.wc_words < 300000 #max word count for display of concordance here as would now be a large file + if @md.concord_make \ + and @md.wc_words < 300000 #max word count for display of concordance here as would now be a large file %{ #{text} diff --git a/lib/sisu/v0/html_format_css.rb b/lib/sisu/v0/html_format_css.rb index 497e883c..497ae1c2 100644 --- a/lib/sisu/v0/html_format_css.rb +++ b/lib/sisu/v0/html_format_css.rb @@ -344,7 +344,8 @@ module SiSU_HTML_Format_type #{@vz.table_close}} end def subtoc_lev - one=if @one and @one =~/<\/?i>|/mi + one=if @one \ + and @one =~/<\/?i>|/mi @one.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text else @one end diff --git a/lib/sisu/v0/html_promo.rb b/lib/sisu/v0/html_promo.rb index 1fc8fb4d..1f31b3b9 100644 --- a/lib/sisu/v0/html_promo.rb +++ b/lib/sisu/v0/html_promo.rb @@ -146,23 +146,27 @@ module SiSU_HTML_promo def search_form_sisu(table=true) db=if @prod['db']=~/\S+/ @prod['db']=~/^SiSU_\S+/ ? @prod['db'] : "SiSU_#{@prod['db']}" - elsif defined? @rc['search']['sisu']['db'] and @rc['search']['sisu']['db'] =~/\S+/ + elsif defined? @rc['search']['sisu']['db'] \ + and @rc['search']['sisu']['db'] =~/\S+/ @rc['search']['sisu']['db']=~/^SiSU_\S+/ ? @prod['search']['sisu']['db'] : "SiSU_#{@prod['db']}" else nil end action=if @prod['action']=~/^http:\/\// @prod['action'] - elsif defined? @rc['search']['sisu']['action'] and @rc['search']['sisu']['action'] =~/^http:\/\// + elsif defined? @rc['search']['sisu']['action'] \ + and @rc['search']['sisu']['action'] =~/^http:\/\// @rc['search']['sisu']['action'] else nil end - form=if action and db + form=if action \ + and db '
' + @env.widget.search_form('sisusearch',action,db,table) else '' end end def search_form_hyperestraier(table=true) - action=if defined? @rc['search']['hyperestraier']['action'] and @rc['search']['hyperestraier']['action'] =~/^http:\/\// + action=if defined? @rc['search']['hyperestraier']['action'] \ + and @rc['search']['hyperestraier']['action'] =~/^http:\/\// @rc['search']['hyperestraier']['action'] else nil end @@ -176,7 +180,9 @@ module SiSU_HTML_promo if @prod['links'] #and @prod['links'] == Array links_a=[] @prod['links'].each do |x| - if x and x['url'] and x['title'] + if x \ + and x['url'] \ + and x['title'] subtitle=x['subtitle'] ? %{ - #{x['subtitle']}} : '' url_=x['url'] =~/http:/ ? x['url'] : "../#{x['url']}" #url_=x['url'] =~/http:/ ? x['url'] : "#{@env.url.root}/#{x['url']}" @@ -214,19 +220,22 @@ module SiSU_HTML_promo end def price def gbp - if defined? @prod['price']['gbp'] and @prod['price']['gbp'] + if defined? @prod['price']['gbp'] \ + and @prod['price']['gbp'] "  £ #{@prod['price']['gbp']} (GBP) " else '' end end def euro - if defined? @prod['price']['euro'] and @prod['price']['euro'] + if defined? @prod['price']['euro'] \ + and @prod['price']['euro'] "  € #{@prod['price']['euro']} (Euro) " else '' end end def usd - if defined? @prod['price']['usd'] and @prod['price']['usd'] + if defined? @prod['price']['usd'] \ + and @prod['price']['usd'] "  $ #{@prod['price']['usd']} (USD) " else '' end @@ -365,13 +374,15 @@ WOK #end def advert_extract_subject(category) #extracts products from category/subject list adverts=[] - if defined? @ad[:promo_list][category] and @ad[:promo_list][category] + if defined? @ad[:promo_list][category] \ + and @ad[:promo_list][category] @ad[:promo_list][category].keys.each do |type| @ad[:promo_list][category][type].each do |i| if i id=i.to_s =~/^\d/ ? "id_#{i.to_s.strip}" : i.to_s.strip gbp=usd=euro=nil - if defined? @ad[:promo][type][id] and not @ad[:promo][type][id].nil? + if defined? @ad[:promo][type][id] \ + and not @ad[:promo][type][id].nil? adverts << output_form_select(type,id) end end diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 30640f30..483b5222 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -86,7 +86,10 @@ module SiSU_HTML_scroll if para =~/^\d~metadata\s+Metadata/ para.gsub!(/(Metadata)/,'\1
') end - @rcdc=true if @rcdc==false and (para =~/^\d~metadata/ or para =~/^1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/^\d~metadata/ or para =~/^1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~||)/ unless para =~/^<:code>/; para.gsub!(/~[{\[].+?[}\]]~\s+/m,' ') end @@ -126,13 +129,16 @@ module SiSU_HTML_scroll end end end - elsif para =~/^[1-9]~\S*/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/^[1-9]~\S*/ \ + and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,para) para=format_txt_obj.bold_header - elsif para =~/Endnotes?/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/Endnotes?/ \ + and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'
Note') para=format_txt_obj.bold_para - elsif para =~/Owner Details/ and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/Owner Details/ \ + and para !~/<~\d+;(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ format_txt_obj=SiSU_HTML_Format_type::Format_text_object.new(@md,'
Owner Details') @scr[:owner_details]=format_txt_obj.bold_para para='' @@ -141,7 +147,10 @@ module SiSU_HTML_scroll format_seg=SiSU_HTML_Format_type::Format_seg.new(@md,one,two) para=format_seg.no_paranum end - para='' if (para =~// and para =~/^(?:\^~\d+\s|)/) # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though + if para =~// \ + and para =~/^(?:\^~\d+\s|)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though + para='' + end if para =~/<:center>/ #rules changed now a

(.*)/.match(para).captures format_scroll=SiSU_HTML_Format_type::Format_scroll.new(@md,one,two) diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index de96dd7d..595ad2dc 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -135,10 +135,13 @@ module SiSU_HTML_seg unless para =~/^1~/; head1=$_ #; end end - if @@is4 == 1 or para =~/^|^/ - if newfile == 1 or para =~/^|^/ + if @@is4 == 1 \ + or para =~/^|^/ + if newfile == 1 \ + or para =~/^|^/ newfile=0 - if para =~/^4~\S+/ or para =~/^|^/ # @@level4 + if para =~/^4~\S+/ \ + or para =~/^|^/ # @@level4 if tracking != 0 File.mkpath(@md.dir_out) unless FileTest.directory?(@md.dir_out) #bug - added specifically for nav! not needed by regular seg, check !!! Seg.new('',@md).tail @@ -260,7 +263,8 @@ module SiSU_HTML_seg paranum=m[1].to_s @p_num=SiSU_HTML_Format_type::Paragraph_number.new(@md,paranum) end - if para =~/<:(?:code|alt|verse|group)>/m or @@flag_alt==true + if para =~/<:(?:code|alt|verse|group)>/m \ + or @@flag_alt==true if para =~/<:(?:code|alt|verse|group)>/m @group_collect=[] #unless @group_collect.class == Array @group_collect << @vz.margin_txt_0 + para.gsub(/<:(?:code|alt|verse|group)-end>/m,'') #watch ! @@ -304,10 +308,12 @@ module SiSU_HTML_seg when /^code$/ @sto.seg_lev_para_ocn.code when /null/ - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ and para !~/^/ + if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \ + and para !~/^/ format_txt_obj.gsub_body @sto.seg_lev_para_ocn.para - elsif para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ and para =~/^/ + elsif para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \ + and para =~/^/ format_txt_obj.gsub_body @sto.seg_lev_para_ocn.table_end else para @@ -388,7 +394,8 @@ module SiSU_HTML_seg data.each do |para| para.gsub!(/(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes - if para =~/^[1234]~/ and not @@fn.empty? + if para =~/^[1234]~/ \ + and not @@fn.empty? @@seg_endnotes[@@fn]=[] @@seg_endnotes[@@fn] << @@seg_endnotes_array @@seg_endnotes_array=[] if para=~/^4~/ @@ -427,7 +434,8 @@ module SiSU_HTML_seg @@seg_subtoc_array << para end if @md.flag_auto_endnotes - if para =~/~[{\[][\d*+]+ / # endnote- + if para =~/~[{\[][\d*+]+ / # endnote- endnote_array=[] if para=~/~\{.+?\}\~/m endnote_array << para.scan(/~\{.+?\}\~/m) diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index ab37abb2..caf88d79 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -261,7 +261,8 @@ module SiSU_Tune image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external else @env.url.images_local end - ins=if u and u.strip !~/^image$/ + ins=if u \ + and u.strip !~/^image$/ %{#{caption}} else %{#{caption}} end @@ -322,13 +323,15 @@ module SiSU_Tune para.gsub!(/!new/, %{ new}) para.gsub!(/<:h(.{1,7}?)>/,'\1') para.gsub!(/<:to(\d{1,7}?)>/,'to { \1 } ') - if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) + if para =~/\b\S+\@\S+?\.\S+/ \ + and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/ para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<\1>\2') end para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2') #http ftp matches escaped, no decoration para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1\2\3') #special case \{ e.g. \}http://url para.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #http ftp matches with decoration - if (para =~/..\/\S+/ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/) + if para =~/..\/\S+/ \ + and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ para.gsub!(/(\.\.\/\S+)/,'\1') end para.gsub!(/\n "); tell.puts_grey @@ -518,13 +538,17 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if FileTest.file?(fns) @opt.fns=fns unless @opt.fns =~ /(?:\.(?:(?:-|ssm\.)?sst|ssm|ssp|sx[sdn]\.xml|termsheet.rb)|sisupod(?:\.zip)?)$/ - if @opt.fns=~/\.kdi$/ and @opt.mod.inspect =~/--(?:convert(?:-from)?|from)[=-]kdi/ - elsif @opt.fns=~/\.sx[sdn]\.xml$/ and @opt.mod.inspect =~/--(?:(?:convert(?:-from)?|from)[=-])?(?:xml2sst|sxml)/ - elsif @opt.fns=~/\.ssi$/ and @opt.mod.inspect =~/--identify/ + if @opt.fns=~/\.kdi$/ \ + and @opt.mod.inspect =~/--(?:convert(?:-from)?|from)[=-]kdi/ + elsif @opt.fns=~/\.sx[sdn]\.xml$/ \ + and @opt.mod.inspect =~/--(?:(?:convert(?:-from)?|from)[=-])?(?:xml2sst|sxml)/ + elsif @opt.fns=~/\.ssi$/ \ + and @opt.mod.inspect =~/--identify/ else Operations.new(@opt).not_recognised end end - if @opt.fns =~/\.ssm\.sst$/ and @opt.cmd !~/[S_M]/ # rework necessry, revist, the _ flag is a hack, to keep ._sst files + if @opt.fns =~/\.ssm\.sst$/ \ + and @opt.cmd !~/[S_M]/ # rework necessry, revist, the _ flag is a hack, to keep ._sst files @msg,@msgs='temporary file removed',nil @tell.call.warn unless @opt.cmd =~/V/ File.unlink(@opt.fns) if File.exist?(@opt.fns) #CONSIDER diff --git a/lib/sisu/v0/manifest.rb b/lib/sisu/v0/manifest.rb index 0776f4d1..e0617fec 100644 --- a/lib/sisu/v0/manifest.rb +++ b/lib/sisu/v0/manifest.rb @@ -240,16 +240,18 @@ module SiSU_Manifest id,file='Markup Composite File (SiSU source)',req summarize_source(id,file) end - end - if FileTest.file?("#@base_path_src/#{@md.fns}")==true - id,file='Markup (SiSU source)',@md.fns - summarize_source(id,file) + else + if FileTest.file?("#@base_path_src/#{@md.fns}")==true + id,file='Markup (SiSU source)',@md.fns + summarize_source(id,file) + end end if FileTest.file?("#@base_path_src/#{@md.fn[:sisupod]}")==true id,file='SiSU doc (zip)',@md.fn[:sisupod] summarize_source(id,file) end - if FileTest.file?("#@base_path/#{@md.fnb}")==true and @md.fnb =~/\.kdi$/ + if FileTest.file?("#@base_path/#{@md.fnb}")==true \ + and @md.fnb =~/\.kdi$/ id,file='Kdissert (.kdi source)',@md.fnb summarize_source(id,file) end @@ -339,11 +341,13 @@ module SiSU_Manifest id,info=@translate.date_valid,@md.dc_date_valid metadata(id,info) end - if @md.dc_language and @md.dc_language[:name] + if @md.dc_language \ + and @md.dc_language[:name] id,info=@translate.language,@md.dc_language[:name] metadata(id,info) end - if @md.language_original and @md.language_original[:name] + if @md.language_original \ + and @md.language_original[:name] id,info=@translate.language_original,@md.language_original[:name] metadata(id,info) end @@ -437,14 +441,17 @@ module SiSU_Manifest end end def links_tests - if defined? @md.lnk and @md.lnk + if defined? @md.lnk \ + and @md.lnk @md.lnk.each do |l| if defined? l[:say] target=if l[:url] !~/^\.(\.)?\//; 'external' else '_top' end url,lnk=l[:url],l[:say] - unless url.nil? or url.empty?; links(url,lnk,target) + unless url.nil? \ + or url.empty? + links(url,lnk,target) end end end @@ -454,7 +461,8 @@ module SiSU_Manifest begin id,file='','' vz=SiSU_Env::Get_init.instance.skin - banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ and vz.banner_home_button_only !~ /sisu\.home\.png/ + banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \ + and vz.banner_home_button_only !~ /sisu\.home\.png/ < #{vz.banner_band}

#{@url_brace.xml_open}#@base_url/#{file}#{@url_brace.xml_close}

#{@env.widget_static.search_form}SiSU --> diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index 397b94d8..e747e22a 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -289,10 +289,12 @@ WOK '.BR' << @br << wrapped # [consider s/.BR/.PP/] end 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 @manpage[:body] << @br @@endnotes[:para].each { |e| @manpage[:body] << e << @br } - elsif @@endnotes[:para] and @@dostype =~/endnote/ + elsif @@endnotes[:para] \ + and @@dostype =~/endnote/ @manpage[:body] << @br*2 end @@endnotes[:para]=[] @@ -387,7 +389,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+))?/ manpage_structure(para,$1,@sto.ocn,$2) @@ -432,11 +435,14 @@ WOK end elsif para =~/#{table_message}/ @manpage[: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') #@@manpage[:owner_details]=formatMono.bold_para #para='' @@ -446,7 +452,10 @@ 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 + para='' + end case para when /<:i[1-9]>/ if para =~/.*<:#>.*$/m @@ -501,7 +510,8 @@ WOK filename_manpage=SiSU_Env::SiSU_file.new(@md,@md.fn[:manpage]).mkfile_man @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_manpage.puts line #unix manpage diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index feea7cde..78099d16 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -211,12 +211,16 @@ module SiSU_ODF para.gsub!(/^([1-6])~\S*\s/,'') m=/#{$1}/ breakpage='' - if @md.fns and @md.fns != '' and @md.fns !=@@fns + if @md.fns \ + and @md.fns != '' \ + and @md.fns !=@@fns @@docstart=true @@fns=@md.fns end unless @@docstart - breakpage=if (@md.pagenew or @md.pagebreak) and (@md.pagenew =~ m or @md.pagebreak =~m); ' ' + breakpage=if (@md.pagenew or @md.pagebreak) \ + and (@md.pagenew =~ m or @md.pagebreak =~m) + ' ' else '' end end @@ -224,9 +228,11 @@ module SiSU_ODF %{#{breakpage}#{para}} end def image_src(i) - image_source=if @md.fns =~/\.ss[tm]$/ and FileTest.file?("#{@env.path.image_source_local_tex}/#{i}") #review + image_source=if @md.fns =~/\.ss[tm]$/ \ + and FileTest.file?("#{@env.path.image_source_local_tex}/#{i}") #review @env.path.image_source_local_tex - elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{@env.path.image_source_remote_tex}/#{i}") + elsif @md.fns =~/\.-ss[tm]$/ \ + and FileTest.file?("#{@env.path.image_source_remote_tex}/#{i}") @env.path.image_source_remote_tex elsif FileTest.file?("#{@env.path.image_source_tex}/#{i}") @env.path.image_source_tex @@ -251,7 +257,9 @@ module SiSU_ODF image_source=image_src(i) pwd=Dir.pwd cp("#{image_source}/#{i}","#{@env.path.odf}/Pictures/#{i}") if image_source - img=if i.to_s =~/jpg|png|gif/ and h.to_s =~/\d/ and w.to_s =~/\d/ + img=if i.to_s =~/jpg|png|gif/ \ + and h.to_s =~/\d/ \ + and w.to_s =~/\d/ @@img_count +=1 %{#{c}} #anchor-type: as-char or paragraph or char or ... else %{[image omitted]} @@ -465,7 +473,9 @@ module SiSU_ODF word.each do |w| # _ - / # | : ! ^ ~ unless para =~/^(?:0~|%+ )/m w.gsub!(/&#(?:126|152);/,'~') #126 usual - if w !~/&\S{1,7};/ or w =~/ /; w.gsub!(/&/,'&') #watch   + if w !~/&\S{1,7};/ \ + or w =~/ / + w.gsub!(/&/,'&') #watch   end end para_array << w @@ -522,7 +532,8 @@ module SiSU_ODF if d_meta; odf_metadata(d_meta) end end - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/1~meta\s+Document Information/) + @rcdc=true if @rcdc==false \ + and (para =~/~metadata/ or para =~/1~meta\s+Document Information/) if para !~/(^0~||)/ if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change paranum=para[@regx,3] @@ -533,7 +544,8 @@ module SiSU_ODF ### problem in scroll, it appears tables are getting paragraph numbers unless @rcdc 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+))?/; odf_structure(para,$1,@sto.ocn,$2) para @@ -576,7 +588,10 @@ module SiSU_ODF format_text=OD_format::Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if para =~// and para =~/^(-\{{2}~\d+|)/ # -endnote + if para =~// \ + and para =~/^(-\{{2}~\d+|)/ # -endnote + para='' + end if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/) # i don't get the condition for no paranum end @@ -627,7 +642,9 @@ module SiSU_ODF %{#@br} else '' end - breakpage=if @md.pagenew or @md.pagebreak; ' fo:break-before="page"' + breakpage=if @md.pagenew \ + or @md.pagebreak + ' fo:break-before="page"' else '' end @@odf[:head]<<%{#@br} + diff --git a/lib/sisu/v0/options.rb b/lib/sisu/v0/options.rb index a4cdc5e4..39de0530 100644 --- a/lib/sisu/v0/options.rb +++ b/lib/sisu/v0/options.rb @@ -97,7 +97,8 @@ module SiSU_commandline s.strip! # String.strip is broken in ruby 1.9.0 (2007-09-10 patchlevel 0) [i486-linux], 2007-09-18:38/2 a=s.split(/\s+/) a.each do |x| - if x =~/^-[a-z0-5]+/i or x =~/^--\S+/ + if x =~/^-[a-z0-5]+/i \ + or x =~/^--\S+/ if x =~/^-([a-z0-5]+)/i; c << $1 end if x =~/^--\S+/; m << x @@ -141,7 +142,9 @@ module SiSU_commandline end @files << f @files.flatten! - if @files.length > 0 and @cmd.empty? and @mod.length == 0 #% if no other action called on filename given, default is sisu -0 [filename(s)] configured as flag default + if @files.length > 0 \ + and @cmd.empty? \ + and @mod.length == 0 #% if no other action called on filename given, default is sisu -0 [filename(s)] configured as flag default @cmd=shortcut.cf_0 end tell=SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd + ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n") diff --git a/lib/sisu/v0/param_identify_markup.rb b/lib/sisu/v0/param_identify_markup.rb index fcdf71cb..a5e74aa4 100644 --- a/lib/sisu/v0/param_identify_markup.rb +++ b/lib/sisu/v0/param_identify_markup.rb @@ -66,19 +66,23 @@ module SiSU_Markup_type def identify @version_determined,@version_declared,@declared_doc_type=@@version_determined,@@version_declared,@@declared_doc_type if @opt.fns != @@fns - if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ + or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ @declared_doc_type,@version_declared=$1,$2 - elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ + or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ @version_declared=$1 end @flag_57,@flag_38=false,false @cont.each_with_index do |y,i| - if @flag_57 or y =~/^:?A~\?? @title/ + if @flag_57 \ + or y =~/^:?A~\?? @title/ @version_determined=0.57 @flag_57=true break end - if @flag_38 or y =~/^:?A~/ + if @flag_38 \ + or y =~/^:?A~/ @version_determined=0.38 @flag_38=true break if i >= 200 @@ -87,7 +91,8 @@ module SiSU_Markup_type break end end - if y =~/^0~/ and not @flag_38 + if y =~/^0~/ \ + and not @flag_38 @version_determined=0.16 break end 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 diff --git a/lib/sisu/v0/rexml.rb b/lib/sisu/v0/rexml.rb index e710c7ed..d3346a91 100644 --- a/lib/sisu/v0/rexml.rb +++ b/lib/sisu/v0/rexml.rb @@ -83,7 +83,8 @@ module SiSU_Rexml def xml begin if FileTest.file?(@fnap) - if @prog.rexml !=false and FileTest.directory?('/usr/lib/ruby/1.8/rexml/') #note values can be other than true + if @prog.rexml !=false \ + and FileTest.directory?('/usr/lib/ruby/1.8/rexml/') #note values can be other than true xmlfile=IO.readlines(@fnap,'').join begin @xmldoc=REXML::Document.new xmlfile diff --git a/lib/sisu/v0/screen_text_color.rb b/lib/sisu/v0/screen_text_color.rb index a3f1cc7f..5d79c2b1 100644 --- a/lib/sisu/v0/screen_text_color.rb +++ b/lib/sisu/v0/screen_text_color.rb @@ -69,12 +69,12 @@ module SiSU_Screen flag=SiSU_Env::Info_processing_flag.new if @cmd if flag.color #set default colors on or off -c acts as toggle against this default, if default is off -c turns on, if default is on -c turns off - if @cmd =~/c/; @use_color=false - else @use_color=true + @use_color=if @cmd =~/c/; false + else true end else - if @cmd =~/c/; @use_color=true - else @use_color=false + @use_color=if @cmd =~/c/; true + else false end end if @cmd =~/k/; @use_color=false diff --git a/lib/sisu/v0/share_src_kdissert.rb b/lib/sisu/v0/share_src_kdissert.rb index e2e00d8c..fc56ac46 100644 --- a/lib/sisu/v0/share_src_kdissert.rb +++ b/lib/sisu/v0/share_src_kdissert.rb @@ -74,7 +74,8 @@ module SiSU_Kdi_source File.mkpath(@env.path.output) unless FileTest.directory?(@env.path.output) File.mkpath(@output_path) unless FileTest.directory?(@output_path) if FileTest.directory?(@output_path) - if @opt.fns =~/\.kdi\._sst$/ and FileTest.file?(@opt.fnb) + if @opt.fns =~/\.kdi\._sst$/ \ + and FileTest.file?(@opt.fnb) cp(@opt.fnb,@output_path) end else diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 730bf00d..6f62c69b 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -72,7 +72,8 @@ module SiSU_Format_Shared @@fns=@md.fns '' end - @hname=if col[:seg] and not col[:seg].to_s.empty? + @hname=if col[:seg] \ + and not col[:seg].to_s.empty? @@hname=col[:seg].to_s else @@hname end @@ -104,7 +105,8 @@ module SiSU_Format_Shared #image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external #else @env.url.images_local #end - ins=if u and u.strip !~/^image$/ + ins=if u \ + and u.strip !~/^image$/ %{[#{png}]#{caption}} else %{[#{png}] #{caption}} end diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb index 6af436b0..e5acf36d 100644 --- a/lib/sisu/v0/shared_txt.rb +++ b/lib/sisu/v0/shared_txt.rb @@ -81,15 +81,18 @@ module SiSU_text_utils 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+/ + 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 if word - out[line]=if out[line] and out[line] !~/\S+$/m + out[line]=if out[line] \ + and out[line] !~/\S+$/m "#{out[line]}#{word}" - elsif out[line] and out[line] =~/\S+/ + elsif out[line] \ + and out[line] =~/\S+/ "#{out[line]} #{word}" else "#{word.strip}" end @@ -114,7 +117,8 @@ module SiSU_text_utils @md,@p=md,para end def extract(tag,tag_content,type,attrib) - dc=if dc_tag and dc_content + dc=if dc_tag \ + and dc_content [dc_tag,dc_content,{dc_tag=>dc_content}] else nil end diff --git a/lib/sisu/v0/shared_xml.rb b/lib/sisu/v0/shared_xml.rb index 7f9cdc83..11dead2d 100644 --- a/lib/sisu/v0/shared_xml.rb +++ b/lib/sisu/v0/shared_xml.rb @@ -483,11 +483,13 @@ module SiSU_XML_tags #Format content=meta_content_clean(@md.dc_source) @dc_source=%{ \n} end - if @md.dc_language and @md.dc_language[:name] # DublinCore 12 - language (English) + if @md.dc_language \ + and @md.dc_language[:name] # DublinCore 12 - language (English) @rdf_language=%{ dc.language="#{@md.dc_language[:name]}"\n} @dc_language=%{ \n} end - if @md.language_original and @md.language_original[:name] + if @md.language_original \ + and @md.language_original[:name] @rdf_language_original=%{ dc.language="#{@md.language_original[:name]}"\n} @language_original=%{ \n} end diff --git a/lib/sisu/v0/sitemaps.rb b/lib/sisu/v0/sitemaps.rb index 740dbf76..5e16e772 100644 --- a/lib/sisu/v0/sitemaps.rb +++ b/lib/sisu/v0/sitemaps.rb @@ -150,7 +150,8 @@ WOK idx=sitemap_idx.join end def sitemap - map=if @md.dc_date_modified and @md.dc_date_modified=~/\d{4}-\d{2}-\d{2}/ + map=if @md.dc_date_modified \ + and @md.dc_date_modified=~/\d{4}-\d{2}-\d{2}/ sitemap_date_modified else sitemap_no_date end diff --git a/lib/sisu/v0/sst_convert_markup.rb b/lib/sisu/v0/sst_convert_markup.rb index 9eeb22b9..e1e691f7 100644 --- a/lib/sisu/v0/sst_convert_markup.rb +++ b/lib/sisu/v0/sst_convert_markup.rb @@ -79,7 +79,8 @@ module SiSU_Modify end def message(text) response='' - unless @opt.cmd=~/QQ/ or @opt.cmd=~/q/ + unless @opt.cmd=~/QQ/ \ + or @opt.cmd=~/q/ response=@ask.response?(%{#{ text}\nProceed? }) end end @@ -196,7 +197,8 @@ WOK end def conversion #%% do it --------------------------> - if @opt.files and @opt.files.length > 0 + if @opt.files \ + and @opt.files.length > 0 mr=nil #%% changes to make m match, r replace --------------------------> if @opt.mod.inspect =~/--help/; help @@ -234,15 +236,16 @@ WOK @new,@matched,@flag_start,@flag_end,@empty1,@empty2=true,false,false,false,false,false o="#{i}.bk" #o is for old markup_version=SiSU_Markup::Markup_identify.new(@opt).markup_version? - if (@opt.mod.inspect=~/37/ and markup_version=~/0.38/) or - (@opt.mod.inspect=~/current|38/ and markup_version=~/0.37/) + if (@opt.mod.inspect=~/37/ and markup_version=~/0.38/) \ + or (@opt.mod.inspect=~/current|38/ and markup_version=~/0.37/) puts "#{i} #{markup_version}" file=File.open(i,'r') cont=file.readlines file.close cont.each do |y| match_and_replace.each do |m,r,w| - if y =~m and y =~w + if y =~m \ + and y =~w if @new @new=false File.unlink(o) if File.exist?(o) @@ -262,9 +265,11 @@ WOK if y =~end_processing @flag_end=true end - if @flag_start and not @flag_end + if @flag_start \ + and not @flag_end match_and_replace.each do |m,r,w| - if y =~m and y =~w + if y =~m \ + and y =~w puts m.inspect + ' -> ' + r unless @opt.cmd=~/q/ puts "in: #{y}" if @opt.cmd=~/[vVM]/ y.gsub!(m,r) if m and r diff --git a/lib/sisu/v0/sst_do_inline_footnotes.rb b/lib/sisu/v0/sst_do_inline_footnotes.rb index 0bbaa131..fba5b177 100644 --- a/lib/sisu/v0/sst_do_inline_footnotes.rb +++ b/lib/sisu/v0/sst_do_inline_footnotes.rb @@ -125,7 +125,8 @@ module SiSU_Convert_footnotes meta=file_array.dup meta=meta.join.split("\n\n") #check whether can be eliminated, some of these are large objects to have twice @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract - if @md.en[:mismatch] == 0 or @md.mod.inspect =~/=footnotes-force/ + if @md.en[:mismatch] == 0 \ + or @md.mod.inspect =~/=footnotes-force/ meta=nil dal=SiSU_Convert_footnotes::Make.new(@md,file_array).song SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.fns}.fn").output if @md.cmd =~/v/ @@ -208,7 +209,8 @@ module SiSU_Convert_footnotes data=@data tuned_file,vocab_insert=[],[] data.each do |para| - if para =~/^1~/ and @@flag_vocab == 0 + if para =~/^1~/ \ + and @@flag_vocab == 0 vocab_insert << '@vocabulary: lex' << "\n\n" << para tuned_file << vocab_insert unless para.nil? @@flag_vocab=1 @@ -273,7 +275,8 @@ module SiSU_Convert_footnotes para.gsub!(/^8~/,'5~') para.gsub!(/^9~/,'6~') end - if para =~/<:insert\d+!?>/ and para !~/^%\s+/ + if para =~/<:insert\d+!?>/ \ + and para !~/^%\s+/ @skin.select #require "#{@md.doc_skin}" #FIX now ins=SiSU_Viz::Inserts.new @@ -328,7 +331,8 @@ module SiSU_Convert_footnotes @tuned_file << para end # debug 2003w46 adding revision control info - if @md.flag_auto_endnotes and @md.flag_separate_endnotes_make + if @md.flag_auto_endnotes \ + and @md.flag_separate_endnotes_make @tuned_file << "\n1~endnotes Endnotes <~0;0:0;u0>" #prob numbering, revisit end @tuned_file << "\n" @@ -345,7 +349,8 @@ module SiSU_Convert_footnotes para.gsub!(/^#{num}~([a-z_\.]+)\s+(.+)/i,%{#{num}~\\1 #{title_no} \\2 <:name##{title_no}>}) else para.gsub!(/^#{num}~ /,"#{num}~#{title_no} #{title_no} ") #main end - if @md.toc_lev_limit and @md.toc_lev_limit < num + if @md.toc_lev_limit \ + and @md.toc_lev_limit < num para.gsub!(/^[2-6]~(?:~\S+)?\s*/,'!_ ') end para @@ -357,7 +362,8 @@ module SiSU_Convert_footnotes @tuned_file=[] data.each do |para| unless @md.set_heading_top - if para !~/^(?:@\S+:|0~\S+)\s/m and para !~/\A\s*\Z/m + if para !~/^(?:@\S+:|0~\S+)\s/m \ + and para !~/\A\s*\Z/m @md.set_heading_top=true head=if @md.title ; ":A~ #{@md.title}" else ':A~ [no title provided]' @@ -377,7 +383,9 @@ module SiSU_Convert_footnotes @tuned_file=[] data.each do |para| unless @md.set_heading_seg - if para !~/^(?:@\S+:|0~\S+|:[ABC]~)/m and para !~/\A\s*\Z/m and para !~/<:p[bn]>/ + if para !~/^(?:@\S+:|0~\S+|:[ABC]~)/m \ + and para !~/\A\s*\Z/m \ + and para !~/<:p[bn]>/ @md.set_heading_seg=true head=if @md.title ; "1~seg [#{@md.title}]" else '1~seg [segment]' @@ -397,7 +405,8 @@ module SiSU_Convert_footnotes @tuned_file=[] data.each do |para| unless @md.set_header_title - if para !~/^%{1,2}\s/m and para !~/\A\s*\Z/m + if para !~/^%{1,2}\s/m \ + and para !~/\A\s*\Z/m @tuned_file << "0~title #{@md.heading_seg_first}" @md.title=@md.heading_seg_first @md.set_header_title=true diff --git a/lib/sisu/v0/sst_identify_markup.rb b/lib/sisu/v0/sst_identify_markup.rb index 19601c13..7fac34d5 100644 --- a/lib/sisu/v0/sst_identify_markup.rb +++ b/lib/sisu/v0/sst_identify_markup.rb @@ -93,34 +93,40 @@ WOK end def identify f=@opt.fns - if f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])$/ and File.exist?(f) + if f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])$/ \ + and File.exist?(f) file=File.open(f,'r') cont=file.readlines file.close links,oldlinks='','' markup=nil @declared_type,@declared_markup='[text?]','' - if cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + if cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ + or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ @declared_type,@declared_markup=$1,$2 #puts "SiSU #@declared_markup (declared markup version)" #else puts 'markup version not declared' - elsif cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ + elsif cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ + or cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ @declared_markup=$1 end @flag_57,@flag_38=false,false cont.each_with_index do |y,i| - if y =~/^(?:0\{?~links?|@links?:)\s/ and f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])/ + if y =~/^(?:0\{?~links?|@links?:)\s/ \ + and f =~/(?:\.sst|\.ssm|\.ssi|\.s[123])/ links=unless y =~/\{.+?\}\S+/; oldlinks=' (pre 0.20.4 header links)' else ' (post 0.20.4 header links)' end end - if @flag_57 or y =~/^:?A~\?? @title/ + if @flag_57 \ + or y =~/^:?A~\?? @title/ version='0.57' markup=Markup_inform.new(version,'0.57' + oldlinks,@declared_markup,@declared_type) @flag_57=true break end - if @flag_38 or (y =~/^:?A~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) + if @flag_38 \ + or (y =~/^:?A~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) version='0.38' markup=Markup_inform.new(version,'0.38' + oldlinks,@declared_markup,@declared_type) @flag_38=true @@ -131,12 +137,15 @@ WOK break end end - if (y =~/^1~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) and not @flag_38 + if (y =~/^1~/ and f =~/(?:\.sst|\.ssm|\.ssi)/) \ + and not @flag_38 version='0.37' markup=Markup_inform.new(version,'0.37 is substantially 0.16 - 0.36 markup with new file-extension' + oldlinks,@declared_markup,@declared_type) break end - if y =~/^1~/ and f =~/\.([rs])([123])/ and not @flag_38 + if y =~/^1~/ \ + and f =~/\.([rs])([123])/ \ + and not @flag_38 t,n=$1,$2 version='0.16' instruct=if t =~/r/ @@ -146,12 +155,14 @@ WOK markup=Markup_inform.new(version,'0.16 - 0.36' + instruct + links,@declared_markup,@declared_type) break end - if y =~/^0\{~/ and not @flag_38 + if y =~/^0\{~/ \ + and not @flag_38 version='0.1' markup=Markup_inform.new(version,'0.1 - 0.15',@declared_markup,@declared_type) break end - if y =~/^0\{{3}/ and not @flag_38 + if y =~/^0\{{3}/ \ + and not @flag_38 markup=Markup_inform.new('circa. 1997','old, check date',@declared_markup,@declared_type) break end @@ -162,7 +173,9 @@ WOK end end def determine_markup_version - if @opt.fns.nil? or @opt.fns.empty?; Markup_history.new(@opt).help_identify + if @opt.fns.nil? \ + or @opt.fns.empty? + Markup_history.new(@opt).help_identify end if File.exist?(@opt.fns) if @opt.fns =~/\.(?:sst|ssm|ssi|s[123i]|r[123])/ diff --git a/lib/sisu/v0/sst_to_s_xml_dom.rb b/lib/sisu/v0/sst_to_s_xml_dom.rb index 8e3fce27..748b6bfc 100644 --- a/lib/sisu/v0/sst_to_s_xml_dom.rb +++ b/lib/sisu/v0/sst_to_s_xml_dom.rb @@ -236,7 +236,11 @@ WOK xml_element="" 3.downto(lv) do |x| y=x - 1 - @@xml[:body] << "#{@tab*5}\n" if @cont[1] or @cont[2] or @cont[3] + if @cont[1] \ + or @cont[2] \ + or @cont[3] + @@xml[:body] << "#{@tab*5}\n" + end @cont[1]=false if @cont[1] @cont[2]=false if @cont[2] @cont[3]=false if @cont[3] @@ -277,7 +281,10 @@ WOK end @cont[1]=true when 5 - @@xml[:body] << "#{@tab*5}\n" if @cont[2] or @cont[1] + if @cont[2] \ + or @cont[1] + @@xml[:body] << "#{@tab*5}\n" + end if @copen[3] == true #6{ [3,2].each { |v| @@xml[:body] << "#{@tab*n}\n" } elsif @copen[2] == true #5{ @@ -285,7 +292,11 @@ WOK end @cont[2]=true when 6 - @@xml[:body] << "#{@tab*5}\n" if @cont[3] or @cont[2] or @cont[1] + if @cont[3] \ + or @cont[2] \ + or @cont[1] + @@xml[:body] << "#{@tab*5}\n" + end [3].each { |v| @@xml[:body] << "#{@tab*n}\n" } if @copen[3] @cont[3]=true end @@ -356,7 +367,10 @@ WOK if d_meta; xml_head(d_meta) end end - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~|^@\S+?:||)/ @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc @@ -421,16 +435,21 @@ WOK @@xml[:body] << table_structure(para) else #xml_structure xml_markup(para) - @@xml[:body] << %{#{@tab*6}} << "\n" if para[@regx] and para[@regx,2] + if para[@regx] \ + and para[@regx,2] + @@xml[:body] << %{#{@tab*6}} << "\n" + end @@xml[:body] << "#{@tab*7}#{para[@regx,2]}\n" if para[@regx,2] # main text, contents, body KEEP @@xml[:body] << "#{@tab*6}" << "\n" if para[@regx] end end elsif para =~/(Note|Endnotes?)/ - elsif para =~/(MetaData)/ and para =~/<~\d+;[m]\d+;\w\d+><#{@@dp}:#{@@dp}>$/ #debug 2003w46 add rc info + elsif para =~/(MetaData)/ \ + and para =~/<~\d+;[m]\d+;\w\d+><#{@@dp}:#{@@dp}>$/ #debug 2003w46 add rc info format_scroll=Format_scroll.new(@md,'
MetaData') para=format_scroll.bold_para - elsif para =~/(Owner Details)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#{@@dp}:#{@@dp}>$/ + elsif para =~/(Owner Details)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#{@@dp}:#{@@dp}>$/ format_scroll=Format_scroll.new(@md,'
Owner Details') @@xml[:owner_details]=format_scroll.bold_para para='' @@ -439,7 +458,10 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if para =~// and para =~/^(-\{{2}~\d+|)/ # -endnote + if para =~// \ + and para =~/^(-\{{2}~\d+|)/ # -endnote + para='' + end if para =~/.*<:#>.*$/ para=case para when /<:i1>/ diff --git a/lib/sisu/v0/sst_to_s_xml_node.rb b/lib/sisu/v0/sst_to_s_xml_node.rb index cbaf7672..38c025c0 100644 --- a/lib/sisu/v0/sst_to_s_xml_node.rb +++ b/lib/sisu/v0/sst_to_s_xml_node.rb @@ -228,9 +228,11 @@ WOK end if lv.to_s =~/^[1-6]/; @@current=lv end - if o.node == 1 or lv == 1 + if o.node == 1 \ + or lv == 1 @@parent[:node][o.node]=0 - elsif @@current == lv and @@current !=nil + elsif @@current == lv \ + and @@current !=nil if @node[:no][lv-1] != nil @@parent[:node][o.node]=@node[:no][lv-1] elsif @node[:no][lv-2] != nil @@ -240,12 +242,14 @@ WOK else puts 'error' end elsif lv == nil - if o.ocn.class == Fixnum and @@current + if o.ocn.class == Fixnum \ + and @@current @@parent[:node][o.node]=@node[:no][@@current] end else puts 'error' end - if @@current == lv and @@current !=nil + if @@current == lv \ + and @@current !=nil if @node[:ocn][lv-1] != nil @@parent[:ocn][o.ocn]=@node[:ocn][lv-1] elsif @node[:ocn][lv-2] != nil @@ -255,7 +259,8 @@ WOK else puts 'error' end elsif lv == nil - if o.ocn.class == Fixnum and @@current + if o.ocn.class == Fixnum \ + and @@current @@parent[:ocn][o.ocn]=@node[:ocn][@@current] end else puts 'error' @@ -418,8 +423,11 @@ WOK obj.each do |o| para=o.txt unless o.txt =~/^%% / #comments are lost, consider if para - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) if para !~/(^0~|^@\S+?:|^\s*$||)/ + @rcdc=true + end @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ @@ -457,7 +465,11 @@ WOK obj.each do |o| para=o.txt unless o.txt =~/^%% / #comments are lost, consider if para - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ \ + or para =~/^1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~|^@\S+?:|^\s*$||)/ @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc @@ -497,7 +509,10 @@ WOK else xml_structure(o,para,nil,nil) end end - para='' if para =~// and para =~/^(-\{{2}~\d+|)/ # -endnote + if para =~// \ + and para =~/^(-\{{2}~\d+|)/ # -endnote + para='' + end if para =~/.*<:#>.*$/ para=case para when /<:i1>/ diff --git a/lib/sisu/v0/sst_to_s_xml_sax.rb b/lib/sisu/v0/sst_to_s_xml_sax.rb index 9ea7d58c..38663f4f 100644 --- a/lib/sisu/v0/sst_to_s_xml_sax.rb +++ b/lib/sisu/v0/sst_to_s_xml_sax.rb @@ -265,7 +265,10 @@ WOK if d_meta; xml_head(d_meta) end end - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ or para =~/^1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~|^@\S+?:|^\s*$||)/ @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para unless @rcdc @@ -324,7 +327,10 @@ WOK else xml_structure(para,nil,nil) end end - para='' if para =~// and para =~/^(-\{{2}~\d+|)/ # -endnote + if para =~// \ + and para =~/^(-\{{2}~\d+|)/ # -endnote + para='' + end if para =~/.*<:#>.*$/ para=case para when /<:i1>/ diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index a6d94c1a..c8fff3e1 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -194,20 +194,24 @@ module SiSU_TexInfo @@flag['poem']=1 end if @@flag['code'] - if @@flag['code'] and para =~ /<:code[-_](?:end|close)>/ #watch change not tested 200501 + if @@flag['code'] \ + and para =~ /<:code[-_](?:end|close)>/ #watch change not tested 200501 @@flag['code']=false end - if @@flag['code'] and para =~ /\S/ + if @@flag['code'] \ + and para =~ /\S/ sub_array=para.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) para=@@line_mode.join end elsif @@flag['poem']==1 - if @@flag['poem']==1 and para =~ /<:verse[-_](?:end|close)>/ #watch change not tested 200501 + if @@flag['poem']==1 \ + and para =~ /<:verse[-_](?:end|close)>/ #watch change not tested 200501 @@flag['poem']=0 end - if @@flag['poem']==1 and para =~ /\S/ + if @@flag['poem']==1 \ + and para =~ /\S/ sub_array=para.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -220,7 +224,8 @@ module SiSU_TexInfo def code_lines data=@data data.each do |line| - if line =~ /\S/ and line !~ /<:(code|verse).+/ + if line =~ /\S/ \ + and line !~ /<:(code|verse).+/ if @@flag['code'] line.gsub!(/^\s*(.+)/m, "\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") @@counting+=1 if @@flag['code'] @@ -347,7 +352,8 @@ module SiSU_TexInfo data=Texinfo_make.new(data,@md).number_titles #TOGGLE to SWITCH PARAGRAPH NUMBERING (ON & OFF) data=Texinfo_make.new(data,@md).number_paras \ - if @md.fns !~ /\.e[pdr]00/ and @md.markup !~ /not_to/i + if @md.fns !~ /\.e[pdr]00/ \ + and @md.markup !~ /not_to/i end def number_titles data=@data @@ -358,8 +364,10 @@ module SiSU_TexInfo t_no1=0; t_no2=0; t_no3=0; t_no4=0; no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3); data.each do |para| - if @md.markup =~ /num_top/i and para !~ /0\\+/ - if para =~ /^[1-6]\\+(?:~\S+)?\s*/ and para !~ /<:\d-endnotes>/ + if @md.markup =~ /num_top/i \ + and para !~ /0\\+/ + if para =~ /^[1-6]\\+(?:~\S+)?\s*/ \ + and para !~ /<:\d-endnotes>/ header=para[//m, 1].gsub!(/-/m,'.') para.gsub!(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*/, "\\1 #{header} ") @@ -378,7 +386,8 @@ module SiSU_TexInfo @tex_file=[] paranumber=0 data.each do |para| - if para =~/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/ and para !~ // + if para =~/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/ \ + and para !~ // parablock,paranum=/(.+?)<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/im.match(para)[1,2] do_duo=TexInfoFormat::DuoTex.new(parablock,paranum) ###is BUG para=do_duo.paraNum if parablock diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index d6420684..c080c554 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -206,7 +206,8 @@ module SiSU_TeX @dir_sisu=@dirout.path.output texfile=@md.fns.gsub(/$/,'.tex') texfile=texfile.gsub(/~/,'-') - if File.exist?(texfile) and File.size(texfile) > 0 + if File.exist?(texfile) \ + and File.size(texfile) > 0 @tex_f_no+=1 latex_do(texfile) else @@ -241,7 +242,9 @@ module SiSU_TeX @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern vz=SiSU_Env::Get_init.instance.skin - @skin_no_ocn=if defined? vz.ocn_display_off and vz.ocn_display_off == true; true + @skin_no_ocn=if defined? vz.ocn_display_off \ + and vz.ocn_display_off == true + true else false end end @@ -272,7 +275,9 @@ module SiSU_TeX if @md.flag_tables data=tables(data) end - ocn=if @md.markup.inspect =~/no_ocn/ or @md.mod.inspect =~/--no-ocn/ or @skin_no_ocn + ocn=if @md.markup.inspect =~/no_ocn/ \ + or @md.mod.inspect =~/--no-ocn/ \ + or @skin_no_ocn false else true end @@ -429,7 +434,8 @@ WOK @group_collect=[] data.each do |para| #% case follows with levels 1-6 indents & graphics mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) - if para =~/<:(code|alt|verse|group)>/ or @@flag_alt + if para =~/<:(code|alt|verse|group)>/ \ + or @@flag_alt if para =~/<:(code|alt|verse|group)>/ @lineone=case para when /<:(alt|verse|group)>/; para @@ -521,7 +527,8 @@ WOK @tex_file << if @md.doc_skin !~/skin_mail/; @tex.doc_tail else @tex.mail_tail end - if defined? @md.lnk and @md.lnk + if defined? @md.lnk \ + and @md.lnk @md.lnk.each do |l| if l[:say] url=%<#{l[:url]}> @@ -565,7 +572,8 @@ WOK def number_paras(data,ocn) @tex_file=[] data.each do |para| - if para =~/<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ and para !~/\\end\{longtable\}|/ #catch + if para =~/<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ \ + and para !~/\\end\{longtable\}|/ #catch m=/(.+?)<\\~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/m parablock=para[m,1] paranum=if ocn; para[m,2] diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index 7849727b..3887600d 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -271,7 +271,8 @@ WOK @@dp=nil def initialize(md,string,string1=nil) @md,@string,@string1=md,string,string1 - if defined? @md.image and @md.image =~/center/ + if defined? @md.image \ + and @md.image =~/center/ @center_begin,@center_end='\begin{center}','\end{center}' else @center_begin,@center_end='','' end @@ -733,9 +734,11 @@ WOK image,m=/<:image\s+(\S+)\s+.+?width=``(\d+)''.+?>/m.match(@string).captures width=m[1] || '100' width=width.to_i*0.4 - image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") + image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ + and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") dir.path.image_source_local_tex - elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") + elsif @md.fns =~/\.-ss[tm]$/ \ + and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") dir.path.image_source_remote_tex elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}") dir.path.image_source_tex @@ -770,14 +773,17 @@ WOK hsp="\n{\\color{mywhite} .}&~\n" # ~ character for hardspace caption="{\\\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c}\\end{scriptsize}&}" if c #caption="{\\\\\\\ \n\\begin{scriptsize}#{hsp*3}#{c[1]}\\end{scriptsize}&}" if c - image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") + image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ + and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") dir.path.image_source_local_tex - elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") + elsif @md.fns =~/\.-ss[tm]$/ \ + and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") dir.path.image_source_remote_tex elsif FileTest.file?("#{dir.path.image_source_tex}/#{image}") dir.path.image_source_tex else - unless image.nil? or image.length < 2 + unless image.nil? \ + or image.length < 2 tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search locations: #{dir.path.image_source_local_tex},#{dir.path.image_source_remote_tex} and #{dir.path.image_source_tex}") tell.error2 unless @md.cmd =~/q/ end @@ -805,7 +811,8 @@ WOK end z,url=r.match(word).captures if word =~r url=url.strip - if word =~/\{\s*\S+\.?(?:png|jpg|gif)/ and word=~/\s+\d+x\d+\s+/ + if word =~/\{\s*\S+\.?(?:png|jpg|gif)/ \ + and word=~/\s+\d+x\d+\s+/ image,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') width=200 @@ -818,7 +825,8 @@ WOK when /a5/; @tx.a5 else @tx.a4 end - width=if orientation =~/portrait/ #value is not currently passed + width=if \ + orientation =~/portrait/ #value is not currently passed width=if width.to_i > dm.portrait.img_px; dm.portrait.img_px else width end @@ -835,14 +843,16 @@ WOK tell.print_grey #unless @opt.cmd =~/q/ end ins=if image #most images fc etc. #% clean up ! - out=if @md.fns =~/\.(?:ssm\.)?sst$/ and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") + out=if @md.fns =~/\.(?:ssm\.)?sst$/ \ + and FileTest.file?("#{dir.path.image_source_local_tex}/#{image}") @center_begin + "\\\n\\href{#{url}}" + #not satisfactory: \\ added to ^line to mimic reference file output "{\\includegraphics*[width=#{width}pt]" + "{#{dir.path.image_source_local_tex}/#{image}}}" + "#{caption}" + @center_end if word =~ /(\{[a-zA-Z0-9_\\]+\.(?:png|jpg|gif).+?\}(?:https?|file|ftp):\/\/\S+)/ - elsif @md.fns =~/\.-ss[tm]$/ and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") + elsif @md.fns =~/\.-ss[tm]$/ \ + and FileTest.file?("#{dir.path.image_source_remote_tex}/#{image}") @center_begin + "\\\n\\href{#{url}}" + #not satisfactory: \\ added to ^line to mimic reference file output "{\\includegraphics*[width=#{width}pt]" + @@ -1197,7 +1207,8 @@ WOK def a4generic end def para_num - paranumber_display=if @md.markup.inspect =~/no_ocn/ or @md.mod.inspect =~/--no-ocn/; '' + paranumber_display=if @md.markup.inspect =~/no_ocn/ \ + or @md.mod.inspect =~/--no-ocn/; '' else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering end if @string !~/^([1-6a-z-]#{@@tilde}\S*|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ diff --git a/lib/sisu/v0/urls.rb b/lib/sisu/v0/urls.rb index cfe242b3..b9b1e0ec 100644 --- a/lib/sisu/v0/urls.rb +++ b/lib/sisu/v0/urls.rb @@ -139,20 +139,29 @@ module SiSU_urls end end def urls_maintenance(opt,x,y) - if x=~/^([abchHmNopwxXy])/ and opt.cmd =~/[abchHmNopwxXy]/ and x=~/^[#{opt.cmd}]/ + if x=~/^([abchHmNopwxXy])/ \ + and opt.cmd =~/[abchHmNopwxXy]/ \ + and x=~/^[#{opt.cmd}]/ m=$1 f=y tool=@editor - if x =~/^m/ and @opt.cmd=~/m/ and x=~/^[#{opt.cmd}]/ and @opt.cmd =~/M/ + if x =~/^m/ \ + and @opt.cmd=~/m/ \ + and x=~/^[#{opt.cmd}]/ \ + and @opt.cmd =~/M/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@editor #{@env.path.dal}/#{@opt.fns}.meta") tell.maintenance unless @opt.cmd =~/q/ end - if x=~/^([hHw])/ and @opt.cmd=~/[hHw]/ and x=~/^[#{@opt.cmd}]/ + if x=~/^([hHw])/ \ + and @opt.cmd=~/[hHw]/ \ + and x=~/^[#{@opt.cmd}]/ f=if x !~/segmented/; "#{y}.html" else "#{y}.index.html" end end - if x=~/^p/ and @opt.cmd=~/p/ and x=~/^[#{@opt.cmd}]/ + if x=~/^p/ \ + and @opt.cmd=~/p/ \ + and x=~/^[#{@opt.cmd}]/ tool=@pdf_viewer if opt.cmd =~/M/ fns=@opt.fns.gsub(/~/,'-') @@ -163,7 +172,9 @@ module SiSU_urls tell.maintenance unless @opt.cmd =~/q/ end end - if x=~/^o/ and @opt.cmd=~/o/ and x=~/^[#{@opt.cmd}]/ + if x=~/^o/ \ + and @opt.cmd=~/o/ \ + and x=~/^[#{@opt.cmd}]/ tool=@odf_viewer end #if x=~/^i/ and @opt.cmd=~/i/ and x=~/^[#{@opt.cmd}]/ @@ -185,38 +196,46 @@ module SiSU_urls @pwd_stub="#@webserv_url"[m,1] @u.each do |x,y| if @opt.fns =~ @m_regular - if x=~/^([abchHNopwxXyY])/ and @opt.cmd=~/[abchHNopwxXyY]/ and x=~/^[#{@opt.cmd}]/ + if x=~/^([abchHNopwxXyY])/ \ + and @opt.cmd=~/[abchHNopwxXyY]/ \ + and x=~/^[#{@opt.cmd}]/ m=$1 tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@browser #@webserv_url/#@fnb/#{y}") tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/#{m}/,'') end - if x=~/^I/ and @opt.cmd =~/I/ + if x=~/^I/ \ + and @opt.cmd =~/I/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","cd #{@path.path.texinfo}; pinfo ./#@fnb.#{y}; cd -") tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/I/,'') end - if x=~/^D/ and @opt.cmd =~/D/ + if x=~/^D/ \ + and @opt.cmd =~/D/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI psql","#@pwd_stub::#{@opt.fns}",y) tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/D[iu]/,'') end - if x=~/^d/ and @opt.cmd =~/d/ + if x=~/^d/ \ + and @opt.cmd =~/d/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite #{@env.path.output}/sisu_sqlite.db", "#{y}") tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/d[iu]/,'') end - if x=~/^i/ and @opt.cmd =~/i/ + if x=~/^i/ \ + and @opt.cmd =~/i/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@manpage_gen #{@path.path.manpage}/#@fnb.1 |most") tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/I/,'') end - if x=~/^P/ and @opt.cmd =~/P/ + if x=~/^P/ \ + and @opt.cmd =~/P/ tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} Psql","#@pwd_stub::#{@opt.fns}",y) tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/P[iu]/,'') end - if x=~/^[sS]/ and @opt.cmd =~/[sS]/ + if x=~/^[sS]/ \ + and @opt.cmd =~/[sS]/ zipfile=if @opt.fns =~/\.ssm\.sst$/; y.gsub(/(?:\~\S{2,3})?(\.ssm\.sst\.zip)$/,'.ssm.zip') else y.gsub(/(?:\~\S{2,3})?(\.sst\.zip)$/,'\1') end diff --git a/lib/sisu/v0/wikispeak.rb b/lib/sisu/v0/wikispeak.rb index a0ca2cd5..7fe7ac89 100644 --- a/lib/sisu/v0/wikispeak.rb +++ b/lib/sisu/v0/wikispeak.rb @@ -273,7 +273,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+))?/ wiki_structure(para,$1,@sto.ocn,$2) @@ -318,11 +319,14 @@ WOK end elsif para =~/#{table_message}/ @@wiki[: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') #@@wiki[:owner_details]=formatMono.bold_para #para='' @@ -332,7 +336,10 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if (para =~// and para =~/^(-\{{2}~\d+|)/) # -endnote + if (para =~// \ + and para =~/^(-\{{2}~\d+|)/) # -endnote + para='' + end case para when /<:i1>/ if para =~/.*<:#>.*$/ diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 6b91f34f..903ce869 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -270,7 +270,11 @@ WOK if d_meta; xml_head(d_meta) end end - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ \ + or para =~/1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~||)/ if para =~/.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ paranum=para[@regx,3] @@ -330,11 +334,14 @@ WOK #@@xml[:body] << "#{@tab*7}#{para[@regx,2]}\n" if para[@regx,2] # main text, contents, body KEEP #@@xml[:body] << "#{@tab*6}
" << "\n" if para[@regx] end - elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - elsif para =~/(MetaData)/ and para =~/<~(\d+);[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info + elsif para =~/(Note|Endnotes?)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(MetaData)/ \ + and para =~/<~(\d+);[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info format_scroll=Format_scroll.new(@md,'
MetaData') para=format_scroll.bold_para - elsif para =~/(Owner Details)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(Owner Details)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ format_scroll=Format_scroll.new(@md,'
Owner Details') @@xml[:owner_details]=format_scroll.bold_para para='' @@ -343,7 +350,10 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if (para =~// and para =~/^(-\{{2}~\d+|)/) # -endnote + if (para =~// \ + and para =~/^(-\{{2}~\d+|)/) # -endnote + para='' + end para=case para when /<:i[1-9]>/ if para =~/.*<:#>.*$/ diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index e739bf59..2aa8bb56 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -297,7 +297,10 @@ WOK if d_meta; xml_head(d_meta) end end - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ or para =~/1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~||)/ if para =~/.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ paranum=para[@regx,3] @@ -357,11 +360,14 @@ WOK #@@xml[:body] << "#{@tab*7}#{para[@regx,2]}\n" if para[@regx,2] # main text, contents, body KEEP #@@xml[:body] << "#{@tab*6}" << "\n" if para[@regx] end - elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - elsif para =~/(MetaData)/ and para =~/<~(\d+);[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info + elsif para =~/(Note|Endnotes?)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(MetaData)/ \ + and para =~/<~(\d+);[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info format_scroll=Format_scroll.new(@md,'
MetaData') para=format_scroll.bold_para - elsif para =~/(Owner Details)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(Owner Details)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ format_scroll=Format_scroll.new(@md,'
Owner Details') @@xml[:owner_details]=format_scroll.bold_para para='' @@ -370,7 +376,10 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if para =~// and para =~/^(-\{{2}~\d+|)/ # -endnote + if para =~// \ + and para =~/^(-\{{2}~\d+|)/ # -endnote + para='' + end if para =~/.*<:#>.*$/ para=if para =~ /<:i[1-9]>/ format_text=Format_text_object.new(para,'') diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index 14cc162f..f8259664 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -225,7 +225,11 @@ WOK xml_element="" 3.downto(lv) do |x| y=x - 1 - @@xml[:body] << "#{@tab*5}\n" if @cont[1] or @cont[2] or @cont[3] + if @cont[1] \ + or @cont[2] \ + or @cont[3] + @@xml[:body] << "#{@tab*5}\n" + end #@@xml[:body] << "#{@tab*5}\n" if @cont[1] == true or @cont[2] == true or @cont[3] == true @cont[1]=false if @cont[1] @cont[2]=false if @cont[2] @@ -267,7 +271,10 @@ WOK end @cont[1]=true when 5 - @@xml[:body] << "#{@tab*5}\n" if @cont[2] or @cont[1] + if @cont[2] \ + or @cont[1] + @@xml[:body] << "#{@tab*5}\n" + end if @copen[3] == true #6~ [3,2].each { |v| @@xml[:body] << "#{@tab*n}\n" } elsif @copen[2] == true #5~ @@ -275,8 +282,14 @@ WOK end @cont[2]=true when 6 - @@xml[:body] << "#{@tab*5}\n" if @cont[3] or @cont[2] or @cont[1] - [3].each { |v| @@xml[:body] << "#{@tab*n}\n" } if @copen[3] #6{ + if @cont[3] \ + or @cont[2] \ + or @cont[1] + @@xml[:body] << "#{@tab*5}\n" + end + if @copen[3] #6{ + [3].each { |v| @@xml[:body] << "#{@tab*n}\n" } + end @cont[3]=true end end @@ -340,7 +353,11 @@ WOK if d_meta; xml_head(d_meta) end end - @rcdc=true if @rcdc==false and (para =~/~metadata/ or para =~/1~meta\s+Document Information/) + if @rcdc==false \ + and (para =~/~metadata/ \ + or para =~/1~meta\s+Document Information/) + @rcdc=true + end if para !~/(^0~||)/ if para =~/.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ paranum=para[@regx,3] @@ -403,19 +420,25 @@ WOK else 'norm' end xml_markup(para) - @@xml[:body] << %{#{@tab*6}} << "\n" if para[@regx] and para[@regx,3] + if para[@regx] \ + and para[@regx,3] + @@xml[:body] << %{#{@tab*6}} << "\n" + end @@xml[:body] << "#{@tab*7}#{para[@regx,3]}" << "\n" if para[@regx,3] @@xml[:body] << %{#{@tab*7}#{para[@regx,2]}\n} if para[@regx,2] # main text, contents, body KEEP @@xml[:body] << "#{@tab*6}" << "\n" if para[@regx] end end - elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(Note|Endnotes?)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #format_scroll=MonoSiSU.new('
Note') #para=format_scroll.boldPara - elsif para =~/(MetaData)/ and para =~/<~\d+;[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info + elsif para =~/(MetaData)/ \ + and para =~/<~\d+;[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info format_scroll=Format_scroll.new(@md,'
MetaData') para=format_scroll.bold_para - elsif para =~/(Owner Details)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para =~/(Owner Details)/ \ + and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ format_scroll=Format_scroll.new(@md,'
Owner Details') @@xml[:owner_details]=format_scroll.bold_para para='' @@ -424,7 +447,10 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if para =~// and para =~/^(-\{{2}~\d+|)/ # -endnote + if para =~// \ + and para =~/^(-\{{2}~\d+|)/ # -endnote + para='' + end if para =~/.*<:#>.*$/ para=case para when /<:i[1-9]>/ -- cgit v1.2.3