aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/param.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-10-15 19:22:03 +0100
committerRalph Amissah <ralph@amissah.com>2007-10-15 19:25:53 +0100
commit8e092e0f3acc154f60f296419d1fab4d59f65e53 (patch)
treef4cc75bcad883a529fef8924e3edeaa2873064ec /lib/sisu/v0/param.rb
parentremote_conn, accepting multiple remote hosts, sysenv also beginning of rearra... (diff)
regex matching of images, (and rearrangement of conditionals)
Diffstat (limited to 'lib/sisu/v0/param.rb')
-rw-r--r--lib/sisu/v0/param.rb104
1 files changed, 73 insertions, 31 deletions
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 =~/<![abcdeghijklmnopqrstuvwxyz]/i # <!f not included
+ if para !~/^\%+\s/ \
+ and para =~/<![abcdeghijklmnopqrstuvwxyz]/i # <!f not included
raise "Old markup style in file #@fns, current version #{@sisu_version[:project]} #{@sisu_version[:version]} #{@sisu_version[:date_stamp]} #{@sisu_version[:date]}:\n\t\t#{para}\n\n"
end
@code_flag=case para
@@ -257,7 +263,8 @@ module SiSU_Param
else @code_flag
end
regx_header=/^(?:0~|@\S+?:[+-]?\s)/
- if para =~regx_header and not @code_flag #or para=~/^(?:1|:?A)~/
+ if para =~regx_header \
+ and not @code_flag #or para=~/^(?:1|:?A)~/
case para
when /^(?:0~ocn|@ocn:)\s+(.+?)$/m; @ocn=$1 #% processing
when /^(?:0~title|@title:)\s+(.+?)$/m #% metainfo DC
@@ -298,7 +305,8 @@ module SiSU_Param
when /^(?:0~|@)date.+?$/m #% metainfo DC
if para =~/(?:0~date|@date:)\s+(.+?)$/m
@dc_date=$1.strip
- if @dc_date !~regx_date and not @dc_date.empty?
+ if @dc_date !~regx_date \
+ and not @dc_date.empty?
tell=SiSU_Screen::Ansi.new(@cmd,'Date Format should be','YYYY-MM-DD','please correct document','Date','field, current value:',@dc_date)
tell.instruct if @cmd =~/v/
end
@@ -306,7 +314,8 @@ module SiSU_Param
end
if para =~/(?:0~date\.created|@date\.created:)\s*(.+?)$/m
date=$1.strip
- if date !~regx_date and not date.empty?
+ if date !~regx_date \
+ and not date.empty?
tell=SiSU_Screen::Ansi.new(@cmd,'Date Format should be','YYYY-MM-DD','please correct document','Date','field, current value:',date)
tell.instruct if @cmd =~/v/
end
@@ -315,7 +324,8 @@ module SiSU_Param
end
if para =~/(?:0~date\.issued|@date\.issued:)\s*(.+?)$/m
date=$1.strip
- if date !~regx_date and not date.empty?
+ if date !~regx_date \
+ and not date.empty?
tell=SiSU_Screen::Ansi.new(@cmd,'Date Format should be','YYYY-MM-DD','please correct document','Date','field, current value:',date)
tell.instruct if @cmd =~/v/
end
@@ -324,7 +334,8 @@ module SiSU_Param
end
if para =~/(?:0~date\.available|@date\.available:)\s*(.+?)$/m
date=$1.strip
- if date !~regx_date and not date.empty?
+ if date !~regx_date \
+ and not date.empty?
tell=SiSU_Screen::Ansi.new(@cmd,'Date Format should be','YYYY-MM-DD','please correct document','Date','field, current value:',date)
tell.instruct if @cmd =~/v/
end
@@ -333,7 +344,8 @@ module SiSU_Param
end
if para =~/^(?:0~date\.valid|@date\.valid:)\s*(.+?)$/m
date=$1.strip
- if date !~regx_date and not date.empty?
+ if date !~regx_date \
+ and not date.empty?
tell=SiSU_Screen::Ansi.new(@cmd,'Date Format should be','YYYY-MM-DD','please correct document','Date','field, current value:',date)
tell.instruct if @cmd =~/v/
end
@@ -342,7 +354,8 @@ module SiSU_Param
end
if para =~/^(?:0~date\.modified|@date\.modified:)\s*(.+?)$/m #% of interest rss feed & sitemap
date=$1.strip
- if date !~regx_date and not date.empty?
+ if date !~regx_date \
+ and not date.empty?
tell=SiSU_Screen::Ansi.new(@cmd,'Date Format should be','YYYY-MM-DD','please correct document','Date','field, current value:',date)
tell.instruct if @cmd =~/v/
end
@@ -539,11 +552,14 @@ module SiSU_Param
else #%
if para =~ /^(?:1|:?A)~/ #% processing
if para=~/^:?A~/
- if @markup.nil? or @markup.empty?; @markup=@markup_version.to_s
+ if @markup.nil? \
+ or @markup.empty?
+ @markup=@markup_version.to_s
elsif @markup !~/0\.38/; @markup=@markup.strip + "; #@markup_version"
end
end
- if (para=~/^:?A~/ and @markup_version >= 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(/(<p>|<p \/>|<br>|<br \/>)/,'')
@@ -580,15 +596,25 @@ module SiSU_Param
if para =~/table\{|<!tableh?\s+c\d+;.+?!>/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(/(<p>|<p \/>|<br>|<br \/>)/,'')
@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