From 059e31210711c0b51b2ae1ea9e4c82ec75ad5b89 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 25 Dec 2014 00:45:15 -0500 Subject: c&d: po4a (& git) revisited, revisit --- lib/sisu/current/ao.rb | 18 +- lib/sisu/current/ao_doc_str.rb | 690 ++++++++++++++++++++------------------- lib/sisu/current/ao_numbering.rb | 10 +- lib/sisu/current/dp.rb | 26 +- lib/sisu/current/git.rb | 6 +- lib/sisu/current/po4a.rb | 334 ++++++++++++------- lib/sisu/current/se_info_env.rb | 2 +- lib/sisu/develop/ao.rb | 18 +- lib/sisu/develop/ao_doc_str.rb | 690 ++++++++++++++++++++------------------- lib/sisu/develop/ao_numbering.rb | 10 +- lib/sisu/develop/dp.rb | 29 +- lib/sisu/develop/git.rb | 78 +++-- lib/sisu/develop/po4a.rb | 334 ++++++++++++------- lib/sisu/develop/se_info_env.rb | 2 +- 14 files changed, 1265 insertions(+), 982 deletions(-) (limited to 'lib') diff --git a/lib/sisu/current/ao.rb b/lib/sisu/current/ao.rb index 633c4442..e24fd4e9 100644 --- a/lib/sisu/current/ao.rb +++ b/lib/sisu/current/ao.rb @@ -86,8 +86,8 @@ module SiSU_AO @@idx_arr={ sst: [], tex: [], html: [], xhtml: [] } @@map_arr={ nametags: [], ocn_htmlseg: [] } @@fns=nil - def initialize(opt,fnx=nil) - @opt,@fnx=opt,fnx + def initialize(opt,fnx=nil,process=:complete) + @opt,@fnx,@process=opt,fnx,process @@fns ||=opt.fns fn_use=if fnx \ and fnx =~/\.ss[tmi]$/ @@ -273,6 +273,7 @@ module SiSU_AO protected def create_ao ao_array=[] + fnp = @fnx ? "#{@opt.fno} #{@fnx}" : @opt.fno unless @opt.act[:quiet][:set]==:on tell=(@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ @@ -283,7 +284,8 @@ module SiSU_AO ) : SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], - 'Document Abstraction',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" + 'Document Abstraction', + "[#{@opt.f_pth[:lng_is]}] #{fnp}" ) tell.blue_title_hi end @@ -296,7 +298,7 @@ module SiSU_AO meta=file_array=@env.source_file_processing_array(fn) @md=SiSU_Param::Parameters::Instructions.new(meta,@opt).extract meta=nil - ao=SiSU_AO::Make.new(fn,@md,file_array).song + ao=SiSU_AO::Make.new(fn,@md,file_array,@fnx,@process).song if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) @@ -347,7 +349,7 @@ module SiSU_AO ao=[] ao=(FileTest.file?(@fnc)) \ ? (File.open(@fnc,'r:utf-8'){ |f| ao=Marshal.load(f)}) - : SiSU_AO::Source.new(@opt).create_ao + : SiSU_AO::Source.new(@opt,@fnx,@process).create_ao end def read_idx_sst m=[] @@ -519,8 +521,8 @@ module SiSU_AO end end class Make - def initialize(fn,md,data) - @fn,@md,@data=fn,md,data + def initialize(fn,md,data,fnx,process) + @fn,@md,@data,@fnx,@process=fn,md,data,fnx,process @env=SiSU_Env::InfoEnv.new(@md.fns) end def reset @@ -551,7 +553,7 @@ module SiSU_AO data_obj, tags_map, ocn_html_seg_map= - SiSU_AO_Numbering::Numbering.new(@md,data_obj). # ao_numbering.rb + SiSU_AO_Numbering::Numbering.new(@md,data_obj,@fnx,@process). # ao_numbering.rb numbering_song data_obj, book_index_rel, diff --git a/lib/sisu/current/ao_doc_str.rb b/lib/sisu/current/ao_doc_str.rb index 40e1e0d0..50916d10 100644 --- a/lib/sisu/current/ao_doc_str.rb +++ b/lib/sisu/current/ao_doc_str.rb @@ -1257,8 +1257,8 @@ module SiSU_AO_DocumentStructureExtract end end class OCN - def initialize(md,data) - @md,@data=md,data + def initialize(md,data,fnx,process) + @md,@data,@fnx,@process=md,data,fnx,process end def structure_info def lv @@ -1318,31 +1318,33 @@ has incorrect level and/or parent level --} end def required_headers_present? - unless (defined? @md.title \ - and @md.title.full) - STDERR.puts %{required header missing: + if @process == :complete + unless (defined? @md.title \ + and @md.title.full) + STDERR.puts %{required header missing: @title: SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" } - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end end - end - unless (defined? @md.creator.author \ - and @md.creator.author) - STDERR.puts %{required header missing: + unless (defined? @md.creator.author \ + and @md.creator.author) + STDERR.puts %{required header missing: @creator: :author: anonymous? SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" } - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end end end end @@ -1381,337 +1383,341 @@ SKIPPED processing file: if not dob.obj =~/~#|-#/ ocn+=1 end - if dob.is==:heading \ - and (ln.to_s =~/^[0-9]/ \ - or ln.to_s =~@md.lv0 \ - or ln.to_s =~@md.lv1 \ - or ln.to_s =~@md.lv2 \ - or ln.to_s =~@md.lv3 \ - or ln.to_s =~@md.lv4 \ - or ln.to_s =~@md.lv5 \ - or ln.to_s =~@md.lv6 \ - or ln.to_s =~@md.lv7) - if not dob.obj =~/~#|-#/ - ocnh+=1 - end - if ln==0 \ - or ln=~@md.lv0 - @lev_occurences[:a] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh0+=1 #heading - node0="0:#{ocnh0};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node0="0:0;0" - end - document_structure_check_info(node0,node0) - @collapsed_lv0=0 - collapsed_level=@collapsed_lv0 - node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' - elsif ln==1 \ - or ln=~@md.lv1 - @lev_occurences[:b] += 1 + if @process == :complete \ + or (@fnx == @md.opt.fns \ + && @md.opt.fns =~/.sst$/) + if dob.is==:heading \ + and (ln.to_s =~/^[0-9]/ \ + or ln.to_s =~@md.lv0 \ + or ln.to_s =~@md.lv1 \ + or ln.to_s =~@md.lv2 \ + or ln.to_s =~@md.lv3 \ + or ln.to_s =~@md.lv4 \ + or ln.to_s =~@md.lv5 \ + or ln.to_s =~@md.lv6 \ + or ln.to_s =~@md.lv7) if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh1+=1 #heading - node1="1:#{ocnh1};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node1="1:0;0" + ocnh+=1 end - parent=if node0 - document_structure_check_info(node1,node0) - @collapsed_lv1=@collapsed_lv0+1 - node0 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node0,node0,:error) - node0 - end - collapsed_level=@collapsed_lv1 - node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX - elsif ln==2 \ - or ln=~@md.lv2 - @lev_occurences[:c] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh2+=1 - node2="2:#{ocnh2};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node2="2:0;0" - end - parent=if node1 - document_structure_check_info(node2,node1) - @collapsed_lv2=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node2,node0,:error) - node0 - end - collapsed_level=@collapsed_lv2 - node,ocn_sp=node2,"h#{ocnh}" - elsif ln==3 \ - or ln=~@md.lv3 - @lev_occurences[:d] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh3+=1 - node3="3:#{ocnh3};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node3="3:0;0" - end - parent=if node2 - document_structure_check_info(node3,node2) - @collapsed_lv3=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - puts %{parent is :A~ & this level #{dob.lv} + if ln==0 \ + or ln=~@md.lv0 + @lev_occurences[:a] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh0+=1 #heading + node0="0:#{ocnh0};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node0="0:0;0" + end + document_structure_check_info(node0,node0) + @collapsed_lv0=0 + collapsed_level=@collapsed_lv0 + node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' + elsif ln==1 \ + or ln=~@md.lv1 + @lev_occurences[:b] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh1+=1 #heading + node1="1:#{ocnh1};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node1="1:0;0" + end + parent=if node0 + document_structure_check_info(node1,node0) + @collapsed_lv1=@collapsed_lv0+1 + node0 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node0,node0,:error) + node0 + end + collapsed_level=@collapsed_lv1 + node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX + elsif ln==2 \ + or ln=~@md.lv2 + @lev_occurences[:c] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh2+=1 + node2="2:#{ocnh2};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node2="2:0;0" + end + parent=if node1 + document_structure_check_info(node2,node1) + @collapsed_lv2=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node2,node0,:error) + node0 + end + collapsed_level=@collapsed_lv2 + node,ocn_sp=node2,"h#{ocnh}" + elsif ln==3 \ + or ln=~@md.lv3 + @lev_occurences[:d] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh3+=1 + node3="3:#{ocnh3};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node3="3:0;0" + end + parent=if node2 + document_structure_check_info(node3,node2) + @collapsed_lv3=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + puts %{parent is :A~ & this level #{dob.lv} either parent should be level :B~ or this level should be level :B~ rather than #{dob.lv}} - document_structure_check_info(node3,node1,:error) - @collapsed_lv3=@collapsed_lv1+1 - node1 - else - document_structure_check_info(node3,node0,:error) - warning_incorrect_parent_level_or_level(dob.obj) - node0 - end - collapsed_level=@collapsed_lv3 - node,ocn_sp=node3,"h#{ocnh}" - elsif ln==4 \ - or ln=~@md.lv4 - @lev_occurences[:l1] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh4+=1 - node4="4:#{ocnh4};#{ocn}" - else - ocn_flag=false - node4="4:0;0" - end - parent=if node3 - document_structure_check_info(node4,node3) - @collapsed_lv4=@collapsed_lv3+1 - node3 - elsif node2 - document_structure_check_info(node4,node2) - @collapsed_lv4=@collapsed_lv2+1 - node2 - elsif node1 - document_structure_check_info(node4,node1) - @collapsed_lv4=@collapsed_lv1+1 - node1 - elsif node0 - document_structure_check_info(node4,node0) - @collapsed_lv4=@collapsed_lv0+1 - node0 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node4,node0,:error) - node0 - end - collapsed_level=@collapsed_lv4 - node,ocn_sp=node4,"h#{ocnh}" - elsif ln==5 \ - or ln=~@md.lv5 - @lev_occurences[:l2] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh5+=1 - node5="5:#{ocnh5};#{ocn}" - else - ocn_flag=false - node5="5:0;0" - end - parent=if node4 - document_structure_check_info(node5,node4) - @collapsed_lv5=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node3,:error) - @collapsed_lv5=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node2,:error) - @collapsed_lv5=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node1,:error) - @collapsed_lv5=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node0,:error) - node0 - end - collapsed_level=@collapsed_lv5 - node,ocn_sp=node5,"h#{ocnh}" - elsif ln==6 \ - or ln=~@md.lv6 - @lev_occurences[:l3] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh6+=1 - node6="6:#{ocnh6};#{ocn}" - else - ocn_flag=false - node6="6:0;0" - end - parent=if node5 - document_structure_check_info(node6,node5) - @collapsed_lv6=@collapsed_lv5+1 - node5 - elsif node4 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) + document_structure_check_info(node3,node1,:error) + @collapsed_lv3=@collapsed_lv1+1 + node1 + else + document_structure_check_info(node3,node0,:error) + warning_incorrect_parent_level_or_level(dob.obj) + node0 + end + collapsed_level=@collapsed_lv3 + node,ocn_sp=node3,"h#{ocnh}" + elsif ln==4 \ + or ln=~@md.lv4 + @lev_occurences[:l1] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh4+=1 + node4="4:#{ocnh4};#{ocn}" + else + ocn_flag=false + node4="4:0;0" + end + parent=if node3 + document_structure_check_info(node4,node3) + @collapsed_lv4=@collapsed_lv3+1 + node3 + elsif node2 + document_structure_check_info(node4,node2) + @collapsed_lv4=@collapsed_lv2+1 + node2 + elsif node1 + document_structure_check_info(node4,node1) + @collapsed_lv4=@collapsed_lv1+1 + node1 + elsif node0 + document_structure_check_info(node4,node0) + @collapsed_lv4=@collapsed_lv0+1 + node0 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node4,node0,:error) + node0 + end + collapsed_level=@collapsed_lv4 + node,ocn_sp=node4,"h#{ocnh}" + elsif ln==5 \ + or ln=~@md.lv5 + @lev_occurences[:l2] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh5+=1 + node5="5:#{ocnh5};#{ocn}" + else + ocn_flag=false + node5="5:0;0" + end + parent=if node4 + document_structure_check_info(node5,node4) + @collapsed_lv5=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node3,:error) + @collapsed_lv5=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node2,:error) + @collapsed_lv5=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node1,:error) + @collapsed_lv5=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node0,:error) + node0 + end + collapsed_level=@collapsed_lv5 + node,ocn_sp=node5,"h#{ocnh}" + elsif ln==6 \ + or ln=~@md.lv6 + @lev_occurences[:l3] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh6+=1 + node6="6:#{ocnh6};#{ocn}" + else + ocn_flag=false + node6="6:0;0" + end + parent=if node5 + document_structure_check_info(node6,node5) + @collapsed_lv6=@collapsed_lv5+1 + node5 + elsif node4 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) either parent should be level #5 (2~) or this level should be #5 (2~) rather ##{dob.ln} (#{dob.lv}~)" - document_structure_check_info(node6,node4,:error) - @collapsed_lv6=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node3,:error) - @collapsed_lv6=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node2,:error) - @collapsed_lv6=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node1,:error) - @collapsed_lv6=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node0,:error) - node0 - end - collapsed_level=@collapsed_lv6 - node,ocn_sp=node6,"h#{ocnh}" - elsif ln==7 \ - or ln=~@md.lv7 - @lev_occurences[:l4] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh7+=1 - node7="7:#{ocnh7};#{ocn}" - else - ocn_flag=false - node7="7:0;0" - end - parent=if node6 - document_structure_check_info(node7,node6) - @collapsed_lv7=@collapsed_lv6+1 - node5 - elsif node5 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level #5 (2~) & this level ##{dob.ln} (#{dob.lv}~) + document_structure_check_info(node6,node4,:error) + @collapsed_lv6=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node3,:error) + @collapsed_lv6=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node2,:error) + @collapsed_lv6=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node1,:error) + @collapsed_lv6=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node0,:error) + node0 + end + collapsed_level=@collapsed_lv6 + node,ocn_sp=node6,"h#{ocnh}" + elsif ln==7 \ + or ln=~@md.lv7 + @lev_occurences[:l4] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh7+=1 + node7="7:#{ocnh7};#{ocn}" + else + ocn_flag=false + node7="7:0;0" + end + parent=if node6 + document_structure_check_info(node7,node6) + @collapsed_lv7=@collapsed_lv6+1 + node5 + elsif node5 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level #5 (2~) & this level ##{dob.ln} (#{dob.lv}~) either parent should be level #6 (3~) or this level should be #6 (3~) rather ##{dob.ln} (#{dob.lv}~)" - document_structure_check_info(node7,node5,:error) - @collapsed_lv6=@collapsed_lv5+1 - node5 - elsif node4 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) + document_structure_check_info(node7,node5,:error) + @collapsed_lv6=@collapsed_lv5+1 + node5 + elsif node4 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) either parent should be level 6~ or this level should be #6 (3~) rather ##{dob.ln} (#{dob.lv}~)" - document_structure_check_info(node7,node4,:error) - @collapsed_lv6=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node3,:error) - @collapsed_lv6=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node2,:error) - @collapsed_lv6=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node1,:error) - @collapsed_lv6=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node0,:error) - node0 + document_structure_check_info(node7,node4,:error) + @collapsed_lv6=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node3,:error) + @collapsed_lv6=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node2,:error) + @collapsed_lv6=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node1,:error) + @collapsed_lv6=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node0,:error) + node0 + end + collapsed_level=@collapsed_lv7 + node,ocn_sp=node7,"h#{ocnh}" end - collapsed_level=@collapsed_lv7 - node,ocn_sp=node7,"h#{ocnh}" - end - else - unless @lev_occurences[:l1] > 0 - STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} + else + unless @lev_occurences[:l1] > 0 + STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - puts dob.obj #.gsub(/^(.{1,80})/,'"\1"') - exit - end - unless @ln >= 4 - lev=case @ln - when 0 then 'A' - when 1 then 'B' - when 2 then 'C' - when 3 then 'D' - when 4 then '1' - when 5 then '2' - when 6 then '3' - when 7 then '4' - when 8 then '5' - when 9 then '6' + puts dob.obj #.gsub(/^(.{1,80})/,'"\1"') + exit end - STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ + unless @ln >= 4 + lev=case @ln + when 0 then 'A' + when 1 then 'B' + when 2 then 'C' + when 3 then 'D' + when 4 then '1' + when 5 then '2' + when 6 then '3' + when 7 then '4' + when 8 then '5' + when 9 then '6' + end + STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - puts dob.obj.gsub(/^(.{1,80})/,'"\1"') - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - break - else exit + puts dob.obj.gsub(/^(.{1,80})/,'"\1"') + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + break + else exit + end + end + if not dob.obj =~/~#|-#/ + ocn_flag=true + else + ocn_flag=false + end + ocno+=1 + if dob.is==:table + ocnt+=1 + ocn_sp,parent="t#{ocnt}",node + elsif dob.is==:code + ocnc+=1 + ocn_sp,parent="c#{ocnc}",node + elsif dob.is==:group \ + || dob.is==:box \ + || dob.is==:block \ + || dob.is==:alt \ + || dob.is==:verse + ocng+=1 #group, poem + ocn_sp,parent="g#{ocng}",node + elsif dob.is==:image #check + ocni+=1 + ocn_sp,parent="i#{ocni}",node + else ocnp+=1 #paragraph + ocn_sp,parent="p#{ocnp}",node end - end - if not dob.obj =~/~#|-#/ - ocn_flag=true - else - ocn_flag=false - end - ocno+=1 - if dob.is==:table - ocnt+=1 - ocn_sp,parent="t#{ocnt}",node - elsif dob.is==:code - ocnc+=1 - ocn_sp,parent="c#{ocnc}",node - elsif dob.is==:group \ - || dob.is==:box \ - || dob.is==:block \ - || dob.is==:alt \ - || dob.is==:verse - ocng+=1 #group, poem - ocn_sp,parent="g#{ocng}",node - elsif dob.is==:image #check - ocni+=1 - ocn_sp,parent="i#{ocni}",node - else ocnp+=1 #paragraph - ocn_sp,parent="p#{ocnp}",node end end if dob.is==:heading @@ -1760,24 +1766,28 @@ SKIPPED processing file: end @o_array << dob end - unless @lev_occurences[:a] == 1 - STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} + if @process == :complete \ + or (@fnx == @md.opt.fns \ + && @md.opt.fns =~/.sst$/) + unless @lev_occurences[:a] == 1 + STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} There must be one level A~ (no more and no less) SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end end - end - unless @lev_occurences[:l1] > 0 - STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} + unless @lev_occurences[:l1] > 0 + STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} There must be at least one level 1~ (and as many as required) SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end end end @o_array diff --git a/lib/sisu/current/ao_numbering.rb b/lib/sisu/current/ao_numbering.rb index 9df1479a..31986a86 100644 --- a/lib/sisu/current/ao_numbering.rb +++ b/lib/sisu/current/ao_numbering.rb @@ -58,8 +58,8 @@ module SiSU_AO_Numbering class Numbering attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment @@segments_count=0 - def initialize(md,data) - @md,@data=md,data + def initialize(md,data,fnx,process) + @md,@data,@fnx,@process=md,data,fnx,process @obj=@type=@ocn=@lv=@name=@index=@comment=nil @chosen_seg_names=[] end @@ -104,7 +104,9 @@ module SiSU_AO_Numbering data=ocn(data.compact) #watch data=xml(data.compact) data=minor_numbering(data.compact) - data,tags_map,ocn_html_seg_map=name_para_seg_filename(data) + if @process==:complete + data,tags_map,ocn_html_seg_map=name_para_seg_filename(data) + end data=set_heading_top(data) unless @md.set_heading_top [data,tags_map,ocn_html_seg_map] ensure @@ -277,7 +279,7 @@ module SiSU_AO_Numbering @tuned_file=@tuned_file.flatten end def ocn(data) #and auto segment numbering increment - @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data).ocn + @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data,@fnx,@process).ocn @tuned_file end def xml(data) diff --git a/lib/sisu/current/dp.rb b/lib/sisu/current/dp.rb index c57112de..9c8ab9fc 100644 --- a/lib/sisu/current/dp.rb +++ b/lib/sisu/current/dp.rb @@ -540,7 +540,9 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Copyright missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) '' end l,n=Db[:col_info_note],'rights.copyright.text' @@ -612,7 +614,9 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -670,7 +674,9 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -1421,11 +1427,13 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], '*WARN* endnote number mismatch', - "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" + "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} " \ + + "(difference = #{@en[:mismatch]})" ).warn unless @opt.act[:quiet][:set]==:on footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') footnote_conversion_errors << - "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" + "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} " \ + + "(difference = #{@en[:mismatch]})\n" end if not @title \ or not defined? @title.main \ @@ -1438,7 +1446,9 @@ module SiSU_Param @opt.act[:color_state][:set], 'WARNING: Document Title missing', 'please provide @title:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) end end if @author !~/[\S]/ @@ -1450,7 +1460,9 @@ module SiSU_Param @opt.act[:color_state][:set], 'WARNING: Document Author missing', 'please provide @creator: :author:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) end end @struct={} diff --git a/lib/sisu/current/git.rb b/lib/sisu/current/git.rb index f9723186..0ec3520b 100644 --- a/lib/sisu/current/git.rb +++ b/lib/sisu/current/git.rb @@ -59,8 +59,8 @@ module SiSU_Git require_relative 'se' # se.rb require_relative 'ao' # ao.rb class Source - def initialize(opt) - @opt=opt + def initialize(opt,process=:complete) + @opt,@process=opt,process @env=SiSU_Env::InfoEnv.new @md=SiSU_Param::Parameters.new(@opt).get @file=SiSU_Env::FileOp.new(@md) @@ -88,7 +88,7 @@ module SiSU_Git video: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:video], conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf] } - SiSU_AO::Source.new(@opt).read # -m + SiSU_AO::Source.new(@opt,nil,@process).read # -m end def create_file_structure_git make_dir_fnb diff --git a/lib/sisu/current/po4a.rb b/lib/sisu/current/po4a.rb index 7d602f7c..097fb2c6 100644 --- a/lib/sisu/current/po4a.rb +++ b/lib/sisu/current/po4a.rb @@ -63,12 +63,15 @@ module SiSU_Po4a require_relative 'po4a_set' # po4a_set.rb include SiSU_Param class Source - @@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn=nil,nil,nil,nil,nil,nil + @@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn= + nil,nil,nil,nil,nil,nil def initialize(opt,fn=nil) @opt,@fn=opt,fn #unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/ # puts "#{@opt.fns} not a processed file type" #end + file_arr=SiSU_Info_Env::InfoEnv.new.source_file_processing_array(@opt.fns) + SiSU_Param::Parameters::Instructions.new(file_arr,@opt).extract r=Px[:lng_lst_rgx].gsub(/\|en\|/,'|') @lang_regx=%r{(?:#{r})} if opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ @@ -94,36 +97,44 @@ module SiSU_Po4a end md=SiSU_Param::Parameters.new(@opt).get src[:files].each do |fn| - SiSU_AO::Source.new(@opt,fn).read # -m env=SiSU_Env::InfoEnv.new(@opt.fns) + file=SiSU_Env::FileOp.new(md) m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss @fnn,@fnb,@fnt=fn[m,1],fn[m,2],fn[m,3] unless @opt.act[:quiet][:set]==:on - path=env.path.output_tell tool=(@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{path}/#{md.fnb}/#{md.fn[:plain]}" + ? "#{env.program.text_editor} #{file.output_path.pot.dir}/" : @opt.fns (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Pot po4a',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Pot po4a',tool).green_title_hi + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Pot po4a', + tool + ).green_hi_blue + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Pot po4a', + tool + ).green_title_hi if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], @opt.fns, - "#{path}/#{md.fnb}/#{md.fn[:plain]}" + file.output_path.pot.dir ).flow end end if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ or @opt.f_pth[:lng] !=@opt.lng_base opt_lang_trn_fn=fn - @ao_array_lang_translation=SiSU_AO::Source.new(@opt,opt_lang_trn_fn).get # ao file drawn here + @ao_array_lang_translation= + SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here opt_lang_src_fn=if fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/ fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2') #check i else fn @@ -138,14 +149,16 @@ module SiSU_Po4a else nil end if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}") - @ao_array_lang_src=SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn).get # ao file drawn here + @ao_array_lang_src= + SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn,:po4a).get # ao file drawn here else puts "no identified source document" exit end Dir.chdir(transdir) if transdir else - @ao_array_lang_src=SiSU_AO::Source.new(@opt,fn).get # ao file drawn here + @ao_array_lang_src= + SiSU_AO::Source.new(@opt,fn,:po4a).get # ao file drawn here @ao_array_lang_translation=nil end wrap_width=if defined? md.make.plaintext_wrap \ @@ -156,7 +169,13 @@ module SiSU_Po4a env.plaintext_wrap else 78 end - SiSU_Po4a::Source::Scroll.new(fn,@ao_array_lang_src,@ao_array_lang_translation,@@md_src,@@md_trn,wrap_width).songsheet + SiSU_Po4a::Source::Scroll.new( + fn, + @ao_array_lang_src, + @ao_array_lang_translation, + @@md_src,@@md_trn, + wrap_width + ).songsheet end rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do @@ -170,14 +189,24 @@ module SiSU_Po4a include SiSU_Po4aUtils @@endnotes={ para: [], end: [] } def initialize(fn,data_src,data_trn,md_src,md_trn,wrap_width) - @fn,@data_src,@data_trn,@md_src,@md_trn,@wrap_width=fn,data_src,data_trn,md_src,md_trn,wrap_width + @fn,@data_src,@data_trn,@md_src,@md_trn,@wrap_width= + fn, data_src, data_trn, md_src, md_trn, wrap_width @md=(md_trn.nil?) \ ? md_src : md_trn @tab="\t" @@endnotes_=(@md.opt.selections.str =~/--endnote/) ? true : false # --footnote - @br=(@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n" # --unix - @pot={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } + @pot={ + body: [], + open: [], + close: [], + head: [], + metadata: [], + tail: [] + } + end + def br + (@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n" # --unix end def songsheet ############## BUG @fn changes value @@ -185,7 +214,7 @@ module SiSU_Po4a pot=pot_markup(@data_src,@data_trn) publish(fn,pot) end - def extract_endnotes(dob='') #% Used for extraction of endnotes from paragraphs + def extract_endnotes(dob='') #% used for extraction of endnotes from paragraphs notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d]+\s+.+?)#{Mx[:en_a_c]}/) ##notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/) #notes_b=dob.obj.scan(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/) @@ -193,8 +222,8 @@ module SiSU_Po4a notes_a.flatten.each do |n| #high cost to deal with
appropriately within plaintext, consider n=n.dup.to_s n=n.gsub(/^([\d]+)\s+/,'^~\1 '). - #gsub(/^([\d*+]+)\s+/,'^~\1 '). - gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/, + ' \\\\\\ ') @n << n end notes_a=@n.flatten @@ -212,14 +241,21 @@ module SiSU_Po4a mark="^~ " instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# footnotes, the preferred sisu markup for a footnote is~{this is a footnote}~ however, for translation a footnote reference marker in the text~^ with a set of notes following the paragraph starting on a newline with "^~ this is a footnote", is easier to deal with, if possible these should be converted back to~{inline notes}~} + instruct=%{\n# footnotes, the preferred sisu markup for a footnote is~{this is a footnote}~ } \ + + %{however, for translation a footnote reference marker in the text~^ } \ + + %{with a set of notes following the paragraph starting on a newline with "^~ this is a footnote", } \ + + %{is easier to deal with, if possible these should be converted back to~{inline notes}~} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" - orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : orig_notes[i].to_s + orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) \ + ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) + : orig_notes[i].to_s trans=if trn_notes.is_a?(Array) \ and trn_notes.length==orig_notes.length - (trn_notes[i].to_s =~/^\^~[\d*+]+/) ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : trn_notes[i].to_s + (trn_notes[i].to_s =~/^\^~[\d*+]+/) \ + ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) + : trn_notes[i].to_s else '' end util=pot_structure(desc,orig,trans) @@ -238,7 +274,7 @@ GSUB @@endnotes[:para] << wrap @@endnotes[:end] << '' << wrap end - @@endnotes[:para].each {|e| @pot[:body] << e << @br} + @@endnotes[:para].each {|e| @pot[:body] << e << br} @@endnotes[:para]=[] @@endnotes end @@ -297,10 +333,10 @@ GSUB meta_src.metadata_tags.classify.topic_register, meta_src.metadata_tags.classify.loc, meta_src.metadata_tags.classify.dewey, - meta_src.metadata_tags.notes.relation, - meta_src.metadata_tags.notes.type, - meta_src.metadata_tags.identifier.oclc, - meta_src.metadata_tags.identifier.isbn, + #meta_src.metadata_tags.notes.relation, + #meta_src.metadata_tags.notes.type, + #meta_src.metadata_tags.identifier.oclc, + #meta_src.metadata_tags.identifier.isbn, 'msgstr ""', ] w << [ @@ -340,7 +376,7 @@ GSUB z += %{"#{x}"\n} if x =~/^\s+:\S+?: / end end - @pot[:metadata] << z << @br + @pot[:metadata] << z << br #puts z unless z.empty? end end @@ -425,20 +461,20 @@ GSUB meta_src.metadata_tags.classify.topic_register, meta_src.metadata_tags.classify.loc, meta_src.metadata_tags.classify.dewey, - meta_src.metadata_tags.notes.relation, - meta_src.metadata_tags.notes.type, - meta_src.metadata_tags.identifier.oclc, - meta_src.metadata_tags.identifier.isbn, + #meta_src.metadata_tags.notes.relation, + #meta_src.metadata_tags.notes.type, + #meta_src.metadata_tags.identifier.oclc, + #meta_src.metadata_tags.identifier.isbn, 'msgstr ""', meta_trn.metadata_tags.classify.head, meta_trn.metadata_tags.classify.subject, meta_trn.metadata_tags.classify.topic_register, meta_trn.metadata_tags.classify.loc, meta_trn.metadata_tags.classify.dewey, - meta_trn.metadata_tags.notes.relation, - meta_trn.metadata_tags.notes.type, - meta_trn.metadata_tags.identifier.oclc, - meta_trn.metadata_tags.identifier.isbn, + #meta_trn.metadata_tags.notes.relation, + #meta_trn.metadata_tags.notes.type, + #meta_trn.metadata_tags.identifier.oclc, + #meta_trn.metadata_tags.identifier.isbn, ] w << [ "#. #{@po4a_identify_type} - metadata: date", @@ -493,14 +529,22 @@ GSUB z += %{"#{x}"\n} if x =~/^\s+:\S+?: / end end - @pot[:metadata] << z << @br + @pot[:metadata] << z << br #puts z unless z.empty? end end def pot_structure(desc,orig,trans,indent=0,hang=0) - SiSU_Po4aUtils::Wrap.new(@md,orig,trans,desc,@wrap_width,indent,hang) + SiSU_Po4aUtils::Wrap.new( + @md, + orig, + trans, + desc, + @wrap_width, + indent, + hang + ) end - def pot_structure_heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document lv=n=n3=nil lv=dob_src.ln n=lv - 1 @@ -511,7 +555,9 @@ GSUB d="#{dob_src.is.to_s} (level #{dob_src.lv})" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for headings is marker at the start of the line/object, indicating the heading level, and if provided an associated name tag, this heading is "#{mark}"} + instruct=%{\n# markup for headings is marker at the start of the line/object, } \ + + %{indicating the heading level, and if provided an associated name tag, } \ + + %{this heading is "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -519,18 +565,18 @@ GSUB trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}" util=pot_structure(desc,orig,trans) wrapped=util.line_wrap - @pot[:body] << wrapped << @br # main text, contents, body KEEP + @pot[:body] << wrapped << br # main text, contents, body KEEP if @@endnotes[:para] \ and notes_s.length > 0 \ and not @@endnotes_ - @pot[:body] << @br + @pot[:body] << br wrap_endnotes(notes_s,notes_t) elsif @@endnotes[:para] \ and @@endnotes_ - @pot[:body] << @br*2 + @pot[:body] << br*2 end end - def pot_structure_para(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_para(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document util=nil wrapped=if dob_src.indent =~/[1-9]/ \ and dob_src.indent == dob_src.hang @@ -540,7 +586,8 @@ GSUB d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented bullet text is at the start of the line/object, an underscore followed by the indent level and an asterisk "#{mark}"} + instruct=%{\n# markup for indented bullet text is at the start of the line/object, } \ + + %{an underscore followed by the indent level and an asterisk "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -549,7 +596,8 @@ GSUB d="#{dob_src.is.to_s}: indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by the indent level "#{mark}"} + instruct=%{\n# markup for indented text is at the start of the line/object, } \ + + %{an underscore followed by the indent level "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -564,7 +612,11 @@ GSUB d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented text with a first line indented to a different level from the rest of the paragraph, is at the start of the line/object, an underscore and the first indent level a second underscore and the indent level for the rest of the paragraph, "#{mark1}"} + instruct=%{\n# markup for indented text with a first line indented } \ + + %{to a different level from the rest of the paragraph, } \ + + %{is at the start of the line/object, } \ + + %{an underscore and the first indent level } \ + + %{a second underscore and the indent level for the rest of the paragraph, "#{mark1}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -578,7 +630,8 @@ GSUB d="#{dob_src.is.to_s}: bullet" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by an asterisk "#{mark}"} + instruct=%{\n# markup for indented text is at the start of the line/object, } \ + + %{an underscore followed by an asterisk "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -599,23 +652,24 @@ GSUB util=pot_structure(desc,orig,trans) end wrapped=util.line_wrap - @pot[:body] << wrapped << @br # main text, contents, body KEEP + @pot[:body] << wrapped << br # main text, contents, body KEEP if @@endnotes[:para] \ and notes_s.length > 0 \ and not @@endnotes_ - @pot[:body] << @br + @pot[:body] << br wrap_endnotes(notes_s,notes_t) elsif @@endnotes[:para] \ and @@endnotes_ - @pot[:body] << @br*2 + @pot[:body] << br*2 end end - def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="block{\\n\\n...\\n\\n}block" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# block text is a text block with an opening and closing marker, the content of which may be wrapped" + instruct=%{\n# block text is a text block with an opening and closing marker, } \ + + %{the content of which may be wrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -623,14 +677,15 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="group{\\n\\n...\\n\\n}group" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# group text is a text block with an opening and closing marker, the content of which may be wrapped" + instruct=%{\n# group text is a text block with an opening and closing marker, } \ + + %{the content of which may be wrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -638,14 +693,17 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# verse are part of the text block described as a poem, the first verse is preceeded by an opening marker, and the last verse by a closing marker, the content of which should remain unwrapped" + instruct=%{\n# verse are part of the text block described as a poem, } \ + + %{the first verse is preceeded by an opening marker, } \ + + %{and the last verse by a closing marker, } \ + + %{the content of which should remain unwrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -653,14 +711,15 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="code{\\n\\n...\\n\\n}code" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# codeblocks are a text block with an opening and closing marker, the content of which should remain unwrapped" + instruct=%{\n# codeblocks are a text block with an opening and closing marker, } \ + + %{the content of which should remain unwrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -668,14 +727,15 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="table{\\n\\n...\\n\\n}table" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# tables are a text block with an opening and closing marker, the content of which should remain unwrapped" + instruct=%{\n# tables are a text block with an opening and closing marker, } \ + + %{the content of which should remain unwrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -685,27 +745,27 @@ GSUB trans=trans.gsub(/#{Mx[:tc_c]}/,"\n") util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_idx(dob_src='',dob_trn='') #% Used to extract the structure of a document - mark="={ ... }" - instruct=s_mark='' - if @md.opt.act[:maintenance][:set]==:on - instruct="\n# the book index should be attached unwrapped to the preceding text block (there should be a new line, but no empty line)" - s_mark="\n# " + %{"\\n#{mark}\\n\\n"} - end - d='book-idx' - desc="#{d}#{s_mark}#{instruct}" - orig='={' + dob_src.idx + '}' - trans=if defined? dob_trn.idx \ - and not dob_trn.idx.nil? \ - and not dob_trn.idx.empty? - '={' + dob_trn.idx + '}' - else '' - end - util=pot_structure(desc,orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + def pot_structure_idx(dob_src='',dob_trn='') #% used for book index but broken as original markup lost, already abstracted, fix + #mark="={ ... }" + #instruct=s_mark='' + #if @md.opt.act[:maintenance][:set]==:on + # instruct="\n# the book index should be attached unwrapped to the preceding text block (there should be a new line, but no empty line)" + # s_mark="\n# " + %{"\\n#{mark}\\n\\n"} + #end + #d='book-idx' + #desc="#{d}#{s_mark}#{instruct}" + #orig='={' + dob_src.idx + '}' + #trans=if defined? dob_trn.idx \ + #and not dob_trn.idx.nil? \ + #and not dob_trn.idx.empty? + # '={' + dob_trn.idx + '}' + #else '' + #end + #util=pot_structure(desc,orig,trans) + #unwrapped=util.no_line_wrap_block + #@pot[:body] << unwrapped << br end def pot_markup(data_src,data_trn) #@endnotes,@copen,@pot_contents_close=Array.new(3){[]} @@ -734,24 +794,35 @@ GSUB s+=1;t+=1 next end - if (data_src[s].is == :comment or data_trn[t].is == :comment) \ + if ((data_src[s].is == :comment) \ + || (data_trn[t].is == :comment)) \ and (data_src[s].is != data_trn[t].is) if data_src[s].is == :comment - puts "src (comment):\n\t" + data_src[s].obj if @md.opt.act[:maintenance][:set]==:on + if @md.opt.act[:maintenance][:set]==:on + puts "src (comment):\n\t" \ + + data_src[s].obj + end s+=1 #next if data_src[s].is == :comment elsif data_trn[t].is == :comment - puts "trans (comment):\n\t" + data_trn[t].obj if @md.opt.act[:maintenance][:set]==:on + if @md.opt.act[:maintenance][:set]==:on + puts "trans (comment):\n\t" \ + + data_trn[t].obj + end t+=1 #next if data_trn[t].is == :comment end end - if (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ + if ((defined? data_src[s].ocn) \ + && (data_src[s].ocn.is_a?(Fixnum))) \ + and ((defined? data_trn[t].ocn) \ + && (data_trn[t].ocn.is_a?(Fixnum))) \ and (data_src[s].ocn == data_trn[t].ocn) @m_s,@m_t=s,t - elsif (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ + elsif ((defined? data_src[s].ocn) \ + && (data_src[s].ocn.is_a?(Fixnum))) \ + and ((defined? data_trn[t].ocn) \ + && (data_trn[t].ocn.is_a?(Fixnum))) \ and (data_src[s].ocn != data_trn[t].ocn) p '--- OCN ---' p 'mis-match' @@ -766,7 +837,8 @@ GSUB p data_trn[@m_t].ocn p data_trn[@m_t].obj exit - elsif (defined? data_src[s].ocn and defined? data_trn[t].ocn \ + elsif (((defined? data_src[s].ocn) \ + && (defined? data_trn[t].ocn)) \ and data_src[s].ocn.class != data_trn[t].ocn.class) p '--- OCN class ---' p 'mis-match' @@ -813,13 +885,20 @@ GSUB @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum) end case dob_src.is - when :heading then pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) - when :para then pot_structure_para(dob_src,notes_s,dob_trn,notes_t) - when :group then pot_structure_group(dob_src,notes_s,dob_trn,notes_t) - when :block then pot_structure_block(dob_src,notes_s,dob_trn,notes_t) - when :verse then pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) - when :code then pot_structure_code(dob_src,notes_s,dob_trn,notes_t) - when :table then pot_structure_table(dob_src,notes_s,dob_trn,notes_t) + when :heading + pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) + when :para + pot_structure_para(dob_src,notes_s,dob_trn,notes_t) + when :group + pot_structure_group(dob_src,notes_s,dob_trn,notes_t) + when :block + pot_structure_block(dob_src,notes_s,dob_trn,notes_t) + when :verse + pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) + when :code + pot_structure_code(dob_src,notes_s,dob_trn,notes_t) + when :table + pot_structure_table(dob_src,notes_s,dob_trn,notes_t) end if defined? dob_src.idx \ and not dob_src.idx.nil? \ @@ -835,9 +914,10 @@ GSUB end #[dob_src,dob_trn] end - def markup(dob) # Used for major markup instructions + def markup(dob) # used for major markup instructions SiSU_Env::InfoEnv.new(@md.fns) - dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + dob.obj=dob.obj. + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}"). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}"). @@ -857,19 +937,26 @@ GSUB "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") notes='' unless dob.is==:code - dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). + dob.obj=dob.obj. + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). - gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). - gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1 [link: <\2>]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/, + '\1 [link: local image]'). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1') notes=extract_endnotes(dob) #% ### footnotes current state - extracted - dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up + dob.obj=dob.obj. + gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up #% ### footnotes current state - keep inline #dob.obj.gsub!(/#{Mx[:en_a_o]}[\d]+\s+(.+?)#{Mx[:en_a_c]}/,'~{ \1 }~') # inline endnote with marker marked up - gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,'~[ \1 ]~'). # inline endnote with marker marked up - gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,'~{\1 \2 }~'). # inline endnote with marker marked up - gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,'~[\1 \2 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/, + '~[ \1 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '~{\1 \2 }~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/, + '~[\1 \2 ]~'). # inline endnote with marker marked up gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). @@ -898,9 +985,12 @@ GSUB gsub(/(.+?)<\/a>/m,'\1'). gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links gsub(/ |#{Mx[:nbsp]}/,' '). # decide on - gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") - gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") - gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/, + ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/, + ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/, + '[image: "\1"]') [dob,notes] end def publish(fn,pot) @@ -910,18 +1000,18 @@ GSUB content << pot[:metadata] content << pot[:body] content << @@endnotes[:end] if @@endnotes_ - Output.new(fn,content,@md).po4a + Output.new(fn,content,@md,@process).po4a @@endnotes={ para: [], end: [] } end end class Output - FileUtils::cp(@file.place_file.po.dir, @file.output_path.po_git.dir) #unless FileTest.file?(@file.place_file.po_git.dir) + FileUtils::cp( + @file.place_file.po.dir, + @file.output_path.po_git.dir + ) #unless FileTest.file?(@file.place_file.po_git.dir) end git.read end diff --git a/lib/sisu/current/se_info_env.rb b/lib/sisu/current/se_info_env.rb index 85dd043c..276f14e6 100644 --- a/lib/sisu/current/se_info_env.rb +++ b/lib/sisu/current/se_info_env.rb @@ -1060,7 +1060,7 @@ WOK @sys.home end def sisurc_path - GetInit.new.sisu_yaml.rc_path + SiSU_Get_Init::GetInit.new.sisu_yaml.rc_path end def pwd @sys.pwd diff --git a/lib/sisu/develop/ao.rb b/lib/sisu/develop/ao.rb index 0373149e..1ca49338 100644 --- a/lib/sisu/develop/ao.rb +++ b/lib/sisu/develop/ao.rb @@ -83,8 +83,8 @@ module SiSU_AO end end class Source 0 - STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} + else + unless @lev_occurences[:l1] > 0 + STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - puts dob.obj #.gsub(/^(.{1,80})/,'"\1"') - exit - end - unless @ln >= 4 - lev=case @ln - when 0 then 'A' - when 1 then 'B' - when 2 then 'C' - when 3 then 'D' - when 4 then '1' - when 5 then '2' - when 6 then '3' - when 7 then '4' - when 8 then '5' - when 9 then '6' + puts dob.obj #.gsub(/^(.{1,80})/,'"\1"') + exit end - STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ + unless @ln >= 4 + lev=case @ln + when 0 then 'A' + when 1 then 'B' + when 2 then 'C' + when 3 then 'D' + when 4 then '1' + when 5 then '2' + when 6 then '3' + when 7 then '4' + when 8 then '5' + when 9 then '6' + end + STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - puts dob.obj.gsub(/^(.{1,80})/,'"\1"') - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - break - else exit + puts dob.obj.gsub(/^(.{1,80})/,'"\1"') + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + break + else exit + end + end + if not dob.obj =~/~#|-#/ + ocn_flag=true + else + ocn_flag=false + end + ocno+=1 + if dob.is==:table + ocnt+=1 + ocn_sp,parent="t#{ocnt}",node + elsif dob.is==:code + ocnc+=1 + ocn_sp,parent="c#{ocnc}",node + elsif dob.is==:group \ + || dob.is==:box \ + || dob.is==:block \ + || dob.is==:alt \ + || dob.is==:verse + ocng+=1 #group, poem + ocn_sp,parent="g#{ocng}",node + elsif dob.is==:image #check + ocni+=1 + ocn_sp,parent="i#{ocni}",node + else ocnp+=1 #paragraph + ocn_sp,parent="p#{ocnp}",node end - end - if not dob.obj =~/~#|-#/ - ocn_flag=true - else - ocn_flag=false - end - ocno+=1 - if dob.is==:table - ocnt+=1 - ocn_sp,parent="t#{ocnt}",node - elsif dob.is==:code - ocnc+=1 - ocn_sp,parent="c#{ocnc}",node - elsif dob.is==:group \ - || dob.is==:box \ - || dob.is==:block \ - || dob.is==:alt \ - || dob.is==:verse - ocng+=1 #group, poem - ocn_sp,parent="g#{ocng}",node - elsif dob.is==:image #check - ocni+=1 - ocn_sp,parent="i#{ocni}",node - else ocnp+=1 #paragraph - ocn_sp,parent="p#{ocnp}",node end end if dob.is==:heading @@ -1736,24 +1742,28 @@ SKIPPED processing file: end @o_array << dob end - unless @lev_occurences[:a] == 1 - STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} + if @process == :complete \ + or (@fnx == @md.opt.fns \ + && @md.opt.fns =~/.sst$/) + unless @lev_occurences[:a] == 1 + STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} There must be one level A~ (no more and no less) SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end end - end - unless @lev_occurences[:l1] > 0 - STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} + unless @lev_occurences[:l1] > 0 + STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} There must be at least one level 1~ (and as many as required) SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end end end @o_array diff --git a/lib/sisu/develop/ao_numbering.rb b/lib/sisu/develop/ao_numbering.rb index cc6b595a..6e9f2853 100644 --- a/lib/sisu/develop/ao_numbering.rb +++ b/lib/sisu/develop/ao_numbering.rb @@ -58,8 +58,8 @@ module SiSU_AO_Numbering class Numbering attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment @@segments_count=0 - def initialize(md,data) - @md,@data=md,data + def initialize(md,data,fnx,process) + @md,@data,@fnx,@process=md,data,fnx,process @obj=@type=@ocn=@lv=@name=@index=@comment=nil @chosen_seg_names=[] end @@ -104,7 +104,9 @@ module SiSU_AO_Numbering data=ocn(data.compact) #watch data=xml(data.compact) data=minor_numbering(data.compact) - data,tags_map,ocn_html_seg_map=name_para_seg_filename(data) + if @process==:complete + data,tags_map,ocn_html_seg_map=name_para_seg_filename(data) + end data=set_heading_top(data) unless @md.set_heading_top [data,tags_map,ocn_html_seg_map] ensure @@ -277,7 +279,7 @@ module SiSU_AO_Numbering @tuned_file=@tuned_file.flatten end def ocn(data) #and auto segment numbering increment - @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data).ocn + @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data,@fnx,@process).ocn @tuned_file end def xml(data) diff --git a/lib/sisu/develop/dp.rb b/lib/sisu/develop/dp.rb index 68f8c610..76fe87ff 100644 --- a/lib/sisu/develop/dp.rb +++ b/lib/sisu/develop/dp.rb @@ -150,7 +150,8 @@ module SiSU_Param @@md.opt=@opt @@md rescue - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('has an existing option been selected?') + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + mark('has an existing option been selected?') exit end end @@ -545,7 +546,9 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Copyright missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) '' end l,n=Db[:col_info_note],'rights.copyright.text' @@ -617,7 +620,9 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -675,7 +680,9 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) else l,n=Db[:col_info_note],'rights.all' validate_length(s,l,n) @@ -1426,11 +1433,13 @@ module SiSU_Param SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], '*WARN* endnote number mismatch', - "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})" + "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} " \ + + "(difference = #{@en[:mismatch]})" ).warn unless @opt.act[:quiet][:set]==:on footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') footnote_conversion_errors << - "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} (difference = #{@en[:mismatch]})\n" + "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} " \ + + "(difference = #{@en[:mismatch]})\n" end if not @title \ or not defined? @title.main \ @@ -1443,7 +1452,9 @@ module SiSU_Param @opt.act[:color_state][:set], 'WARNING: Document Title missing', 'please provide @title:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) end end if @author !~/[\S]/ @@ -1455,7 +1466,9 @@ module SiSU_Param @opt.act[:color_state][:set], 'WARNING: Document Author missing', 'please provide @creator: :author:' - ).warn unless @opt.act[:quiet][:set]==:on + ).warn if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) end end @struct={} diff --git a/lib/sisu/develop/git.rb b/lib/sisu/develop/git.rb index fb2b1631..4d20742a 100644 --- a/lib/sisu/develop/git.rb +++ b/lib/sisu/develop/git.rb @@ -59,8 +59,8 @@ module SiSU_Git require_relative 'se' # se.rb require_relative 'ao' # ao.rb class Source - def initialize(opt) - @opt=opt + def initialize(opt,process=:complete) + @opt,@process=opt,process @env=SiSU_Env::InfoEnv.new @md=SiSU_Param::Parameters.new(@opt).get @file=SiSU_Env::FileOp.new(@md) @@ -88,7 +88,7 @@ module SiSU_Git video: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:video], conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf] } - SiSU_AO::Source.new(@opt).read # -m + SiSU_AO::Source.new(@opt,nil,@process).read # -m end def create_file_structure_git make_dir_fnb @@ -132,14 +132,22 @@ module SiSU_Git (found =~/bin\/git\b/) ? true : false end def make_dir_fnb - FileUtils::mkdir_p(@git_path[:fnb]) unless FileTest.directory?(@git_path[:fnb]) - FileUtils::mkdir_p(@git_path[:doc]) unless FileTest.directory?(@git_path[:doc]) - FileUtils::mkdir_p(@git_path[:po]) unless FileTest.directory?(@git_path[:po]) - FileUtils::mkdir_p(@git_path[:pot]) unless FileTest.directory?(@git_path[:pot]) - FileUtils::mkdir_p(@git_path[:conf]) unless FileTest.directory?(@git_path[:conf]) - FileUtils::mkdir_p(@git_path[:image]) unless FileTest.directory?(@git_path[:image]) - #FileUtils::mkdir_p(@git_path[:audio]) unless FileTest.directory?(@git_path[:audio]) - #FileUtils::mkdir_p(@git_path[:video]) unless FileTest.directory?(@git_path[:video]) + FileUtils::mkdir_p(@git_path[:fnb]) \ + unless FileTest.directory?(@git_path[:fnb]) + FileUtils::mkdir_p(@git_path[:doc]) \ + unless FileTest.directory?(@git_path[:doc]) + FileUtils::mkdir_p(@git_path[:po]) \ + unless FileTest.directory?(@git_path[:po]) + FileUtils::mkdir_p(@git_path[:pot]) \ + unless FileTest.directory?(@git_path[:pot]) + FileUtils::mkdir_p(@git_path[:conf]) \ + unless FileTest.directory?(@git_path[:conf]) + FileUtils::mkdir_p(@git_path[:image]) \ + unless FileTest.directory?(@git_path[:image]) + #FileUtils::mkdir_p(@git_path[:audio]) \ + # unless FileTest.directory?(@git_path[:audio]) + #FileUtils::mkdir_p(@git_path[:video]) \ + # unless FileTest.directory?(@git_path[:video]) end def git_init unless FileTest.directory?("#{@git_path[:fnb]}/.git") @@ -168,13 +176,23 @@ module SiSU_Git p __LINE__ end def copy_src_head - if @opt.f_pth[:lng] - FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}",@git_path[:doc]) + if @opt.f_pth[:lng] \ + and File.exist?("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}") + FileUtils::cp_r( + "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}", + @git_path[:doc] + ) elsif @opt.fns =~/\.ssm\.sst/ ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm') - FileUtils::cp_r("#{@env.path.pwd}/#{ssm}",@git_path[:doc]) - else - FileUtils::cp_r("#{@env.path.pwd}/#{@opt.fns}",@git_path[:doc]) + FileUtils::cp_r( + "#{@env.path.pwd}/#{ssm}", + @git_path[:doc] + ) + elsif File.exist?("#{@env.path.pwd}/#{@opt.fns}") + FileUtils::cp_r( + "#{@env.path.pwd}/#{@opt.fns}", + @git_path[:doc] + ) end end def copy_related_sst_ssi @@ -183,14 +201,21 @@ module SiSU_Git file_array=IO.readlines(@opt.fns,'') file_array.each do |f| if f =~@rgx_doc_import - doc_import = doc_import + f.scan(@rgx_doc_import).uniq.flatten + doc_import = doc_import \ + + f.scan(@rgx_doc_import).uniq.flatten end end doc_import.each do |f| if @opt.f_pth[:lng] - FileUtils::cp_r("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}",@git_path[:doc]) + FileUtils::cp_r( + "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}", + @git_path[:doc] + ) else - FileUtils::cp_r("#{@env.path.pwd}/#{f}",@git_path[:doc]) + FileUtils::cp_r( + "#{@env.path.pwd}/#{f}", + @git_path[:doc] + ) end end end @@ -200,10 +225,19 @@ module SiSU_Git and not @opt.act[:ao][:set]==:on ##SiSU_Assemble::Composite.new(@opt).read #SiSU_AO::Source.new(@opt).read # -m - "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" + @env.processing_path.composite_file \ + + '/' \ + + @opt.fnb \ + + '.ssm.sst' elsif composite_src - "#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst" - else "#{@env.path.pwd}/#{@opt.fns}" + @env.processing_path.composite_file \ + + '/' \ + + @opt.fnb \ + + '.ssm.sst' + else + @env.path.pwd + + '/' \ + + @opt.fns end end def read_composite diff --git a/lib/sisu/develop/po4a.rb b/lib/sisu/develop/po4a.rb index 6c2f9df5..e0b31ce0 100644 --- a/lib/sisu/develop/po4a.rb +++ b/lib/sisu/develop/po4a.rb @@ -63,12 +63,15 @@ module SiSU_Po4a require_relative 'po4a_set' # po4a_set.rb include SiSU_Param class Source - @@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn=nil,nil,nil,nil,nil,nil + @@opt_src,@@opt_trn,@@opt_src_,@@opt_trn_,@@md_src,@@md_trn= + nil,nil,nil,nil,nil,nil def initialize(opt,fn=nil) @opt,@fn=opt,fn #unless @opt.fns =~/(.+?\.(?:-|ssm\.)?sst)$/ # puts "#{@opt.fns} not a processed file type" #end + file_arr=SiSU_Info_Env::InfoEnv.new.source_file_processing_array(@opt.fns) + SiSU_Param::Parameters::Instructions.new(file_arr,@opt).extract r=Px[:lng_lst_rgx].gsub(/\|en\|/,'|') @lang_regx=%r{(?:#{r})} if opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ @@ -94,36 +97,44 @@ module SiSU_Po4a end md=SiSU_Param::Parameters.new(@opt).get src[:files].each do |fn| - SiSU_AO::Source.new(@opt,fn).read # -m env=SiSU_Env::InfoEnv.new(@opt.fns) + file=SiSU_Env::FileOp.new(md) m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss @fnn,@fnb,@fnt=fn[m,1],fn[m,2],fn[m,3] unless @opt.act[:quiet][:set]==:on - path=env.path.output_tell tool=(@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? "#{env.program.text_editor} #{path}/#{md.fnb}/#{md.fn[:plain]}" + ? "#{env.program.text_editor} #{file.output_path.pot.dir}/" : @opt.fns (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Pot po4a',tool).green_hi_blue - : SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],'Pot po4a',tool).green_title_hi + ? SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Pot po4a', + tool + ).green_hi_blue + : SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Pot po4a', + tool + ).green_title_hi if (@opt.act[:verbose][:set]==:on \ || @opt.act[:verbose_plus][:set]==:on \ || @opt.act[:maintenance][:set]==:on) SiSU_Screen::Ansi.new( @opt.act[:color_state][:set], @opt.fns, - "#{path}/#{md.fnb}/#{md.fn[:plain]}" + file.output_path.pot.dir ).flow end end if @opt.fns =~/\S+?~#{@lang_regx}\.ss[mti]/ \ or @opt.f_pth[:lng] !=@opt.lng_base opt_lang_trn_fn=fn - @ao_array_lang_translation=SiSU_AO::Source.new(@opt,opt_lang_trn_fn).get # ao file drawn here + @ao_array_lang_translation= + SiSU_AO::Source.new(@opt,opt_lang_trn_fn,:po4a).get # ao file drawn here opt_lang_src_fn=if fn =~/\S+?~\S{2}(?:_\S{2})?\.ss[mti]/ fn.gsub(/(\S+?)~\S{2}(?:_\S{2})?(\.ss[mti])/,'\1\2') #check i else fn @@ -138,14 +149,16 @@ module SiSU_Po4a else nil end if FileTest.file?("#{srcdir}/#{opt_lang_src_fn}") - @ao_array_lang_src=SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn).get # ao file drawn here + @ao_array_lang_src= + SiSU_AO::Source.new(@@opt_src,opt_lang_src_fn,:po4a).get # ao file drawn here else puts "no identified source document" exit end Dir.chdir(transdir) if transdir else - @ao_array_lang_src=SiSU_AO::Source.new(@opt,fn).get # ao file drawn here + @ao_array_lang_src= + SiSU_AO::Source.new(@opt,fn,:po4a).get # ao file drawn here @ao_array_lang_translation=nil end wrap_width=if defined? md.make.plaintext_wrap \ @@ -156,7 +169,13 @@ module SiSU_Po4a env.plaintext_wrap else 78 end - SiSU_Po4a::Source::Scroll.new(fn,@ao_array_lang_src,@ao_array_lang_translation,@@md_src,@@md_trn,wrap_width).songsheet + SiSU_Po4a::Source::Scroll.new( + fn, + @ao_array_lang_src, + @ao_array_lang_translation, + @@md_src,@@md_trn, + wrap_width + ).songsheet end rescue SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do @@ -170,14 +189,24 @@ module SiSU_Po4a include SiSU_Po4aUtils @@endnotes={ para: [], end: [] } def initialize(fn,data_src,data_trn,md_src,md_trn,wrap_width) - @fn,@data_src,@data_trn,@md_src,@md_trn,@wrap_width=fn,data_src,data_trn,md_src,md_trn,wrap_width + @fn,@data_src,@data_trn,@md_src,@md_trn,@wrap_width= + fn, data_src, data_trn, md_src, md_trn, wrap_width @md=(md_trn.nil?) \ ? md_src : md_trn @tab="\t" @@endnotes_=(@md.opt.selections.str =~/--endnote/) ? true : false # --footnote - @br=(@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n" # --unix - @pot={ body: [], open: [], close: [], head: [], metadata: [], tail: [] } + @pot={ + body: [], + open: [], + close: [], + head: [], + metadata: [], + tail: [] + } + end + def br + (@md.opt.selections.str =~/--dos/) ? "\r\n" : "\n" # --unix end def songsheet ############## BUG @fn changes value @@ -185,7 +214,7 @@ module SiSU_Po4a pot=pot_markup(@data_src,@data_trn) publish(fn,pot) end - def extract_endnotes(dob='') #% Used for extraction of endnotes from paragraphs + def extract_endnotes(dob='') #% used for extraction of endnotes from paragraphs notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d]+\s+.+?)#{Mx[:en_a_c]}/) ##notes_a=dob.obj.scan(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/) #notes_b=dob.obj.scan(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/) @@ -193,8 +222,8 @@ module SiSU_Po4a notes_a.flatten.each do |n| #high cost to deal with
appropriately within plaintext, consider n=n.dup.to_s n=n.gsub(/^([\d]+)\s+/,'^~\1 '). - #gsub(/^([\d*+]+)\s+/,'^~\1 '). - gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') + gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/, + ' \\\\\\ ') @n << n end notes_a=@n.flatten @@ -212,14 +241,21 @@ module SiSU_Po4a mark="^~ " instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# footnotes, the preferred sisu markup for a footnote is~{this is a footnote}~ however, for translation a footnote reference marker in the text~^ with a set of notes following the paragraph starting on a newline with "^~ this is a footnote", is easier to deal with, if possible these should be converted back to~{inline notes}~} + instruct=%{\n# footnotes, the preferred sisu markup for a footnote is~{this is a footnote}~ } \ + + %{however, for translation a footnote reference marker in the text~^ } \ + + %{with a set of notes following the paragraph starting on a newline with "^~ this is a footnote", } \ + + %{is easier to deal with, if possible these should be converted back to~{inline notes}~} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" - orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : orig_notes[i].to_s + orig=(orig_notes[i].to_s =~/^\^~[\d*+]+/) \ + ? (orig_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) + : orig_notes[i].to_s trans=if trn_notes.is_a?(Array) \ and trn_notes.length==orig_notes.length - (trn_notes[i].to_s =~/^\^~[\d*+]+/) ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) : trn_notes[i].to_s + (trn_notes[i].to_s =~/^\^~[\d*+]+/) \ + ? (trn_notes[i].to_s.gsub(/^\^~[\d*+]+/,'^~')) + : trn_notes[i].to_s else '' end util=pot_structure(desc,orig,trans) @@ -238,7 +274,7 @@ GSUB @@endnotes[:para] << wrap @@endnotes[:end] << '' << wrap end - @@endnotes[:para].each {|e| @pot[:body] << e << @br} + @@endnotes[:para].each {|e| @pot[:body] << e << br} @@endnotes[:para]=[] @@endnotes end @@ -297,10 +333,10 @@ GSUB meta_src.metadata_tags.classify.topic_register, meta_src.metadata_tags.classify.loc, meta_src.metadata_tags.classify.dewey, - meta_src.metadata_tags.notes.relation, - meta_src.metadata_tags.notes.type, - meta_src.metadata_tags.identifier.oclc, - meta_src.metadata_tags.identifier.isbn, + #meta_src.metadata_tags.notes.relation, + #meta_src.metadata_tags.notes.type, + #meta_src.metadata_tags.identifier.oclc, + #meta_src.metadata_tags.identifier.isbn, 'msgstr ""', ] w << [ @@ -340,7 +376,7 @@ GSUB z += %{"#{x}"\n} if x =~/^\s+:\S+?: / end end - @pot[:metadata] << z << @br + @pot[:metadata] << z << br #puts z unless z.empty? end end @@ -425,20 +461,20 @@ GSUB meta_src.metadata_tags.classify.topic_register, meta_src.metadata_tags.classify.loc, meta_src.metadata_tags.classify.dewey, - meta_src.metadata_tags.notes.relation, - meta_src.metadata_tags.notes.type, - meta_src.metadata_tags.identifier.oclc, - meta_src.metadata_tags.identifier.isbn, + #meta_src.metadata_tags.notes.relation, + #meta_src.metadata_tags.notes.type, + #meta_src.metadata_tags.identifier.oclc, + #meta_src.metadata_tags.identifier.isbn, 'msgstr ""', meta_trn.metadata_tags.classify.head, meta_trn.metadata_tags.classify.subject, meta_trn.metadata_tags.classify.topic_register, meta_trn.metadata_tags.classify.loc, meta_trn.metadata_tags.classify.dewey, - meta_trn.metadata_tags.notes.relation, - meta_trn.metadata_tags.notes.type, - meta_trn.metadata_tags.identifier.oclc, - meta_trn.metadata_tags.identifier.isbn, + #meta_trn.metadata_tags.notes.relation, + #meta_trn.metadata_tags.notes.type, + #meta_trn.metadata_tags.identifier.oclc, + #meta_trn.metadata_tags.identifier.isbn, ] w << [ "#. #{@po4a_identify_type} - metadata: date", @@ -493,14 +529,22 @@ GSUB z += %{"#{x}"\n} if x =~/^\s+:\S+?: / end end - @pot[:metadata] << z << @br + @pot[:metadata] << z << br #puts z unless z.empty? end end def pot_structure(desc,orig,trans,indent=0,hang=0) - SiSU_Po4aUtils::Wrap.new(@md,orig,trans,desc,@wrap_width,indent,hang) + SiSU_Po4aUtils::Wrap.new( + @md, + orig, + trans, + desc, + @wrap_width, + indent, + hang + ) end - def pot_structure_heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_heading(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document lv=n=n3=nil lv=dob_src.ln n=lv - 1 @@ -511,7 +555,9 @@ GSUB d="#{dob_src.is.to_s} (level #{dob_src.lv})" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for headings is marker at the start of the line/object, indicating the heading level, and if provided an associated name tag, this heading is "#{mark}"} + instruct=%{\n# markup for headings is marker at the start of the line/object, } \ + + %{indicating the heading level, and if provided an associated name tag, } \ + + %{this heading is "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -519,18 +565,18 @@ GSUB trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}" util=pot_structure(desc,orig,trans) wrapped=util.line_wrap - @pot[:body] << wrapped << @br # main text, contents, body KEEP + @pot[:body] << wrapped << br # main text, contents, body KEEP if @@endnotes[:para] \ and notes_s.length > 0 \ and not @@endnotes_ - @pot[:body] << @br + @pot[:body] << br wrap_endnotes(notes_s,notes_t) elsif @@endnotes[:para] \ and @@endnotes_ - @pot[:body] << @br*2 + @pot[:body] << br*2 end end - def pot_structure_para(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_para(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document util=nil wrapped=if dob_src.indent =~/[1-9]/ \ and dob_src.indent == dob_src.hang @@ -540,7 +586,8 @@ GSUB d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented bullet text is at the start of the line/object, an underscore followed by the indent level and an asterisk "#{mark}"} + instruct=%{\n# markup for indented bullet text is at the start of the line/object, } \ + + %{an underscore followed by the indent level and an asterisk "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -549,7 +596,8 @@ GSUB d="#{dob_src.is.to_s}: indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by the indent level "#{mark}"} + instruct=%{\n# markup for indented text is at the start of the line/object, } \ + + %{an underscore followed by the indent level "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -564,7 +612,11 @@ GSUB d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented text with a first line indented to a different level from the rest of the paragraph, is at the start of the line/object, an underscore and the first indent level a second underscore and the indent level for the rest of the paragraph, "#{mark1}"} + instruct=%{\n# markup for indented text with a first line indented } \ + + %{to a different level from the rest of the paragraph, } \ + + %{is at the start of the line/object, } \ + + %{an underscore and the first indent level } \ + + %{a second underscore and the indent level for the rest of the paragraph, "#{mark1}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -578,7 +630,8 @@ GSUB d="#{dob_src.is.to_s}: bullet" instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by an asterisk "#{mark}"} + instruct=%{\n# markup for indented text is at the start of the line/object, } \ + + %{an underscore followed by an asterisk "#{mark}"} s_mark="\n# " + %{"\\n\\n#{mark}...\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -599,23 +652,24 @@ GSUB util=pot_structure(desc,orig,trans) end wrapped=util.line_wrap - @pot[:body] << wrapped << @br # main text, contents, body KEEP + @pot[:body] << wrapped << br # main text, contents, body KEEP if @@endnotes[:para] \ and notes_s.length > 0 \ and not @@endnotes_ - @pot[:body] << @br + @pot[:body] << br wrap_endnotes(notes_s,notes_t) elsif @@endnotes[:para] \ and @@endnotes_ - @pot[:body] << @br*2 + @pot[:body] << br*2 end end - def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="block{\\n\\n...\\n\\n}block" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# block text is a text block with an opening and closing marker, the content of which may be wrapped" + instruct=%{\n# block text is a text block with an opening and closing marker, } \ + + %{the content of which may be wrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -623,14 +677,15 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="group{\\n\\n...\\n\\n}group" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# group text is a text block with an opening and closing marker, the content of which may be wrapped" + instruct=%{\n# group text is a text block with an opening and closing marker, } \ + + %{the content of which may be wrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -638,14 +693,17 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# verse are part of the text block described as a poem, the first verse is preceeded by an opening marker, and the last verse by a closing marker, the content of which should remain unwrapped" + instruct=%{\n# verse are part of the text block described as a poem, } \ + + %{the first verse is preceeded by an opening marker, } \ + + %{and the last verse by a closing marker, } \ + + %{the content of which should remain unwrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -653,14 +711,15 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="code{\\n\\n...\\n\\n}code" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# codeblocks are a text block with an opening and closing marker, the content of which should remain unwrapped" + instruct=%{\n# codeblocks are a text block with an opening and closing marker, } \ + + %{the content of which should remain unwrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -668,14 +727,15 @@ GSUB trans=(dob_trn=='') ? '' : dob_trn.obj util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document + def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% used to extract the structure of a document mark="table{\\n\\n...\\n\\n}table" d=dob_src.is.to_s instruct=s_mark='' if @md.opt.act[:maintenance][:set]==:on - instruct="\n# tables are a text block with an opening and closing marker, the content of which should remain unwrapped" + instruct=%{\n# tables are a text block with an opening and closing marker, } \ + + %{the content of which should remain unwrapped} s_mark="\n# " + %{"\\n\\n#{mark}\\n\\n"} end desc="#{d}#{s_mark}#{instruct}" @@ -685,27 +745,27 @@ GSUB trans=trans.gsub(/#{Mx[:tc_c]}/,"\n") util=pot_structure(desc,orig,trans) unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + @pot[:body] << unwrapped << br end - def pot_structure_idx(dob_src='',dob_trn='') #% Used to extract the structure of a document - mark="={ ... }" - instruct=s_mark='' - if @md.opt.act[:maintenance][:set]==:on - instruct="\n# the book index should be attached unwrapped to the preceding text block (there should be a new line, but no empty line)" - s_mark="\n# " + %{"\\n#{mark}\\n\\n"} - end - d='book-idx' - desc="#{d}#{s_mark}#{instruct}" - orig='={' + dob_src.idx + '}' - trans=if defined? dob_trn.idx \ - and not dob_trn.idx.nil? \ - and not dob_trn.idx.empty? - '={' + dob_trn.idx + '}' - else '' - end - util=pot_structure(desc,orig,trans) - unwrapped=util.no_line_wrap_block - @pot[:body] << unwrapped << @br + def pot_structure_idx(dob_src='',dob_trn='') #% used for book index but broken as original markup lost, already abstracted, fix + #mark="={ ... }" + #instruct=s_mark='' + #if @md.opt.act[:maintenance][:set]==:on + # instruct="\n# the book index should be attached unwrapped to the preceding text block (there should be a new line, but no empty line)" + # s_mark="\n# " + %{"\\n#{mark}\\n\\n"} + #end + #d='book-idx' + #desc="#{d}#{s_mark}#{instruct}" + #orig='={' + dob_src.idx + '}' + #trans=if defined? dob_trn.idx \ + #and not dob_trn.idx.nil? \ + #and not dob_trn.idx.empty? + # '={' + dob_trn.idx + '}' + #else '' + #end + #util=pot_structure(desc,orig,trans) + #unwrapped=util.no_line_wrap_block + #@pot[:body] << unwrapped << br end def pot_markup(data_src,data_trn) #@endnotes,@copen,@pot_contents_close=Array.new(3){[]} @@ -734,24 +794,35 @@ GSUB s+=1;t+=1 next end - if (data_src[s].is == :comment or data_trn[t].is == :comment) \ + if ((data_src[s].is == :comment) \ + || (data_trn[t].is == :comment)) \ and (data_src[s].is != data_trn[t].is) if data_src[s].is == :comment - puts "src (comment):\n\t" + data_src[s].obj if @md.opt.act[:maintenance][:set]==:on + if @md.opt.act[:maintenance][:set]==:on + puts "src (comment):\n\t" \ + + data_src[s].obj + end s+=1 #next if data_src[s].is == :comment elsif data_trn[t].is == :comment - puts "trans (comment):\n\t" + data_trn[t].obj if @md.opt.act[:maintenance][:set]==:on + if @md.opt.act[:maintenance][:set]==:on + puts "trans (comment):\n\t" \ + + data_trn[t].obj + end t+=1 #next if data_trn[t].is == :comment end end - if (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ + if ((defined? data_src[s].ocn) \ + && (data_src[s].ocn.is_a?(Fixnum))) \ + and ((defined? data_trn[t].ocn) \ + && (data_trn[t].ocn.is_a?(Fixnum))) \ and (data_src[s].ocn == data_trn[t].ocn) @m_s,@m_t=s,t - elsif (defined? data_src[s].ocn and data_src[s].ocn.is_a?(Fixnum)) \ - and (defined? data_trn[t].ocn and data_trn[t].ocn.is_a?(Fixnum)) \ + elsif ((defined? data_src[s].ocn) \ + && (data_src[s].ocn.is_a?(Fixnum))) \ + and ((defined? data_trn[t].ocn) \ + && (data_trn[t].ocn.is_a?(Fixnum))) \ and (data_src[s].ocn != data_trn[t].ocn) p '--- OCN ---' p 'mis-match' @@ -766,7 +837,8 @@ GSUB p data_trn[@m_t].ocn p data_trn[@m_t].obj exit - elsif (defined? data_src[s].ocn and defined? data_trn[t].ocn \ + elsif (((defined? data_src[s].ocn) \ + && (defined? data_trn[t].ocn)) \ and data_src[s].ocn.class != data_trn[t].ocn.class) p '--- OCN class ---' p 'mis-match' @@ -813,13 +885,20 @@ GSUB @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum) end case dob_src.is - when :heading then pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) - when :para then pot_structure_para(dob_src,notes_s,dob_trn,notes_t) - when :group then pot_structure_group(dob_src,notes_s,dob_trn,notes_t) - when :block then pot_structure_block(dob_src,notes_s,dob_trn,notes_t) - when :verse then pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) - when :code then pot_structure_code(dob_src,notes_s,dob_trn,notes_t) - when :table then pot_structure_table(dob_src,notes_s,dob_trn,notes_t) + when :heading + pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) + when :para + pot_structure_para(dob_src,notes_s,dob_trn,notes_t) + when :group + pot_structure_group(dob_src,notes_s,dob_trn,notes_t) + when :block + pot_structure_block(dob_src,notes_s,dob_trn,notes_t) + when :verse + pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) + when :code + pot_structure_code(dob_src,notes_s,dob_trn,notes_t) + when :table + pot_structure_table(dob_src,notes_s,dob_trn,notes_t) end if defined? dob_src.idx \ and not dob_src.idx.nil? \ @@ -835,9 +914,10 @@ GSUB end #[dob_src,dob_trn] end - def markup(dob) # Used for major markup instructions + def markup(dob) # used for major markup instructions SiSU_Env::InfoEnv.new(@md.fns) - dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, + dob.obj=dob.obj. + gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/, "#{Px[:po_bold_o]}\\1#{Px[:po_bold_c]}"). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/, "#{Px[:po_italics_o]}\\1#{Px[:po_italics_c]}"). @@ -857,19 +937,26 @@ GSUB "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") notes='' unless dob.is==:code - dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). + dob.obj=dob.obj. + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). - gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). - gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/,'\1 [link: local image]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, + '\1 [link: <\2>]'). + gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}image/, + '\1 [link: local image]'). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1') notes=extract_endnotes(dob) #% ### footnotes current state - extracted - dob.obj=dob.obj.gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up + dob.obj=dob.obj. + gsub(/#{Mx[:en_a_o]}([\d]+)\s+(?:.+?)#{Mx[:en_a_c]}/,'~^'). # endnote marker marked up #% ### footnotes current state - keep inline #dob.obj.gsub!(/#{Mx[:en_a_o]}[\d]+\s+(.+?)#{Mx[:en_a_c]}/,'~{ \1 }~') # inline endnote with marker marked up - gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/,'~[ \1 ]~'). # inline endnote with marker marked up - gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/,'~{\1 \2 }~'). # inline endnote with marker marked up - gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/,'~[\1 \2 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_b_o]}[\d]+\s+(.+?)#{Mx[:en_b_c]}/, + '~[ \1 ]~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/, + '~{\1 \2 }~'). # inline endnote with marker marked up + gsub(/#{Mx[:en_b_o]}([*+]+)\s+(.+?)#{Mx[:en_b_c]}/, + '~[\1 \2 ]~'). # inline endnote with marker marked up gsub(/#{Mx[:gl_o]}(?:#lt|#060)#{Mx[:gl_c]}/,'<'). gsub(/#{Mx[:gl_o]}(?:#gt|#062)#{Mx[:gl_c]}/,'>'). gsub(/#{Mx[:gl_o]}#(?:038|amp)#{Mx[:gl_c]}/,'&'). @@ -898,9 +985,12 @@ GSUB gsub(/
(.+?)<\/a>/m,'\1'). gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). # remove name links gsub(/ |#{Mx[:nbsp]}/,' '). # decide on - gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") - gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/,' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") - gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/,'[image: "\1"]') + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/, + ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif)) .+?#{Mx[:lnk_c]}image/, + ' [ \1 ]'). #"[ #{dir.url.images_local}\/\\1 ]") + gsub(/(?:^|[^_\\])\{\s*\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"\s*\}\S+/, + '[image: "\1"]') [dob,notes] end def publish(fn,pot) @@ -910,18 +1000,18 @@ GSUB content << pot[:metadata] content << pot[:body] content << @@endnotes[:end] if @@endnotes_ - Output.new(fn,content,@md).po4a + Output.new(fn,content,@md,@process).po4a @@endnotes={ para: [], end: [] } end end class Output - FileUtils::cp(@file.place_file.po.dir, @file.output_path.po_git.dir) #unless FileTest.file?(@file.place_file.po_git.dir) + FileUtils::cp( + @file.place_file.po.dir, + @file.output_path.po_git.dir + ) #unless FileTest.file?(@file.place_file.po_git.dir) end git.read end diff --git a/lib/sisu/develop/se_info_env.rb b/lib/sisu/develop/se_info_env.rb index 43509f0e..97e81e77 100644 --- a/lib/sisu/develop/se_info_env.rb +++ b/lib/sisu/develop/se_info_env.rb @@ -1066,7 +1066,7 @@ WOK @sys.home end def sisurc_path - GetInit.new.sisu_yaml.rc_path + SiSU_Get_Init::GetInit.new.sisu_yaml.rc_path end def pwd @sys.pwd -- cgit v1.2.3