diff options
author | Ralph Amissah <ralph@amissah.com> | 2007-10-15 19:27:16 +0100 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2007-10-15 19:27:16 +0100 |
commit | e1ec4bd2dad2bd22ad97cea398ae1cfcfae183a2 (patch) | |
tree | 6ffe3ae1b2453578a032ce053934a31f980645e9 /lib | |
parent | regex matching of images, (and rearrangement of conditionals) (diff) |
mostly the arrangement of conditionals
Diffstat (limited to 'lib')
50 files changed, 796 insertions, 339 deletions
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<ENDNOTES>" @@ -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}: <u>#{@md.sc_filename}</u> <~0;m#{ocnm};v#{ocnv}>" else @rc << "#{@tr.sourcefile}: <u>#{@md.fns}</u> <~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: <u>#{@md.file_encoding}</u> <~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+?;.+?)$/,'<!T¡ \1!>') @@flag['table_to']=true end - if @@flag['table_to'] and para =~/\}table/ + if @@flag['table_to'] \ + and para =~/\}table/ para.gsub!(/^\}table\s*$/,"<!TZ!>\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)>|<!TZ!>)/ + if @@counter <= @@columns.to_i \ + and line !~/(\}T\s*$|<:table[-_](close|end)>|<!TZ!>)/ line.gsub!(/(.+)/,"¡¡#{@@column[@@counter]}¡\\1") unless line =~/<!Th?¡/ @@counter+=1 end diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index a0dfc405..993e64ff 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -72,7 +72,8 @@ module Syntax tail_m_ital=%q{(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$)} tail_m_bold=%q{(?:(?:<\/i>)?(?:\s|[.,;:?!'")]|~\^|~\\\{\s|$))?} bold_line=%q{^!_\s.+?(?:<br>|\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],'<i>\1</i>') - 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,'<i>\1</i>') 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],'<b>\1</b>') - 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,'<b>\1</b>') 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*<u>([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*+]+ <a name="_[\d*+]+"/ and not pg =~/^<:code>/ + if pg =~/~[{\[][\d*+]+ <a name="_[\d*+]+"/ \ + and not pg =~/^<:code>/ 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 name="(\d+)"><\/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+|)$/, %{ <p class="#{ocn_class}"> @@ -227,7 +231,8 @@ module SiSU_HTML_Format </td>} 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/ %{ <td align="center" bgcolor=#{@vz.color_band2}> <a href="#{@md.fn[:pdf_p]}" target="_top" #{@vz.js_portrait}> @@ -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 %{<td align="center" bgcolor=#{@vz.color_band2}> <a href="#{@md.fn[:concordance]}" target="_top" #{@vz.js_concordance}> #{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>|<a\s+name="\S+?">/mi + one=if @one \ + and @one =~/<\/?i>|<a\s+name="\S+?">/mi @one.gsub(/<\/?i>|<a\s+name="\S+?">/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 '<br />' + @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<a name="metadata"></a>') 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~|<ENDNOTES>|<EOF>)/ 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,'<br /><a name="notes">Note</a>') 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,'<br /><a name="owner.details">Owner Details</a>') @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 =~/<a name="n\d+">/ and para =~/^(?:\^~\d+\s|<!e[:_]\d+!>)/) # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though + if para =~/<a name="n\d+">/ \ + and para =~/^(?:\^~\d+\s|<!e[:_]\d+!>)/ # 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 <p class="center" problems may arise 2005w11 ! one,two=/(.*)<:center>(.*)/.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 =~/^<ENDNOTES>|^<EOF>/ - if newfile == 1 or para =~/^<ENDNOTES>|^<EOF>/ + if @@is4 == 1 \ + or para =~/^<ENDNOTES>|^<EOF>/ + if newfile == 1 \ + or para =~/^<ENDNOTES>|^<EOF>/ newfile=0 - if para =~/^4~\S+/ or para =~/^<ENDNOTES>|^<EOF>/ # @@level4 + if para =~/^4~\S+/ \ + or para =~/^<ENDNOTES>|^<EOF>/ # @@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 !~/^<!TZ!>/ + if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \ + and para !~/^<!TZ!>/ 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 =~/^<!TZ!>/ + elsif para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ \ + and para =~/^<!TZ!>/ 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 name=\"h\d.*?\">(.+?)<\/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*+]+ <a name="_[\d*+]+"/ and not para =~/^<:code>/ # endnote- + if para =~/~[{\[][\d*+]+ <a name="_[\d*+]+"/ \ + and not para =~/^<:code>/ # 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$/ %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}} else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}} end @@ -322,13 +323,15 @@ module SiSU_Tune para.gsub!(/!new/, %{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}) para.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - 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)/,'<<a href="mailto:\1">\1</a>>\2') end para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url para.gsub!(/(^|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@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+)/,'<a href="\1">\1</a>') end para.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/}) diff --git a/lib/sisu/v0/hub.rb b/lib/sisu/v0/hub.rb index 9fe102e7..d7e01606 100644 --- a/lib/sisu/v0/hub.rb +++ b/lib/sisu/v0/hub.rb @@ -132,7 +132,9 @@ module SiSU put=fns.gsub(/(.+)?\.ssm\.sst$/,'\1.ssm') @opt.fns=fns if @req !~/(?:urls|remote)$/ - if @req=~/^dal$/ and FileTest.file?(@opt.fns) and @opt.fns =~ /\.(?:(?:-|ssm\.)?sst|ssm)$/ + if @req=~/^dal$/ \ + and FileTest.file?(@opt.fns) \ + and @opt.fns =~ /\.(?:(?:-|ssm\.)?sst|ssm)$/ if fns =~ /\.ssm$/; require "#{SiSU_lib}/composite" #pre-processing SiSU_Assemble::Composite.new(@opt).read @opt.fns=fns.gsub(/\.ssm$/,'.ssm.sst') @@ -297,17 +299,19 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ def actions if @opt.mod.inspect =~/--convert|--to|--from/; require "#{SiSU_lib}/sst_convert_markup" end - if @opt.cmd =~/([abCcDdFfgGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ and - @opt.cmd =~/^-/ and - @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ or - @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ #and + if @opt.cmd =~/([abCcDdFfgGHhIiJjLMmNnOopQqrRSsTtUuVvwWXxYyZ_0-9])/ \ + and @opt.cmd =~/^-/ \ + and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ + or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ #and @@tell=SiSU_Screen::Ansi.new(@opt.cmd) @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX flag=SiSU_Env::Info_processing_flag.new extra='' if @opt.cmd !~/[mn]/ - extra+=if @opt.cmd =~/[abghHhIiJjNOoptTwXxz]/ and @opt.cmd !~/[mn]/; 'm' #% add dal - elsif ((@opt.cmd =~/[Dd]/ or (@opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ + extra+=if @opt.cmd =~/[abghHhIiJjNOoptTwXxz]/ \ + and @opt.cmd !~/[mn]/; 'm' #% add dal + elsif ((@opt.cmd =~/[Dd]/ \ + or (@opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ and @opt.mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ and @opt.cmd !~/[mn]/ 'm' #% add dal @@ -315,14 +319,21 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end end if @opt.cmd !~/y/ - extra+=if @opt.cmd =~/[abehHhIiJjNopsSstwXxz]/ and @opt.cmd !~/y/; 'y' #% add manifest - elsif (@opt.cmd =~/[Dd]/ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) and @opt.files[0] !~/^remove$/ and @opt.cmd !~/y/; 'y' #% add manifest + extra+=if @opt.cmd =~/[abehHhIiJjNopsSstwXxz]/ \ + and @opt.cmd !~/y/ + 'y' #% add manifest + elsif (@opt.cmd =~/[Dd]/ \ + or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/) \ + and @opt.files[0] !~/^remove$/ \ + and @opt.cmd !~/y/ + 'y' #% add manifest else '' end end @opt.cmd=@opt.cmd + extra if @opt.cmd =~/[vVM]/ #% version information - if @opt.cmd =~/V/ and @opt.files.empty? #% environment + if @opt.cmd =~/V/ \ + and @opt.files.empty? #% environment SiSU_Help::Help.new('env',@opt).environment else SiSU_Help::Help.new('env',@opt).sisu_version end @@ -339,7 +350,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ #path_dtd="#{@@env.path.output}/_sisu/xml/dtd" re_p=/(sisupod(?:\.zip)?|[^\/]+?\.ssp)$/ unless @opt.files.join(',') =~ re_p #do not mix pods with source markup files in command line - unless ( FileTest.directory?(path[:css]) and FileTest.directory?(path[:xsd]) ) + unless ( FileTest.directory?(path[:css]) \ + and FileTest.directory?(path[:xsd]) ) @opt.cmd=@opt.cmd +='C' unless @opt.cmd =~/C/ #FIX end if @opt.cmd =~/M/; $VERBOSE=false #debug $VERBOSE=true @@ -350,14 +362,14 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.cmd =~/C/ #% -C initialize/configure op('conf','configure site') if @opt.cmd =~/R/ - if @opt.mod.inspect =~/--init(?:ialize)?=site/ and - @opt.cmd =~/RZ/ + if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ + and @opt.cmd =~/RZ/ Operations.new(@opt).remote_put_base_site_rsync_match else Operations.new(@opt).remote_put_base_site_rsync end elsif @opt.cmd =~/r/ - if @opt.mod.inspect =~/--init(?:ialize)?=site/ and - @opt.cmd =~/CCr/ + if @opt.mod.inspect =~/--init(?:ialize)?=site/ \ + and @opt.cmd =~/CCr/ Operations.new(@opt).remote_put_base_site_all else Operations.new(@opt).remote_put_base_site end @@ -464,9 +476,11 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ #end #if @opt.cmd =~/J/; op('manpage_exp','manpage exp') #% -J manpage #end - if @opt.cmd =~/D/ or @opt.mod.inspect =~/--pgsql/; op('dbi','postgresql') #% -D DB postgresql + if @opt.cmd =~/D/ \ + or @opt.mod.inspect =~/--pgsql/; op('dbi','postgresql') #% -D DB postgresql end - if @opt.cmd =~/d/ or @opt.mod.inspect =~/--sqlite/; op('dbi','sqlite') #% -d DB sqlite + if @opt.cmd =~/d/ \ + or @opt.mod.inspect =~/--sqlite/; op('dbi','sqlite') #% -d DB sqlite end if @opt.cmd =~/G/; Operations.new(@opt).cgi #% -G cgi - used to make dbi intecface end @@ -484,7 +498,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end @msg,@msgs="\tsisu -W [to start ruby web-server on output directory]\n",nil @tell.call.print_brown if @opt.cmd =~/[uUvVM]/ unless @opt.files.join.empty? - if defined? @@env.path.processing and FileTest.directory?(@@env.path.processing) and @@env.path.processing =~/#{@@env.user}$/ #clean temporary processing directory of content as is located in public area + if defined? @@env.path.processing \ + and FileTest.directory?(@@env.path.processing) \ + and @@env.path.processing =~/#{@@env.user}$/ #clean temporary processing directory of content as is located in public area cd(@@env.path.processing_base_tmp) do rm_rf(@@env.user) unless @opt.cmd =~/M/ end end @@ -495,7 +511,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ require "#{SiSU_lib}/sst_identify_markup" markup_version=SiSU_Markup::Markup_identify.new(@opt).markup_version? elsif @opt.mod.inspect =~/--about/ #% help instructions - if @opt.mod.inspect =~/--about/ and not @opt.what.empty?; SiSU_Help::Help.new(@opt.what,'color_off').help_request + if @opt.mod.inspect =~/--about/ \ + and not @opt.what.empty? + SiSU_Help::Help.new(@opt.what,'color_off').help_request else SiSU_Help::Help.new('list','color_off').help_request end elsif @opt.mod.inspect =~/--sitemaps/ #% sitemaps @@ -507,7 +525,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end else #% help instructions unless @opt.mod.inspect =~/--convert|--to|--from/ - if @opt.mod.inspect =~/--help/ and not @opt.what.empty?; SiSU_Help::Help.new(@opt.what).help_request + if @opt.mod.inspect =~/--help/ \ + and not @opt.what.empty? + SiSU_Help::Help.new(@opt.what).help_request elsif @opt.mod.inspect =~/--help/; SiSU_Help::Help.new('list').help_request else SiSU_Help::Help.new('env',@opt).sisu_version tell=SiSU_Screen::Ansi.new(''," for HELP type:\n\tsisu --help [help request]\n\tman sisu\n or see the system or online documentation on SiSU:\n #{Config::CONFIG['datadir']}/doc/sisu/\n <http://www.jus.uio.no/sisu/>\n <http://sisudoc.org/>"); 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/ <<WOK <table summary="band" width="100%" border="0" cellpadding="3" cellspacing="0"> <tr><td align="left" bgcolor="#ffffff">#{vz.banner_band}</td><td width="60%"><p class="tiny">#{@url_brace.xml_open}<a href="#@base_url/#{file}">#@base_url/#{file}</a>#{@url_brace.xml_close}</p></td><td width="20%">#{@env.widget_static.search_form}</td><td><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#{vz.url_path_image}/sisu.png" alt="SiSU -->" /></a></td></tr> 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('<br /><a name="metadata">MetaData</a>') #para=formatMono.bold_para - elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para.include? 'Owner Details' \ + and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #formatMono=MonoSiSU.new('<br /><a name="owner.details">Owner Details</a>') #@@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 =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + para='' if (para =~/<a name="n\d+">/ \ + and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + 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); '<text:p text:style-name="P9"> </text:p>' + breakpage=if (@md.pagenew or @md.pagebreak) \ + and (@md.pagenew =~ m or @md.pagebreak =~m) + '<text:p text:style-name="P9"> </text:p>' else '' end end @@ -224,9 +228,11 @@ module SiSU_ODF %{#{breakpage}<text:h text:style-name="Heading_20_#{no}" text:outline-level="#{no}">#{para}</text:h>} 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 %{<draw:frame draw:style-name="fr1" draw:name="graphics#{@@img_count}" text:anchor-type="as-char" svg:width="#{w}cm" svg:height="#{h}cm" draw:z-index="2"><draw:image xlink:href="Pictures/#{i}" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame>#{c}} #anchor-type: as-char or paragraph or char or ... else %{<text:p text:style-name="P1">[image omitted]</text:p>} @@ -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~|<ENDNOTES>|<EOF>)/ 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 =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote + if para =~/<a name="n\d+">/ \ + and para =~/^(-\{{2}~\d+|<!e[:_]\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 %{<style:style style:name="Table2.N" style:family="table-column"><style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/></style:style>#@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]<<%{<?xml version="1.0" encoding="UTF-8"?>#@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('<br /><a name="metadata">MetaData</a>') #para=formatMono.bold_para - elsif para.include? 'Owner Details' and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ + elsif para.include? 'Owner Details' \ + and para !~/<~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ #formatMono=MonoSiSU.new('<br /><a name="owner.details">Owner Details</a>') #@plaintext[:owner_details]=formatMono.bold_para #para='' @@ -424,7 +438,8 @@ WOK format_text=Format_text_object.new(one,two) para=format_text.seg_no_paranum end - para='' if (para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote + para='' if (para =~/<a name="n\d+">/ \ + and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/) # -endnote case para when /<:i[1-9]>/ if para =~/.*<:#>.*$/m @@ -473,7 +488,8 @@ WOK filename_plaintext=SiSU_Env::SiSU_file.new(@md,@md.fn[:plain]).mkfile @sisu=[] @content.each do |para| # this is a hack - if para.class == Array and para.length > 0 + if para.class == Array \ + and para.length > 0 para.each do |line| line.gsub!(/\s+$/m,'') filename_plaintext.puts line #unix plaintext 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$/ %{<a href="#{u}">[#{png}]</a>#{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=%{ <meta name="dc.source" content="#{content}" />\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=%{ <meta name="dc.language" content="#{@md.dc_language[:name]}" />\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=%{ <meta name="dc.language" content="#{@md.language_original[:name]}" />\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<ENDNOTES>" @@ -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/ |