From 47afa95b36cedb0c327ebdea901fa76b0f1f34ea Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 12 Sep 2014 21:32:35 -0400 Subject: v5 v6: ao, feedback on markup document structure (heading level) errors * adjustment to (existing) provided feedback, based on: * level A~ title, required; * levels B~ C~ D~ optional sequential document divider headings (Part, Section etc. equivalent); * level 1~ required, heading level preceding substantive text; followed by * levels 2~ 3~ 4~ optional, sequential headings (1.1, 1.1.1, 1.1.1.1 equivalents) --- lib/sisu/v5/ao_doc_str.rb | 39 ++++++++++++++++++++++++--------------- lib/sisu/v6/ao_doc_str.rb | 39 ++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 30 deletions(-) (limited to 'lib') 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/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 -- cgit v1.2.3