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/sisu/v0/dal.rb | |
parent | regex matching of images, (and rearrangement of conditionals) (diff) |
mostly the arrangement of conditionals
Diffstat (limited to 'lib/sisu/v0/dal.rb')
-rw-r--r-- | lib/sisu/v0/dal.rb | 64 |
1 files changed, 45 insertions, 19 deletions
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 |