diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v5/ao_doc_str.rb | 39 | ||||
-rw-r--r-- | lib/sisu/v5/ao_expand_insertions.rb | 56 | ||||
-rw-r--r-- | lib/sisu/v5/ao_numbering.rb | 247 | ||||
-rw-r--r-- | lib/sisu/v5/hub.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v5/se_envcall.rb | 13 | ||||
-rw-r--r-- | lib/sisu/v5/se_processing.rb | 20 | ||||
-rw-r--r-- | lib/sisu/v6/ao_doc_str.rb | 39 | ||||
-rw-r--r-- | lib/sisu/v6/ao_expand_insertions.rb | 56 | ||||
-rw-r--r-- | lib/sisu/v6/ao_numbering.rb | 247 | ||||
-rw-r--r-- | lib/sisu/v6/hub.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v6/se_envcall.rb | 13 | ||||
-rw-r--r-- | lib/sisu/v6/se_processing.rb | 20 |
12 files changed, 542 insertions, 212 deletions
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb index 49c9bdf1..f7884b31 100644 --- a/lib/sisu/v5/ao_doc_str.rb +++ b/lib/sisu/v5/ao_doc_str.rb @@ -1307,7 +1307,8 @@ module SiSU_AO_DocumentStructureExtract node_parent_ln=/^([0-7])/.match(node_parent)[1].to_i STDERR.puts %{current level: #{structure_info.lv[node_ln]} (possible parent levels: #{structure_info.possible_parents(structure_info.lv[node_ln])}) parent level: #{structure_info.lv[node_parent_ln]} (possible child levels: #{structure_info.possible_children(structure_info.lv[node_parent_ln])}) -SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} if @md.opt.act[:no_stop][:set]==:on $process_document = :skip else exit @@ -1328,7 +1329,8 @@ has incorrect level and/or parent level STDERR.puts %{required header missing: @title: -SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}" } if @md.opt.act[:no_stop][:set]==:on $process_document = :skip @@ -1341,7 +1343,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" @creator: :author: anonymous? -SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}" } if @md.opt.act[:no_stop][:set]==:on $process_document = :skip @@ -1578,9 +1581,9 @@ or this level should be level :B~ rather than #{dob.lv}} node5 elsif node4 warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level 4~ & this level #{dob.lv} -either parent should be level 5~ -or this level should be 5~ rather #{dob.lv}" + 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 @@ -1623,17 +1626,17 @@ or this level should be 5~ rather #{dob.lv}" node5 elsif node5 warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level 5~ & this level #{dob.lv} -either parent should be level 6~ -or this level should be 6~ rather #{dob.lv}" + 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~ & this level #{dob.lv} + puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) either parent should be level 6~ -or this level should be 6~ rather #{dob.lv}" +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 @@ -1663,7 +1666,10 @@ or this level should be 6~ rather #{dob.lv}" 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 @@ -1679,7 +1685,8 @@ or this level should be 6~ rather #{dob.lv}" 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}"} +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 @@ -1762,7 +1769,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} 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}"} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} if @md.opt.act[:no_stop][:set]==:on $process_document = :skip else exit @@ -1771,7 +1779,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} 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}"} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} if @md.opt.act[:no_stop][:set]==:on $process_document = :skip else exit diff --git a/lib/sisu/v5/ao_expand_insertions.rb b/lib/sisu/v5/ao_expand_insertions.rb index 483e9fdb..4f4f7ae5 100644 --- a/lib/sisu/v5/ao_expand_insertions.rb +++ b/lib/sisu/v5/ao_expand_insertions.rb @@ -81,52 +81,61 @@ module SiSU_AO_Insertions end file_type_names={} file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /y/ + file_type_names[:gen] <<= if cmd_list =~ /\b--manifest\b/ "~^ { document manifest }#{lnk[:manifest]}" end - file_type_names[:gen] <<= if cmd_list =~ /h/ + file_type_names[:gen] <<= if cmd_list =~ /\b--html\b/ [ " { html, segmented text }#{lnk[:html_toc]}", " { html, scroll, document in one }#{lnk[:html_doc]}", ] end - file_type_names[:gen] <<= if cmd_list =~ /e/ + file_type_names[:gen] <<= if cmd_list =~ /\b--epub\b/ [" { epub }#{lnk[:epub]}"] end - file_type_names[:gen] <<= if cmd_list =~ /p/ + file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ + or cmd_list =~ /--pdf-landscape/ [ " { pdf, landscape }#{lnk[:pdf_landscape]}", + ] + end + file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ + or cmd_list =~ /--pdf-portrait/ + [ " { pdf, portrait }#{lnk[:pdf_portrait]}", ] end - file_type_names[:gen] <<= if cmd_list =~ /o/ + file_type_names[:gen] <<= if cmd_list =~ /\b(?:--odt|--odf)\b/ " { odf:odt, open document text }#{lnk[:odt]}" end - file_type_names[:gen] <<= if cmd_list =~ /b/ + file_type_names[:gen] <<= if cmd_list =~ /\b--xhtml\b/ " { xhtml scroll }#{lnk[:xhtml]}" end - file_type_names[:gen] <<= if cmd_list =~ /x/ + file_type_names[:gen] <<= if cmd_list =~ /\b--docbook\b/ + " { docbook }#{lnk[:docbook]}" #CHECK + end + file_type_names[:gen] <<= if cmd_list =~ /\b--xml-sax\b/ " { xml, sax }#{lnk[:xml_sax]}" end - file_type_names[:gen] <<= if cmd_list =~ /X/ + file_type_names[:gen] <<= if cmd_list =~ /\b--xml-dom\b/ " { xml, dom }#{lnk[:xml_dom]}" end - file_type_names[:gen] <<= if cmd_list =~ /a/ + file_type_names[:gen] <<= if cmd_list =~ /\b(?:--txt|--text|--plaintext)\b/ " { plain text utf-8 }#{lnk[:txt]}" end - file_type_names[:gen] <<= if cmd_list =~ /g/ - 'wiki.txt' - end - file_type_names[:gen] <<= if cmd_list =~ /w/ + #file_type_names[:gen] <<= if cmd_list =~ /g/ + # 'wiki.txt' + #end + file_type_names[:gen] <<= if cmd_list =~ /\b--concordance\b/ " { concordance }#{lnk[:html_concordance]}" end - file_type_names[:gen] <<= if cmd_list =~ /N/ + file_type_names[:gen] <<= if cmd_list =~ /\b--digest\b/ " { dcc, document content certificate (digests) }#{lnk[:digest]}" end - file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ + file_type_names[:src] <<= if source and cmd_shortcut =~ /\b--source\b/ " { markup source text }#{lnk[:source]}" end - file_type_names[:src] <<= if cmd_shortcut =~ /S/ + file_type_names[:src] <<= if cmd_shortcut =~ /\b--sisupod\b/ " { markup source (zipped) pod }#{lnk[:sisupod]}" end file_type_names[:gen]=file_type_names[:gen].flatten @@ -180,6 +189,10 @@ module SiSU_AO_Insertions fn=@md.file.base_filename.xhtml(fnh) path_and_file(fn,'xhtml') end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn,'docbook') + end def xml_sax fn=@md.file.base_filename.xml_sax(fnh) path_and_file(fn,'xml_sax') @@ -254,6 +267,10 @@ module SiSU_AO_Insertions fn=@md.file.base_filename.xhtml(fnh) path_and_file(fn,'xhtml') end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn,'docbook') + end def xml_sax fn=@md.file.base_filename.xml_sax(fnh) path_and_file(fn,'xml_sax') @@ -329,6 +346,10 @@ module SiSU_AO_Insertions fn=@md.file.base_filename.xhtml(fnh) path_and_file(fn) end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn) + end def xml_sax fn=@md.file.base_filename.xml_sax(fnh) path_and_file(fn) @@ -418,6 +439,7 @@ module SiSU_AO_Insertions pdf_portrait: by_language(m_linked_doc,m_linked_doc_lang).pdf_landscape, odt: by_language(m_linked_doc,m_linked_doc_lang).odt, xhtml: by_language(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_language(m_linked_doc,m_linked_doc_lang).docbook, xml_sax: by_language(m_linked_doc,m_linked_doc_lang).xml_sax, xml_dom: by_language(m_linked_doc,m_linked_doc_lang).xml_dom, txt: by_language(m_linked_doc,m_linked_doc_lang).txt, @@ -436,6 +458,7 @@ module SiSU_AO_Insertions pdf_portrait: by_filetype(m_linked_doc,m_linked_doc_lang).pdf_landscape, odt: by_filetype(m_linked_doc,m_linked_doc_lang).odt, xhtml: by_filetype(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_filetype(m_linked_doc,m_linked_doc_lang).docbook, xml_sax: by_filetype(m_linked_doc,m_linked_doc_lang).xml_sax, xml_dom: by_filetype(m_linked_doc,m_linked_doc_lang).xml_dom, txt: by_filetype(m_linked_doc,m_linked_doc_lang).txt, @@ -454,6 +477,7 @@ module SiSU_AO_Insertions pdf_portrait: by_filename(m_linked_doc,m_linked_doc_lang).pdf_landscape, odt: by_filename(m_linked_doc,m_linked_doc_lang).odt, xhtml: by_filename(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_filename(m_linked_doc,m_linked_doc_lang).docbook, xml_sax: by_filename(m_linked_doc,m_linked_doc_lang).xml_sax, xml_dom: by_filename(m_linked_doc,m_linked_doc_lang).xml_dom, txt: by_filename(m_linked_doc,m_linked_doc_lang).txt, diff --git a/lib/sisu/v5/ao_numbering.rb b/lib/sisu/v5/ao_numbering.rb index f9257e6a..6954a286 100644 --- a/lib/sisu/v5/ao_numbering.rb +++ b/lib/sisu/v5/ao_numbering.rb @@ -69,6 +69,27 @@ module SiSU_AO_Numbering @obj=@type=@ocn=@lv=@name=@index=@comment=nil @chosen_seg_names=[] end + def chosen_seg_names(chosen,chosen_seg_name,dob,md,type) + @chosen_seg_names=if chosen.compact.uniq.length \ + == chosen.compact.length + chosen + else + if md.opt.act[:maintenance][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). + mark( + "duplicated auto segment name: #{type} #{chosen}\n" \ + + "#{chosen}\n" \ + + " manually name level 1 segments '1~given_name'\n" \ + + 'filename: ' + md.fns + "\n" \ + + 'heading text: "' + dob.obj + '"' + "\n" \ + + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' + ) + end + chosen=chosen[0..-2] + chosen_seg_name=auto_numbering_exceptions(chosen,md,dob) + chosen << chosen_seg_name + end + end def number_of_segments? if @@segments_count==0 @data.each do |dob| @@ -314,6 +335,78 @@ module SiSU_AO_Numbering possible_seg_name.to_s end end + def auto_numbering_exceptions(chosen_seg_names_,md,dob) + number_make=case dob.lv.to_i + when 1 + @num_exc={ + t1: @num_exc[:t1] += 1, + t2: 0, + t3: 0, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + when 2 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2] += 1, + t3: 0, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + when 3 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2], + t3: @num_exc[:t3] += 1, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + '_' \ + + @num_exc[:t3].to_s + when 4 + @num_exc[:t4] += 1 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2], + t3: @num_exc[:t3], + t4: @num_exc[:t4] += 1 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + '_' \ + + @num_exc[:t3].to_s + '_' \ + + @num_exc[:t4].to_s + end + end + def check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,type,md,dob) + begin + chosen_seg_names_ << chosen_seg_name + chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) + if chosen_seg_names_.compact.uniq.length \ + == chosen_seg_names_.compact.length + #check that all auto given seg names are unique + chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). + mark( + "duplicated auto segment name: #{type} #{chosen_seg_name}\n" \ + + "#{chosen_seg_names_}\n" \ + + " manually name level 1 segments '1~given_name'\n" \ + + 'filename: ' + md.fns + "\n" \ + + 'heading text: "' + dob.obj + '"' + "\n" \ + + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' + ) + chosen_seg_name=auto_numbering_exceptions(chosen_seg_names_,md,dob) + check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,:exception,md,dob) + end + rescue + end + end def auto_seg_name(possible_seg_name,heading_num_is,dob,type) prefix=case type when :auto then Mx[:segname_prefix_auto_num_provide] @@ -324,41 +417,49 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - chosen_seg_name=if possible_seg_name.to_s =~/^[0-9]+[.]?$/m \ - and possible_seg_name.to_i <= heading_num_is.to_i \ - and dob.lv == '1' - prefix + leading_zeros_fixed_width_number(possible_seg_name) - elsif possible_seg_name.to_s =~/^[0-9]+[.,:-]*$/m \ - and dob.lv == '1' + @chosen_seg_name= + if dob.lv=='4' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){3}/m possible_seg_name=possible_seg_name.to_s. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name - elsif possible_seg_name.to_s =~ - /^[0-9]+[.,:-][0-9]+[.,:-]*$/m \ - and dob.lv == '2' + elsif dob.lv=='3' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){2}/m possible_seg_name=possible_seg_name.to_s. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name - elsif possible_seg_name.to_s =~ - /^[0-9]+[.,:-][0-9]+[.,:-][0-9][\d.,:-]*$/m \ - and dob.lv == '3' + elsif dob.lv=='2' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){1}/m possible_seg_name=possible_seg_name.to_s. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name + elsif dob.lv=='1' \ + and possible_seg_name.to_s =~/^[0-9]+[:,-]?$/m + if possible_seg_name.to_i <= heading_num_is.to_i + prefix + leading_zeros_fixed_width_number(possible_seg_name) + else + possible_seg_name=possible_seg_name.to_s. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + prefix + possible_seg_name + end else - Mx[:segname_prefix_auto_num_other]*dob.lv.to_i \ - + possible_seg_name.to_s + @chosen_seg_name=auto_numbering_exceptions(@chosen_seg_names,md,dob) end - @chosen_seg_names << chosen_seg_name - if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique - chosen_seg_name - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). - mark("duplicated auto segment name: #{type} #{chosen_seg_name} - #{@chosen_seg_names}; manually name level 1 segments '1~given_name'\n #{@md.fns}\n #{dob.obj}") - exit + check_that_seg_names_are_unique(@chosen_seg_names,@chosen_seg_name,type,@md,dob) + end + def set_name_and_tags(dob,possible_seg_name) + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << possible_seg_name + elsif (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts 'warn, there may be a conflicting numbering scheme' end end def name_para_seg_filename(data) #segment naming, remaining @@ -377,7 +478,7 @@ module SiSU_AO_Numbering # if there is none a sequential number is designated, preceded by an underscore @tuned_file,@unique_auto_name=[],[] tags={} - art_filename_auto=1 + @art_filename_auto=0 @counter=1 if not @md.seg_autoname_safe \ and (@md.opt.act[:verbose_plus][:set]==:on \ @@ -385,10 +486,11 @@ module SiSU_AO_Numbering puts 'manual segment names, numbers used as names, risk warning (segmented html)' end ocn_html_seg=[] + @num_exc={ t1: 0, t2: 0, t3: 0, t4: 0 } data.each do |dob| if dob.is==:heading \ && dob.ln \ - and dob.ln.to_s =~/^[456]/ + and dob.ln.to_s =~/^[4-7]/ heading_num_is=/^\d+:(\d+);\d/m.match(dob.node)[1] if dob.ln==4 \ and not dob.name \ @@ -396,47 +498,72 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name - possible_seg_name=$1 - possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) - possible_seg_name=possible_seg_name. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(possible_seg_name) - dob.name=possible_seg_name - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << possible_seg_name - elsif (@md.opt.act[:verbose_plus][:set]==:on \ - or @md.opt.act[:maintenance][:set]==:on) - puts 'warn, there may be a conflicting numbering scheme' + and dob.ln.to_s =~/^[5-7]/ \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9])+)/m + #heading starts with a recognised numeric + #or word followed by a recognised numeric construct, + #use that as name + if dob.ln==7 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){3})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + elsif dob.ln==6 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){2})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + elsif dob.ln==5 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){1})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) end end - if dob.ln==4 \ - and dob.name #extract segment name from embedded document structure info - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(dob.name) - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << dob.name + if dob.ln==4 + if dob.name !~/^\S+/ \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+)/m + #heading starts with a recognised numeric + #or word followed by a recognised numeric construct, + #use that as name + possible_seg_name=$1 + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) end - end - if dob.ln==4 \ - and not dob.name #if still no segment name, provide a numerical one - possible_seg_name= - auto_seg_name(art_filename_auto,heading_num_is,dob,:auto) - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(possible_seg_name) - dob.name=possible_seg_name - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << possible_seg_name - else puts 'segment name (numbering) error' + if dob.name + #extract segment name from embedded document structure info + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(dob.name) + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << dob.name + end + else + #if no segment name, + #provide a numerical one + @art_filename_auto+=1 + possible_seg_name= + auto_seg_name(@art_filename_auto,heading_num_is,dob,:auto) + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << possible_seg_name + else puts 'segment name (numbering) error' + end + end + if not dob.name #should not occur + puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" end - art_filename_auto+=1 - end - if dob.ln==4 \ - and not dob.name #should not occur - puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" end end if (dob.is ==:heading \ diff --git a/lib/sisu/v5/hub.rb b/lib/sisu/v5/hub.rb index eda98084..0e90f21a 100644 --- a/lib/sisu/v5/hub.rb +++ b/lib/sisu/v5/hub.rb @@ -266,6 +266,8 @@ module SiSU rescue ensure if FileTest.directory?(@env.processing_path.processing) \ + and FileTest.directory?(@env.processing_path.processing_base_tmp) \ + and @env.processing_path.processing_base_tmp =~/#{@env.processing_path.processing}/ \ and @env.processing_path.processing_base_tmp =~/^\/tmp\/\S+/ FileUtils::cd(@env.processing_path.processing_base_tmp) do FileUtils::rm_rf('.') diff --git a/lib/sisu/v5/se_envcall.rb b/lib/sisu/v5/se_envcall.rb index defc51e4..cd0bda7d 100644 --- a/lib/sisu/v5/se_envcall.rb +++ b/lib/sisu/v5/se_envcall.rb @@ -111,13 +111,16 @@ module SiSU_Env_Call end def mono_multi_lingual? if @rc \ - && defined? @rc['lingual'] - if (@rc['lingual'].is_a?(String)) \ - && (@rc['lingual'] =~/mono(?:lingual)?/) + && defined? @rc['output_dir_structure_by'] + if @rc['output_dir_structure_by'] \ + =~/dump/ :mono - elsif (@rc['lingual'].is_a?(String)) \ - && (@rc['lingual'] =~/multi(?:lingual)?/) + elsif @rc['output_dir_structure_by'] \ + =~/language|redirect/ :multi + elsif @rc['output_dir_structure_by'] \ + =~/monolingual|filetype_mono|filenaneme_mono/ + :mono else :multi end else :multi diff --git a/lib/sisu/v5/se_processing.rb b/lib/sisu/v5/se_processing.rb index 33b4a4ed..3789f884 100644 --- a/lib/sisu/v5/se_processing.rb +++ b/lib/sisu/v5/se_processing.rb @@ -483,7 +483,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['default'].is_a?(String) @rc['flag']['default'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest --verbose' + '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --verbose' end end def arr @@ -500,7 +500,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['i'].is_a?(String) @rc['flag']['i'] else - '--digest --text --html --manifest' + '--manifest --text --html' end end def arr @@ -517,7 +517,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['ii'].is_a?(String) @rc['flag']['ii'] else - '--digest --text --html --epub --pdf --manifest' + '--manifest --text --html --epub --pdf' end end def arr @@ -534,7 +534,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['iii'].is_a?(String) @rc['flag']['iii'] else - '--digest --qrcode --text --html --epub --concordance --pdf --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode' end end def arr @@ -551,7 +551,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['iv'].is_a?(String) @rc['flag']['iv'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook' end end def arr @@ -568,7 +568,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['v'].is_a?(String) @rc['flag']['v'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --sqlite --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --sqlite' end end def arr @@ -582,7 +582,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act6'].is_a?(String) @rc['flag']['act6'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --sqlite --xhtml --xml-sax --xml-dom' end end def arr @@ -596,7 +596,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act7'].is_a?(String) @rc['flag']['act7'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --source --sisupod --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --sqlite --xhtml --xml-sax --xml-dom --source --sisupod' end end def arr @@ -610,7 +610,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act8'].is_a?(String) @rc['flag']['act8'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --xhtml --xml-sax --xml-dom --pg --update' end end def arr @@ -624,7 +624,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act9'].is_a?(String) @rc['flag']['act9'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod' end end def arr diff --git a/lib/sisu/v6/ao_doc_str.rb b/lib/sisu/v6/ao_doc_str.rb index 6be0e068..73c2ff7b 100644 --- a/lib/sisu/v6/ao_doc_str.rb +++ b/lib/sisu/v6/ao_doc_str.rb @@ -1307,7 +1307,8 @@ module SiSU_AO_DocumentStructureExtract node_parent_ln=/^([0-7])/.match(node_parent)[1].to_i STDERR.puts %{current level: #{structure_info.lv[node_ln]} (possible parent levels: #{structure_info.possible_parents(structure_info.lv[node_ln])}) parent level: #{structure_info.lv[node_parent_ln]} (possible child levels: #{structure_info.possible_children(structure_info.lv[node_parent_ln])}) -SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} if @md.opt.act[:no_stop][:set]==:on $process_document = :skip else exit @@ -1328,7 +1329,8 @@ has incorrect level and/or parent level STDERR.puts %{required header missing: @title: -SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}" } if @md.opt.act[:no_stop][:set]==:on $process_document = :skip @@ -1341,7 +1343,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" @creator: :author: anonymous? -SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}" +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}" } if @md.opt.act[:no_stop][:set]==:on $process_document = :skip @@ -1578,9 +1581,9 @@ or this level should be level :B~ rather than #{dob.lv}} node5 elsif node4 warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level 4~ & this level #{dob.lv} -either parent should be level 5~ -or this level should be 5~ rather #{dob.lv}" + 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 @@ -1623,17 +1626,17 @@ or this level should be 5~ rather #{dob.lv}" node5 elsif node5 warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level 5~ & this level #{dob.lv} -either parent should be level 6~ -or this level should be 6~ rather #{dob.lv}" + 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~ & this level #{dob.lv} + puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) either parent should be level 6~ -or this level should be 6~ rather #{dob.lv}" +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 @@ -1663,7 +1666,10 @@ or this level should be 6~ rather #{dob.lv}" 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 @@ -1679,7 +1685,8 @@ or this level should be 6~ rather #{dob.lv}" 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}"} +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 @@ -1762,7 +1769,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} 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}"} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} if @md.opt.act[:no_stop][:set]==:on $process_document = :skip else exit @@ -1771,7 +1779,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"} 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}"} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} if @md.opt.act[:no_stop][:set]==:on $process_document = :skip else exit diff --git a/lib/sisu/v6/ao_expand_insertions.rb b/lib/sisu/v6/ao_expand_insertions.rb index 8eb0e5c4..bcbec588 100644 --- a/lib/sisu/v6/ao_expand_insertions.rb +++ b/lib/sisu/v6/ao_expand_insertions.rb @@ -81,52 +81,61 @@ module SiSU_AO_Insertions end file_type_names={} file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /y/ + file_type_names[:gen] <<= if cmd_list =~ /\b--manifest\b/ "~^ { document manifest }#{lnk[:manifest]}" end - file_type_names[:gen] <<= if cmd_list =~ /h/ + file_type_names[:gen] <<= if cmd_list =~ /\b--html\b/ [ " { html, segmented text }#{lnk[:html_toc]}", " { html, scroll, document in one }#{lnk[:html_doc]}", ] end - file_type_names[:gen] <<= if cmd_list =~ /e/ + file_type_names[:gen] <<= if cmd_list =~ /\b--epub\b/ [" { epub }#{lnk[:epub]}"] end - file_type_names[:gen] <<= if cmd_list =~ /p/ + file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ + or cmd_list =~ /--pdf-landscape/ [ " { pdf, landscape }#{lnk[:pdf_landscape]}", + ] + end + file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ + or cmd_list =~ /--pdf-portrait/ + [ " { pdf, portrait }#{lnk[:pdf_portrait]}", ] end - file_type_names[:gen] <<= if cmd_list =~ /o/ + file_type_names[:gen] <<= if cmd_list =~ /\b(?:--odt|--odf)\b/ " { odf:odt, open document text }#{lnk[:odt]}" end - file_type_names[:gen] <<= if cmd_list =~ /b/ + file_type_names[:gen] <<= if cmd_list =~ /\b--xhtml\b/ " { xhtml scroll }#{lnk[:xhtml]}" end - file_type_names[:gen] <<= if cmd_list =~ /x/ + file_type_names[:gen] <<= if cmd_list =~ /\b--docbook\b/ + " { docbook }#{lnk[:docbook]}" #CHECK + end + file_type_names[:gen] <<= if cmd_list =~ /\b--xml-sax\b/ " { xml, sax }#{lnk[:xml_sax]}" end - file_type_names[:gen] <<= if cmd_list =~ /X/ + file_type_names[:gen] <<= if cmd_list =~ /\b--xml-dom\b/ " { xml, dom }#{lnk[:xml_dom]}" end - file_type_names[:gen] <<= if cmd_list =~ /a/ + file_type_names[:gen] <<= if cmd_list =~ /\b(?:--txt|--text|--plaintext)\b/ " { plain text utf-8 }#{lnk[:txt]}" end - file_type_names[:gen] <<= if cmd_list =~ /g/ - 'wiki.txt' - end - file_type_names[:gen] <<= if cmd_list =~ /w/ + #file_type_names[:gen] <<= if cmd_list =~ /g/ + # 'wiki.txt' + #end + file_type_names[:gen] <<= if cmd_list =~ /\b--concordance\b/ " { concordance }#{lnk[:html_concordance]}" end - file_type_names[:gen] <<= if cmd_list =~ /N/ + file_type_names[:gen] <<= if cmd_list =~ /\b--digest\b/ " { dcc, document content certificate (digests) }#{lnk[:digest]}" end - file_type_names[:src] <<= if source and cmd_shortcut =~ /s/ + file_type_names[:src] <<= if source and cmd_shortcut =~ /\b--source\b/ " { markup source text }#{lnk[:source]}" end - file_type_names[:src] <<= if cmd_shortcut =~ /S/ + file_type_names[:src] <<= if cmd_shortcut =~ /\b--sisupod\b/ " { markup source (zipped) pod }#{lnk[:sisupod]}" end file_type_names[:gen]=file_type_names[:gen].flatten @@ -180,6 +189,10 @@ module SiSU_AO_Insertions fn=@md.file.base_filename.xhtml(fnh) path_and_file(fn,'xhtml') end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn,'docbook') + end def xml_sax fn=@md.file.base_filename.xml_sax(fnh) path_and_file(fn,'xml_sax') @@ -254,6 +267,10 @@ module SiSU_AO_Insertions fn=@md.file.base_filename.xhtml(fnh) path_and_file(fn,'xhtml') end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn,'docbook') + end def xml_sax fn=@md.file.base_filename.xml_sax(fnh) path_and_file(fn,'xml_sax') @@ -329,6 +346,10 @@ module SiSU_AO_Insertions fn=@md.file.base_filename.xhtml(fnh) path_and_file(fn) end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn) + end def xml_sax fn=@md.file.base_filename.xml_sax(fnh) path_and_file(fn) @@ -418,6 +439,7 @@ module SiSU_AO_Insertions pdf_portrait: by_language(m_linked_doc,m_linked_doc_lang).pdf_landscape, odt: by_language(m_linked_doc,m_linked_doc_lang).odt, xhtml: by_language(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_language(m_linked_doc,m_linked_doc_lang).docbook, xml_sax: by_language(m_linked_doc,m_linked_doc_lang).xml_sax, xml_dom: by_language(m_linked_doc,m_linked_doc_lang).xml_dom, txt: by_language(m_linked_doc,m_linked_doc_lang).txt, @@ -436,6 +458,7 @@ module SiSU_AO_Insertions pdf_portrait: by_filetype(m_linked_doc,m_linked_doc_lang).pdf_landscape, odt: by_filetype(m_linked_doc,m_linked_doc_lang).odt, xhtml: by_filetype(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_filetype(m_linked_doc,m_linked_doc_lang).docbook, xml_sax: by_filetype(m_linked_doc,m_linked_doc_lang).xml_sax, xml_dom: by_filetype(m_linked_doc,m_linked_doc_lang).xml_dom, txt: by_filetype(m_linked_doc,m_linked_doc_lang).txt, @@ -454,6 +477,7 @@ module SiSU_AO_Insertions pdf_portrait: by_filename(m_linked_doc,m_linked_doc_lang).pdf_landscape, odt: by_filename(m_linked_doc,m_linked_doc_lang).odt, xhtml: by_filename(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_filename(m_linked_doc,m_linked_doc_lang).docbook, xml_sax: by_filename(m_linked_doc,m_linked_doc_lang).xml_sax, xml_dom: by_filename(m_linked_doc,m_linked_doc_lang).xml_dom, txt: by_filename(m_linked_doc,m_linked_doc_lang).txt, diff --git a/lib/sisu/v6/ao_numbering.rb b/lib/sisu/v6/ao_numbering.rb index 7a4e4cee..2ee8c30e 100644 --- a/lib/sisu/v6/ao_numbering.rb +++ b/lib/sisu/v6/ao_numbering.rb @@ -69,6 +69,27 @@ module SiSU_AO_Numbering @obj=@type=@ocn=@lv=@name=@index=@comment=nil @chosen_seg_names=[] end + def chosen_seg_names(chosen,chosen_seg_name,dob,md,type) + @chosen_seg_names=if chosen.compact.uniq.length \ + == chosen.compact.length + chosen + else + if md.opt.act[:maintenance][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). + mark( + "duplicated auto segment name: #{type} #{chosen}\n" \ + + "#{chosen}\n" \ + + " manually name level 1 segments '1~given_name'\n" \ + + 'filename: ' + md.fns + "\n" \ + + 'heading text: "' + dob.obj + '"' + "\n" \ + + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' + ) + end + chosen=chosen[0..-2] + chosen_seg_name=auto_numbering_exceptions(chosen,md,dob) + chosen << chosen_seg_name + end + end def number_of_segments? if @@segments_count==0 @data.each do |dob| @@ -314,6 +335,78 @@ module SiSU_AO_Numbering possible_seg_name.to_s end end + def auto_numbering_exceptions(chosen_seg_names_,md,dob) + number_make=case dob.lv.to_i + when 1 + @num_exc={ + t1: @num_exc[:t1] += 1, + t2: 0, + t3: 0, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + when 2 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2] += 1, + t3: 0, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + when 3 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2], + t3: @num_exc[:t3] += 1, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + '_' \ + + @num_exc[:t3].to_s + when 4 + @num_exc[:t4] += 1 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2], + t3: @num_exc[:t3], + t4: @num_exc[:t4] += 1 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + '_' \ + + @num_exc[:t3].to_s + '_' \ + + @num_exc[:t4].to_s + end + end + def check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,type,md,dob) + begin + chosen_seg_names_ << chosen_seg_name + chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) + if chosen_seg_names_.compact.uniq.length \ + == chosen_seg_names_.compact.length + #check that all auto given seg names are unique + chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). + mark( + "duplicated auto segment name: #{type} #{chosen_seg_name}\n" \ + + "#{chosen_seg_names_}\n" \ + + " manually name level 1 segments '1~given_name'\n" \ + + 'filename: ' + md.fns + "\n" \ + + 'heading text: "' + dob.obj + '"' + "\n" \ + + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' + ) + chosen_seg_name=auto_numbering_exceptions(chosen_seg_names_,md,dob) + check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,:exception,md,dob) + end + rescue + end + end def auto_seg_name(possible_seg_name,heading_num_is,dob,type) prefix=case type when :auto then Mx[:segname_prefix_auto_num_provide] @@ -324,41 +417,49 @@ module SiSU_AO_Numbering possible_seg_name=possible_seg_name. gsub(/\.$/,'') end - chosen_seg_name=if possible_seg_name.to_s =~/^[0-9]+[.]?$/m \ - and possible_seg_name.to_i <= heading_num_is.to_i \ - and dob.lv == '1' - prefix + leading_zeros_fixed_width_number(possible_seg_name) - elsif possible_seg_name.to_s =~/^[0-9]+[.,:-]*$/m \ - and dob.lv == '1' + @chosen_seg_name= + if dob.lv=='4' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){3}/m possible_seg_name=possible_seg_name.to_s. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name - elsif possible_seg_name.to_s =~ - /^[0-9]+[.,:-][0-9]+[.,:-]*$/m \ - and dob.lv == '2' + elsif dob.lv=='3' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){2}/m possible_seg_name=possible_seg_name.to_s. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name - elsif possible_seg_name.to_s =~ - /^[0-9]+[.,:-][0-9]+[.,:-][0-9][\d.,:-]*$/m \ - and dob.lv == '3' + elsif dob.lv=='2' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){1}/m possible_seg_name=possible_seg_name.to_s. gsub(/(?:[:,-]|\W)/,'.'). gsub(/\.$/,'') prefix + possible_seg_name + elsif dob.lv=='1' \ + and possible_seg_name.to_s =~/^[0-9]+[:,-]?$/m + if possible_seg_name.to_i <= heading_num_is.to_i + prefix + leading_zeros_fixed_width_number(possible_seg_name) + else + possible_seg_name=possible_seg_name.to_s. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + prefix + possible_seg_name + end else - Mx[:segname_prefix_auto_num_other]*dob.lv.to_i \ - + possible_seg_name.to_s + @chosen_seg_name=auto_numbering_exceptions(@chosen_seg_names,md,dob) end - @chosen_seg_names << chosen_seg_name - if @chosen_seg_names.compact.uniq.length == @chosen_seg_names.compact.length #checks that all auto given seg names are unique - chosen_seg_name - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). - mark("duplicated auto segment name: #{type} #{chosen_seg_name} - #{@chosen_seg_names}; manually name level 1 segments '1~given_name'\n #{@md.fns}\n #{dob.obj}") - exit + check_that_seg_names_are_unique(@chosen_seg_names,@chosen_seg_name,type,@md,dob) + end + def set_name_and_tags(dob,possible_seg_name) + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << possible_seg_name + elsif (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts 'warn, there may be a conflicting numbering scheme' end end def name_para_seg_filename(data) #segment naming, remaining @@ -377,7 +478,7 @@ module SiSU_AO_Numbering # if there is none a sequential number is designated, preceded by an underscore @tuned_file,@unique_auto_name=[],[] tags={} - art_filename_auto=1 + @art_filename_auto=0 @counter=1 if not @md.seg_autoname_safe \ and (@md.opt.act[:verbose_plus][:set]==:on \ @@ -385,10 +486,11 @@ module SiSU_AO_Numbering puts 'manual segment names, numbers used as names, risk warning (segmented html)' end ocn_html_seg=[] + @num_exc={ t1: 0, t2: 0, t3: 0, t4: 0 } data.each do |dob| if dob.is==:heading \ && dob.ln \ - and dob.ln.to_s =~/^[456]/ + and dob.ln.to_s =~/^[4-7]/ heading_num_is=/^\d+:(\d+);\d/m.match(dob.node)[1] if dob.ln==4 \ and not dob.name \ @@ -396,47 +498,72 @@ module SiSU_AO_Numbering @md.set_heading_seg=true end if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9][0-9.,:-]*)/m #heading starts with a recognised numeric or word followed by a recognised numeric construct, use that as name - possible_seg_name=$1 - possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) - possible_seg_name=possible_seg_name. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(possible_seg_name) - dob.name=possible_seg_name - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << possible_seg_name - elsif (@md.opt.act[:verbose_plus][:set]==:on \ - or @md.opt.act[:maintenance][:set]==:on) - puts 'warn, there may be a conflicting numbering scheme' + and dob.ln.to_s =~/^[5-7]/ \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9])+)/m + #heading starts with a recognised numeric + #or word followed by a recognised numeric construct, + #use that as name + if dob.ln==7 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){3})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + elsif dob.ln==6 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){2})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + elsif dob.ln==5 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){1})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) end end - if dob.ln==4 \ - and dob.name #extract segment name from embedded document structure info - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(dob.name) - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << dob.name + if dob.ln==4 + if dob.name !~/^\S+/ \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+)/m + #heading starts with a recognised numeric + #or word followed by a recognised numeric construct, + #use that as name + possible_seg_name=$1 + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) end - end - if dob.ln==4 \ - and not dob.name #if still no segment name, provide a numerical one - possible_seg_name= - auto_seg_name(art_filename_auto,heading_num_is,dob,:auto) - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(possible_seg_name) - dob.name=possible_seg_name - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << possible_seg_name - else puts 'segment name (numbering) error' + if dob.name + #extract segment name from embedded document structure info + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(dob.name) + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << dob.name + end + else + #if no segment name, + #provide a numerical one + @art_filename_auto+=1 + possible_seg_name= + auto_seg_name(@art_filename_auto,heading_num_is,dob,:auto) + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << possible_seg_name + else puts 'segment name (numbering) error' + end + end + if not dob.name #should not occur + puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" end - art_filename_auto+=1 - end - if dob.ln==4 \ - and not dob.name #should not occur - puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" end end if (dob.is ==:heading \ diff --git a/lib/sisu/v6/hub.rb b/lib/sisu/v6/hub.rb index 2558a9db..41f8e930 100644 --- a/lib/sisu/v6/hub.rb +++ b/lib/sisu/v6/hub.rb @@ -266,6 +266,8 @@ module SiSU rescue ensure if FileTest.directory?(@env.processing_path.processing) \ + and FileTest.directory?(@env.processing_path.processing_base_tmp) \ + and @env.processing_path.processing_base_tmp =~/#{@env.processing_path.processing}/ \ and @env.processing_path.processing_base_tmp =~/^\/tmp\/\S+/ FileUtils::cd(@env.processing_path.processing_base_tmp) do FileUtils::rm_rf('.') diff --git a/lib/sisu/v6/se_envcall.rb b/lib/sisu/v6/se_envcall.rb index 3727baf6..bb918786 100644 --- a/lib/sisu/v6/se_envcall.rb +++ b/lib/sisu/v6/se_envcall.rb @@ -111,13 +111,16 @@ module SiSU_Env_Call end def mono_multi_lingual? if @rc \ - && defined? @rc['lingual'] - if (@rc['lingual'].is_a?(String)) \ - && (@rc['lingual'] =~/mono(?:lingual)?/) + && defined? @rc['output_dir_structure_by'] + if @rc['output_dir_structure_by'] \ + =~/dump/ :mono - elsif (@rc['lingual'].is_a?(String)) \ - && (@rc['lingual'] =~/multi(?:lingual)?/) + elsif @rc['output_dir_structure_by'] \ + =~/language|redirect/ :multi + elsif @rc['output_dir_structure_by'] \ + =~/monolingual|filetype_mono|filenaneme_mono/ + :mono else :multi end else :multi diff --git a/lib/sisu/v6/se_processing.rb b/lib/sisu/v6/se_processing.rb index 15db8cff..23e5c420 100644 --- a/lib/sisu/v6/se_processing.rb +++ b/lib/sisu/v6/se_processing.rb @@ -483,7 +483,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['default'].is_a?(String) @rc['flag']['default'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest --verbose' + '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --verbose' end end def arr @@ -500,7 +500,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['i'].is_a?(String) @rc['flag']['i'] else - '--digest --text --html --manifest' + '--manifest --text --html' end end def arr @@ -517,7 +517,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['ii'].is_a?(String) @rc['flag']['ii'] else - '--digest --text --html --epub --pdf --manifest' + '--manifest --text --html --epub --pdf' end end def arr @@ -534,7 +534,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['iii'].is_a?(String) @rc['flag']['iii'] else - '--digest --qrcode --text --html --epub --concordance --pdf --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode' end end def arr @@ -551,7 +551,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['iv'].is_a?(String) @rc['flag']['iv'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook' end end def arr @@ -568,7 +568,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['v'].is_a?(String) @rc['flag']['v'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --sqlite --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --sqlite' end end def arr @@ -582,7 +582,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act6'].is_a?(String) @rc['flag']['act6'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --sqlite --xhtml --xml-sax --xml-dom' end end def arr @@ -596,7 +596,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act7'].is_a?(String) @rc['flag']['act7'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --source --sisupod --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --sqlite --xhtml --xml-sax --xml-dom --source --sisupod' end end def arr @@ -610,7 +610,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act8'].is_a?(String) @rc['flag']['act8'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --xhtml --xml-sax --xml-dom --pg --update' end end def arr @@ -624,7 +624,7 @@ module SiSU_Info_Processing_Flag and @rc['flag']['act9'].is_a?(String) @rc['flag']['act9'] else - '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod --manifest' + '--manifest --text --html --epub --pdf --concordance --qrcode --digest --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod' end end def arr |