diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:19:13 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:19:13 -0400 |
commit | 98192c43c2d8686397a3884cacdc66ac93bafb02 (patch) | |
tree | 90903de5b159ac19992c88fe0d7fe7e232f969e4 /lib/sisu/v3/param.rb | |
parent | debian/changelog (3.1.15-2) (diff) | |
parent | COPYRIGHT, name change using uppercase, format changed (diff) |
Merge tag 'sisu_3.2.0' into debian/sid
Diffstat (limited to 'lib/sisu/v3/param.rb')
-rw-r--r-- | lib/sisu/v3/param.rb | 209 |
1 files changed, 148 insertions, 61 deletions
diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 91f77410..5563f780 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -64,7 +64,7 @@ module SiSU_Param require_relative 'param_identify_markup' # param_identify_markup.rb require_relative 'help' # help.rb include SiSU_Help - @@date=SiSU_Env::Info_date.new + @@date=SiSU_Env::InfoDate.new @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil @doc={ initialise: nil, markup: '', lnks: '', stmp: '', req: {} } @@yaml=@@yamladdr=nil @@ -82,8 +82,8 @@ module SiSU_Param opt.fns else opt.fns.gsub(/\.ssm$/,'.ssm.sst') end - Instantiate.new.param_instantiate - @env=SiSU_Env::Info_env.new(@fns) + SiSU_Param::Instantiate.new.param_instantiate + @env=SiSU_Env::InfoEnv.new(@fns) @pstorefile="#{@env.processing_path.dal}/#{@fns}.pstore" end def get @@ -113,8 +113,8 @@ module SiSU_Param else param_msg='Parameters extracted' fns_array=@env.read_source_file(@opt.fns) - md=Instructions.new(fns_array,@opt) - @md=Instructions.new(fns_array,@opt).extract + md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt) + @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract @md end if defined? @md.title.main # on removal check problems with -U @@ -126,7 +126,7 @@ module SiSU_Param @@md.opt=@opt @@md end - class Md_default + class MdDefault def rights(author,date) @author,@date=author,date def all @@ -179,7 +179,7 @@ module SiSU_Param end def name_format(name) if name - name.strip! + name=name.strip @name_a_h=[] authors=name.scan(/[^;]+/) authors.each_with_index do |a,i| @@ -776,27 +776,25 @@ module SiSU_Param m=@h['bold'] i=(m=~/\/i$/)? 'i' : '' z=if m - x=m.gsub(/^\/(.+?)\/i?/,'\1') - x.gsub!(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided rgx='\b(' + x + ')\b' y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) { str: '\b(?:' + x + ')\b', regx: y, i: i } else nil end - z end def italics m=@h['italics'] i=((m=~/\/i$/) ? 'i' : '') z=if m - x=m.gsub(/^\/(.+?)\/i?/,'\1') - x.gsub!(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided + x=m.gsub(/^\/(.+?)\/i?/,'\1'). + gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided rgx='\b(' + x + ')\b' y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) { str: '\b(?:' + x + ')\b', regx: y, i: i } else nil end - z end def emphasis if @h['emphasis'] =~/bold/; 'bold' @@ -813,6 +811,89 @@ module SiSU_Param else nil end end + def omit + m=@h['omit'] + @m=m ? (m.split(/,\s+/)) : nil + def list + @m + end + self + end + def ocn? + (omit.list.inspect =~/"ocn"/) \ + ? :off + : :na + end + def toc? + (omit.list.inspect =~/"toc"/) \ + ? :off + : :na + end + def manifest? + (omit.list.inspect =~/"manifest"/) \ + ? :off + : :na + end + def links_to_manifest? + (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ + ? :off + : :na + end + def metadata? + (omit.list.inspect =~/"metadata"/) \ + ? :off + : :na + end + def minitoc? + (omit.list.inspect =~/"minitoc"/) \ + ? :off + : :na + end + def html_minitoc? + (omit.list.inspect =~/"html_minitoc"/) \ + ? :off + : :na + end + def html_top_band? + (omit.list.inspect =~/"html_top_band"/) \ + ? :off + : :na + end + def html_navigation? + (omit.list.inspect =~/"html_navigation"/) \ + ? :off + : :na + end + def html_navigation_bar? + (omit.list.inspect =~/"html_navigation_bar"/) \ + ? :off + : :na + end + def segsubtoc? + (omit.list.inspect =~/"segsubtoc"/) \ + ? :off + : :na + end + def search_form? + (omit.list.inspect =~/"search_form"/) \ + ? :off + : :na + end + def html_search_form? + (omit.list.inspect =~/"html_search_form"/) \ + ? :off + : :na + end + def html_right_pane? + (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ + ? :off + : :na + end + def manifest_minitoc? + (omit.list.inspect =~/"manifest_minitoc"/) \ + ? :off + : :na + end def texpdf_font def main @h['texpdf_font'] \ @@ -863,16 +944,16 @@ module SiSU_Param end end if manpage['name'] - manpage['name']=manpage['name'].join("\n.br\n") - manpage['name'].gsub!(/(-)/m,"\\\\\\1") - manpage['name'].gsub!(/\A/,"\n.br\n.SH NAME\n.br\n") + manpage['name']=manpage['name'].join("\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH NAME\n.br\n") else manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' end if manpage['synopsis'] - manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n") - manpage['synopsis'].gsub!(/(-)/m,"\\\\\\1") - manpage['synopsis'].gsub!(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") + manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). + gsub(/(-)/m,"\\\\\\1"). + gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") else manpage['synopsis']='' end @@ -963,14 +1044,14 @@ module SiSU_Param @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} @authors,@topic_register_array,@papersize_array=[],[],[] @lvs=[nil,0,0,0,0,0,0] - @lang_code_insert=(@opt.dir_structure_by =~/language/) \ + @lang_code_insert=(@opt.dir_structure_by ==:language) \ ? '' : ".#{@opt.lng}" @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg begin - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@fns).error ensure end end @@ -989,9 +1070,9 @@ module SiSU_Param @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] @programs,@wc,@language,@language_original={},{},{},{} @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } - @prog=SiSU_Env::Info_settings.new - @sys=SiSU_Env::System_call.new - @env=SiSU_Env::Info_env.new(@fns) #watch + @prog=SiSU_Env::InfoSettings.new + @sys=SiSU_Env::SystemCall.new + @env=SiSU_Env::InfoEnv.new(@fns) #watch puts 'system locale: ' + @sys.locale if @opt.cmd =~/[MV]/ if @prog.wc \ and @sys.wc @@ -1009,7 +1090,7 @@ module SiSU_Param @locale=@sys.locale @file_encoding=@sys.file_encoding(fns,@opt.cmd) # programs set here for things that affect output appearance only - @programs[:pdf]=SiSU_Env::System_call.new.program_found?('pdflatex') + @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') if @opt.cmd =~/P/ #if @env.multilingual? m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] @@ -1036,13 +1117,13 @@ module SiSU_Param @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false @flag_separate_endnotes_make=true regx_date=/^\d{4}(?:-(?:[0][0-9]|1[0-2])(-(?:[0-2][0-9]|3[01]))?)?$/ - ver=SiSU_Env::Info_version.instance + ver=SiSU_Env::InfoVersion.instance @sisu_version=ver.get_version @ruby_version=ver.rbversion @generated=Time.now fns_array=@data.dup skip unless fns_array # consider - @markup_version=SiSU_Markup_type::Markup_identify.new(fns_array,@opt).markup_version? #% determine markup version + @markup_version=SiSU_MarkupType::MarkupIdentify.new(fns_array,@opt).markup_version? #% determine markup version if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?[\d.]*|sisu-[\d.]+)$/ #check markup and markup version if fns_array[0] =~ /^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)(?:(?:[0-9]+?)(?:\.[0-9]+?)(?:\.[0-9]+))?$/ #check markup and markup version @markup_version_declared=fns_array[0].match(/^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)([\d.]+)$/)[1] @@ -1096,27 +1177,27 @@ module SiSU_Param and not @code_flag #or para=~/^(?:1|:?A)~/ case para when /^@title:(.+)/m #% * header metadata - title - @title=Md.new($1.strip,@opt,@env).title + @title=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).title when /^@creator:(.+)/m #% * header metadata - creator - @creator=Md.new($1.strip,@opt,@env).creator + @creator=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).creator @authorship=@author=@creator.author @authors=@creator.author_detail when /^@date:(.+)/m #% * header metadata - date - @date=Md.new($1.strip,@opt,@env).date + @date=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).date when /^@publisher:\s+(.+)/m #% * header metadata - publisher - @publisher=Md.new($1.strip,@opt,@env).current_publisher + @publisher=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).current_publisher @current_publisher=@publisher when /^@rights:(.+)/m; #% * header metadata - rights - @rights=Md.new($1.strip,@opt,@env).rights + @rights=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).rights when /^@classify:(.+)/m; classify=$1 #% * header metadata - classify - @classify=Md.new($1.strip,@opt,@env).classify + @classify=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).classify when /^@original:(.+)/m #% * header metadata - original (document) - @original=Md.new($1.strip,@opt,@env).original + @original=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).original @source=@original.source when /^@notes?:\s(.+)\Z/m #% * header metadata - notes - @notes=Md.new($1.strip,@opt,@env).notes + @notes=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).notes when /^@links:\s+(.+?)\Z/m #% * header metadata - links - doc_links=Md.new($1.strip,@opt,@env).links + doc_links=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).links count=1 @links=[] doc_links.each do |doc_link| @@ -1128,7 +1209,7 @@ module SiSU_Param end @lnk=@links when /^@make:(.+)/m #% * header processing - make - @make=Md.new($1.strip,@opt,@env).make + @make=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).make if defined? @make.breaks \ and @make.breaks[:page_new] #clearpage @pagenew=@make.breaks[:page_new] @@ -1223,7 +1304,7 @@ module SiSU_Param if not defined? @title.full.nil? tf=para[/^:A~\S*(.+)$/m,1] tf="@title: #{tf}" - @title=Md.new(tf.strip,@opt,@env).title + @title=SiSU_Param::Parameters::Md.new(tf.strip,@opt,@env).title end @html_title=@title.full.gsub(/(<p>|<p \/>|<br>|<br \/>)/,'') SiSU_Screen::Ansi.new(@opt.cmd,'Parameters',@html_title).txt_grey if @opt.cmd =~/v/ @@ -1272,7 +1353,7 @@ module SiSU_Param end end end - para.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) + para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) if para !~/^%+\s/ \ and para =~@rgx_image @ec[:image] << para.scan(@rgx_image).uniq @@ -1284,22 +1365,21 @@ module SiSU_Param end end #% here endeth the document loop if @ec[:image].length > 0 - @ec[:image].flatten! - @ec[:image].uniq! + @ec[:image]=@ec[:image].flatten.uniq @ec[:image].delete_if {|x| x =~/https?:\/\// } - @ec[:image].sort! + @ec[:image]=@ec[:image].sort end - @ec[:audio].uniq!; @ec[:audio].flatten!; @ec[:audio].sort! - @ec[:multimedia].uniq!; @ec[:multimedia].flatten!; @ec[:multimedia].sort! + @ec[:audio]=@ec[:audio].uniq.flatten.sort + @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort unless @rights if defined? @creator.author \ and @creator.author \ and defined? @date.published \ and @date.published - @rights=Md_default.new.rights(@creator.author,@date.published) + @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) elsif defined? @creator.author \ and @creator.author - @rights=Md_default.new.rights("[#{@creator.author}]",'') + @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') end end if defined? @classify.topic_register \ @@ -1315,10 +1395,10 @@ module SiSU_Param m[-1]=m[-1].scan(/[^|]+/) if m[-1] =~/[|]/ @topic_register_array << m end - @topic_register_array.sort! + @topic_register_array=@topic_register_array.sort end if @i18n - @i18n.uniq! + @i18n=@i18n.uniq @i18n << 'en' unless @i18n.find_index("en") else @i18n=[ 'en' ] @@ -1335,6 +1415,13 @@ module SiSU_Param translate.gsub!(/:?C/,'3') translate.gsub!(/:?B/,'2') translate.gsub!(/:?A/,'1') + # looks like an ok substituion for the above but is not, causes problems, check why + #translate=translate.gsub(/3/,'6'). + # gsub(/2/,'5'). + # gsub(/1/,'4'). + # gsub(/:?C/,'3'). + # gsub(/:?B/,'2'). + # gsub(/:?A/,'1') translate=if translate =~/^\d+$/; translate.to_i else translate end @@ -1342,10 +1429,10 @@ module SiSU_Param end end @pagenew,@pagebreak,@num_top,@toc_lev_limit=translated - @markup.gsub!(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}") - @markup.gsub!(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}") - @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}") + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). + gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") end if @opt.mod.inspect =~/--papersize[=-]\S+|--pdf[=-]\S+/ \ or @opt.mod.inspect =~/--(?:a4|letter|legal|book|a5|b5)\b/i #command line config/header override @@ -1356,8 +1443,8 @@ module SiSU_Param @filesize=(File.size(fn)).to_s if @sys.openssl !=false skin=@doc_skin \ - ? (SiSU_Env::Info_skin.new(@opt,@doc_skin).select) - : SiSU_Env::Info_skin.new(@opt).select + ? (SiSU_Env::InfoSkin.new(@opt,@doc_skin).select) + : SiSU_Env::InfoSkin.new(@opt).select @dgst,@dgst_skin=[],[] if @env.digest.type =~/sha256/ dgst=@sys.sha256(@env.source_file_with_path) @@ -1372,7 +1459,7 @@ module SiSU_Param end end @publisher ||= "#@@publisher (this copy)" - fn_set_lang=SiSU_Env::Standardise_language.new(@opt.lng).language + fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language unless @language[:code] \ and @language[:name] lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml @@ -1386,7 +1473,7 @@ module SiSU_Param @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) #fix # @flv.each do |l| -# lang=SiSU_Env::Standardise_language.new.file_to_language(l) +# lang=SiSU_Env::StandardiseLanguage.new.file_to_language(l) # c={ a: '', b: '', c: '' } # if @fnl[:pre] =~/\S/; c[:a]="#{lang[:c]}." # elsif @fnl[:mid] =~/\S/; c[:b]=".#{lang[:c]}" @@ -1394,8 +1481,8 @@ module SiSU_Param # end # @lang << [lang[:n],"#{c[:a]}sisu_manifest#{c[:b]}.html#{c[:c]}"] # end if @flv - @lang.uniq! - @fn=SiSU_Env::Env_call.new(@fns).lang(fn_set_lang[:c]) + @lang=@lang.uniq + @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) @identifier="#{@env.url.root}/#{@fnb}/#{@fn[:toc]}" #DC note constructed dc identifier if @en[:note] > 0 \ and @en[:sum] > 0 @@ -1423,7 +1510,7 @@ module SiSU_Param if @author !~/[\S]/ if @fns =~/\.ssm$/ \ and @opt.inspect =~/P/ - #@creator=Md.new('Text Insert',@opt,@env).creator + #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator else SiSU_Screen::Ansi.new(@opt.cmd,'Warning Document Author missing','please provide @creator: :author:').warn unless @opt.cmd =~/q/ end @@ -1495,7 +1582,7 @@ module SiSU_Param SiSU_Screen::Ansi.new(@opt.cmd,"doc_skin <- #{@doc_skin}").txt_grey if @opt.cmd =~/v/ end @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually - @file=SiSU_Env::SiSU_file.new(self) #watch + @file=SiSU_Env::FileOp.new(self) #watch Store.new(self,@env).store #% pstore self end @@ -1520,7 +1607,7 @@ module SiSU_Param end class Instantiate def param_instantiate - @@date=SiSU_Env::Info_date.new + @@date=SiSU_Env::InfoDate.new @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil @doc={ initialise: nil, |