From 25e9f4f2a37608f9704645f92a50615a01a50db5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 29 May 2013 19:36:42 -0400 Subject: v4 v5: document version check, disable * automatic check disabled * check and correction of pre 0.38 markup removed --- lib/sisu/v4/dal_doc_str.rb | 48 ----------- lib/sisu/v4/dal_substitutions_and_insertions.rb | 5 -- lib/sisu/v4/param.rb | 105 +++++++----------------- lib/sisu/v5/dal_doc_str.rb | 48 ----------- lib/sisu/v5/dal_substitutions_and_insertions.rb | 5 -- lib/sisu/v5/param.rb | 105 +++++++----------------- 6 files changed, 60 insertions(+), 256 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v4/dal_doc_str.rb b/lib/sisu/v4/dal_doc_str.rb index dfea4ad4..25c6f854 100644 --- a/lib/sisu/v4/dal_doc_str.rb +++ b/lib/sisu/v4/dal_doc_str.rb @@ -556,7 +556,6 @@ module SiSU_DAL_DocumentStructureExtract @md,@dob=md,dob end def structure - structure_markup_normalize structure_markup @dob end @@ -590,53 +589,6 @@ module SiSU_DAL_DocumentStructureExtract end @dob end - def structure_markup_normalize #needs a bit of thinking - dob=if @md.markup_version.determined < 0.38 #%convert internal representation, consider making 0.38 structure default ([A-C1-6] instead of [1-9]), requires downstream changes - @dob=@dob.gsub(/^[456]~/,'!_'). - gsub(/^3~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). - gsub(/^3~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). - gsub(/^2~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). - gsub(/^2~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). - gsub(/^1~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). - gsub(/^1~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). - gsub(/^:?C~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). - gsub(/^:?C~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). - gsub(/^:?B~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). - gsub(/^:?B~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). - gsub(/^:?A~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). - gsub(/^:?A~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") - @dob=if @dob =~/^@(?:level|markup):\s/ - @dob=@dob.gsub(/3/,'6'). - gsub(/2/,'5'). - gsub(/1/,'4'). - gsub(/:?C/,'3'). - gsub(/:?B/,'2'). - gsub(/:?A/,'1') - @dob - else @dob - end - else @dob - end - end - def structure_marks - t_o=if @md.markup_version.determined < 0.38 - @t_o=@t_o.gsub(/^1~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). - gsub(/^1~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}"). - gsub(/^2~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). - gsub(/^2~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). - gsub(/^3~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). - gsub(/^3~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). - gsub(/^4~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). - gsub(/^4~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). - gsub(/^5~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). - gsub(/^5~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). - gsub(/^6~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). - gsub(/^6~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). - gsub(/^[789]~/,'!_') - @t_o - else @t_o - end - end end class OCN def initialize(md,data) diff --git a/lib/sisu/v4/dal_substitutions_and_insertions.rb b/lib/sisu/v4/dal_substitutions_and_insertions.rb index ad510488..08a63c89 100644 --- a/lib/sisu/v4/dal_substitutions_and_insertions.rb +++ b/lib/sisu/v4/dal_substitutions_and_insertions.rb @@ -130,11 +130,6 @@ module SiSU_DAL_SubstituteAndInsert end data_new=[] data_expand.each do |para| - para=if @md.markup_version.determined >= 0.38 - SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_markup_normalize - else - SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_marks - end para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header gsub(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v4/param.rb index c1410597..cc9f7018 100644 --- a/lib/sisu/v4/param.rb +++ b/lib/sisu/v4/param.rb @@ -828,14 +828,14 @@ module SiSU_Param @doc={ lv: [] } @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' @@publisher='SiSU scribe' - attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:markup_version,:markup_declared,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section + attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section def initialize(fns_array,opt) @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false @seg_autoname_safe=true @daisy,@sem_tag=false,false - @authorship,@markup_instruction,@markup_declared,@image='','','','' #check which other values should be set to empty rather than nil + @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil @markup=@markup_instruction #use @markup_instruction @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} @@ -954,44 +954,6 @@ module SiSU_Param @generated=Time.now fns_array=@data.dup skip unless fns_array # consider - @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] - sm_a,sm_b,sm_c=fns_array[0].match(/^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)([0-9]+)?(?:\.([0-9]+))?(?:\.([0-9]+))?$/)[1..3] - sm_c ||=0 - sv=(@opt.cmd =~/[VMv]/) ? ("SiSU version (#{@sisu_version[:version]})") : '' - s_a,s_b,s_c=@sisu_version[:version].match(/^([0-9]+)?(?:\.([0-9]+))?(?:\.([0-9]+))?(?:[~-]\S+)?$/)[1..3] - tell=(@markup_version_declared.to_f==@markup_version.determined) \ - ? SiSU_Screen::Ansi.new(@opt.cmd,"Markup version (#{@markup_version.series} version #{@markup_version.determined})",sv) - : SiSU_Screen::Ansi.new(@opt.cmd,"Markup version declared (#{@markup_version_declared}), determined (#{@markup_version.series} version #{@markup_version.determined})",sv) - 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 - 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 - true - else false - end - if ok - tell.txt_green if @opt.cmd =~/[vVM]/ - else - SiSU_Screen::Ansi.new(@opt.cmd,"WARNING: markup version determined (#{@markup_version.determined}) or markup version declared (#{@markup_version_declared}) is newer than SiSU version (#{@sisu_version[:version]})").warn unless @opt.cmd =~/q/ - end - else - SiSU_Screen::Ansi.new(@opt.cmd,'No SiSU markup version provided').warn if @opt.cmd =~/[VM]/ - end - else - mv=if @markup_version.determined.is_a?(Float) - x=@markup_version.determined - "markup version determined #{x}" - else '' - end - SiSU_Screen::Ansi.new(@opt.cmd,'SiSU filetype indicator not provided',mv).warn unless @opt.cmd =~/q/ - end @code_flag=false fns_array.each do |para| #% scan document if para !~/^%+\s/ \ @@ -1142,11 +1104,6 @@ module SiSU_Param @lvs[6]=1 end if para =~ /^:A~/ #% processing - if @markup.nil? \ - or @markup.empty? - @markup=@markup_version.determined.to_s - elsif @markup !~/0\.38/ then @markup=@markup.strip + "; #{@markup_version.determined}" - end if not defined? @title.full.nil? tf=para[/^:A~\S*(.+)$/m,1] tf="@title: #{tf}" @@ -1273,38 +1230,36 @@ module SiSU_Param else @i18n=[ 'en' ] end - if @markup_version.determined >= 0.38 #convert values in headers to internal representation - translated=[] - translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] - translate_list.each do |t| - translate=t.to_s if t - translated << if translate - translate.gsub!(/3/,'6') - translate.gsub!(/2/,'5') - translate.gsub!(/1/,'4') - 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=(translate =~/^\d+$/) \ - ? translate.to_i - : translate - else nil - end + translated=[] + translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] + translate_list.each do |t| + translate=t.to_s if t + translated << if translate + translate.gsub!(/3/,'6') + translate.gsub!(/2/,'5') + translate.gsub!(/1/,'4') + 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=(translate =~/^\d+$/) \ + ? translate.to_i + : translate + else nil end - @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated - @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). - gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). - gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). - 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 + @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). + 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}") papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) papersize_array_opt=[ ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), diff --git a/lib/sisu/v5/dal_doc_str.rb b/lib/sisu/v5/dal_doc_str.rb index da417bd6..2979412b 100644 --- a/lib/sisu/v5/dal_doc_str.rb +++ b/lib/sisu/v5/dal_doc_str.rb @@ -556,7 +556,6 @@ module SiSU_DAL_DocumentStructureExtract @md,@dob=md,dob end def structure - structure_markup_normalize structure_markup @dob end @@ -590,53 +589,6 @@ module SiSU_DAL_DocumentStructureExtract end @dob end - def structure_markup_normalize #needs a bit of thinking - dob=if @md.markup_version.determined < 0.38 #%convert internal representation, consider making 0.38 structure default ([A-C1-6] instead of [1-9]), requires downstream changes - @dob=@dob.gsub(/^[456]~/,'!_'). - gsub(/^3~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). - gsub(/^3~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). - gsub(/^2~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). - gsub(/^2~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). - gsub(/^1~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). - gsub(/^1~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). - gsub(/^:?C~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). - gsub(/^:?C~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). - gsub(/^:?B~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). - gsub(/^:?B~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). - gsub(/^:?A~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). - gsub(/^:?A~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}") - @dob=if @dob =~/^@(?:level|markup):\s/ - @dob=@dob.gsub(/3/,'6'). - gsub(/2/,'5'). - gsub(/1/,'4'). - gsub(/:?C/,'3'). - gsub(/:?B/,'2'). - gsub(/:?A/,'1') - @dob - else @dob - end - else @dob - end - end - def structure_marks - t_o=if @md.markup_version.determined < 0.38 - @t_o=@t_o.gsub(/^1~(\S+)/,"#{Mx[:lv_o]}1:\\1#{Mx[:lv_c]}"). - gsub(/^1~\s+/,"#{Mx[:lv_o]}1:#{Mx[:lv_c]}"). - gsub(/^2~(\S+)/,"#{Mx[:lv_o]}2:\\1#{Mx[:lv_c]}"). - gsub(/^2~\s+/,"#{Mx[:lv_o]}2:#{Mx[:lv_c]}"). - gsub(/^3~(\S+)/,"#{Mx[:lv_o]}3:\\1#{Mx[:lv_c]}"). - gsub(/^3~\s+/,"#{Mx[:lv_o]}3:#{Mx[:lv_c]}"). - gsub(/^4~(\S+)/,"#{Mx[:lv_o]}4:\\1#{Mx[:lv_c]}"). - gsub(/^4~\s+/,"#{Mx[:lv_o]}4:#{Mx[:lv_c]}"). - gsub(/^5~(\S+)/,"#{Mx[:lv_o]}5:\\1#{Mx[:lv_c]}"). - gsub(/^5~\s+/,"#{Mx[:lv_o]}5:#{Mx[:lv_c]}"). - gsub(/^6~(\S+)/,"#{Mx[:lv_o]}6:\\1#{Mx[:lv_c]}"). - gsub(/^6~\s+/,"#{Mx[:lv_o]}6:#{Mx[:lv_c]}"). - gsub(/^[789]~/,'!_') - @t_o - else @t_o - end - end end class OCN def initialize(md,data) diff --git a/lib/sisu/v5/dal_substitutions_and_insertions.rb b/lib/sisu/v5/dal_substitutions_and_insertions.rb index 051d2bfd..eeabc1a5 100644 --- a/lib/sisu/v5/dal_substitutions_and_insertions.rb +++ b/lib/sisu/v5/dal_substitutions_and_insertions.rb @@ -130,11 +130,6 @@ module SiSU_DAL_SubstituteAndInsert end data_new=[] data_expand.each do |para| - para=if @md.markup_version.determined >= 0.38 - SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_markup_normalize - else - SiSU_DAL_DocumentStructureExtract::Structure.new(@md,para).structure_marks - end para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header gsub(/^((?:[1-9]|:?[A-C])~\S*)\s*$/,'\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 if para =~/^@\S+?:/ diff --git a/lib/sisu/v5/param.rb b/lib/sisu/v5/param.rb index 11c2fe81..a78e9fbd 100644 --- a/lib/sisu/v5/param.rb +++ b/lib/sisu/v5/param.rb @@ -828,14 +828,14 @@ module SiSU_Param @doc={ lv: [] } @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' @@publisher='SiSU scribe' - attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:markup_version,:markup_declared,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section + attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:sisu_version,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section def initialize(fns_array,opt) @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@sisu_version=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil @data,@path,@fns,@fno,@opt=fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx=false,false,false,false,false,false,false @seg_autoname_safe=true @daisy,@sem_tag=false,false - @authorship,@markup_instruction,@markup_declared,@image='','','','' #check which other values should be set to empty rather than nil + @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil @markup=@markup_instruction #use @markup_instruction @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} @@ -954,44 +954,6 @@ module SiSU_Param @generated=Time.now fns_array=@data.dup skip unless fns_array # consider - @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] - sm_a,sm_b,sm_c=fns_array[0].match(/^(?:%\s+)?(?:SiSU\s+(?:master\s+)?|sisu-)([0-9]+)?(?:\.([0-9]+))?(?:\.([0-9]+))?$/)[1..3] - sm_c ||=0 - sv=(@opt.cmd =~/[VMv]/) ? ("SiSU version (#{@sisu_version[:version]})") : '' - s_a,s_b,s_c=@sisu_version[:version].match(/^([0-9]+)?(?:\.([0-9]+))?(?:\.([0-9]+))?(?:[~-]\S+)?$/)[1..3] - tell=(@markup_version_declared.to_f==@markup_version.determined) \ - ? SiSU_Screen::Ansi.new(@opt.cmd,"Markup version (#{@markup_version.series} version #{@markup_version.determined})",sv) - : SiSU_Screen::Ansi.new(@opt.cmd,"Markup version declared (#{@markup_version_declared}), determined (#{@markup_version.series} version #{@markup_version.determined})",sv) - 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 - 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 - true - else false - end - if ok - tell.txt_green if @opt.cmd =~/[vVM]/ - else - SiSU_Screen::Ansi.new(@opt.cmd,"WARNING: markup version determined (#{@markup_version.determined}) or markup version declared (#{@markup_version_declared}) is newer than SiSU version (#{@sisu_version[:version]})").warn unless @opt.cmd =~/q/ - end - else - SiSU_Screen::Ansi.new(@opt.cmd,'No SiSU markup version provided').warn if @opt.cmd =~/[VM]/ - end - else - mv=if @markup_version.determined.is_a?(Float) - x=@markup_version.determined - "markup version determined #{x}" - else '' - end - SiSU_Screen::Ansi.new(@opt.cmd,'SiSU filetype indicator not provided',mv).warn unless @opt.cmd =~/q/ - end @code_flag=false fns_array.each do |para| #% scan document if para !~/^%+\s/ \ @@ -1142,11 +1104,6 @@ module SiSU_Param @lvs[6]=1 end if para =~ /^:A~/ #% processing - if @markup.nil? \ - or @markup.empty? - @markup=@markup_version.determined.to_s - elsif @markup !~/0\.38/ then @markup=@markup.strip + "; #{@markup_version.determined}" - end if not defined? @title.full.nil? tf=para[/^:A~\S*(.+)$/m,1] tf="@title: #{tf}" @@ -1273,38 +1230,36 @@ module SiSU_Param else @i18n=[ 'en' ] end - if @markup_version.determined >= 0.38 #convert values in headers to internal representation - translated=[] - translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] - translate_list.each do |t| - translate=t.to_s if t - translated << if translate - translate.gsub!(/3/,'6') - translate.gsub!(/2/,'5') - translate.gsub!(/1/,'4') - 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=(translate =~/^\d+$/) \ - ? translate.to_i - : translate - else nil - end + translated=[] + translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] + translate_list.each do |t| + translate=t.to_s if t + translated << if translate + translate.gsub!(/3/,'6') + translate.gsub!(/2/,'5') + translate.gsub!(/1/,'4') + 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=(translate =~/^\d+$/) \ + ? translate.to_i + : translate + else nil end - @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated - @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). - gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). - gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). - 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 + @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated + @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). + gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). + gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). + 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}") papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) papersize_array_opt=[ ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), -- cgit v1.2.3