diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sisu/v4/dal_doc_str.rb | 118 | ||||
| -rw-r--r-- | lib/sisu/v4/options.rb | 6 | ||||
| -rw-r--r-- | lib/sisu/v5/dal_doc_str.rb | 138 | ||||
| -rw-r--r-- | lib/sisu/v5/options.rb | 10 | 
4 files changed, 207 insertions, 65 deletions
| diff --git a/lib/sisu/v4/dal_doc_str.rb b/lib/sisu/v4/dal_doc_str.rb index 8a177569..f9dd4954 100644 --- a/lib/sisu/v4/dal_doc_str.rb +++ b/lib/sisu/v4/dal_doc_str.rb @@ -796,12 +796,71 @@ module SiSU_DAL_DocumentStructureExtract      def initialize(md,data)        @md,@data=md,data      end +    def structure_info +      def lv +        %w[0 A~ B~ C~ 1 2 3] +      end +      def possible_parents(child) +        case child +        when /A~/ +          'none' +        when /B~/ +          'A~' +        when /C~/ +          'B~' +        when /1/ +          'A~, B~, C~' +        when /2/ +          '1' +        when /3/ +          '3' +        end +      end +      def possible_children(parent) +        case parent +        when /A~/ +          'B~, 1' +        when /B~/ +          'C~, 1' +        when /C~/ +          '1' +        when /1/ +          '2' +        when /2/ +          '3' +        when /3/ +          'none' +        end +      end +      self +    end +    def document_structure_check_info(node,node_parent,status=:ok) +      node_ln=/^([0-6])/.match(node)[1].to_i +      node_parent_ln=/^([0-6])/.match(node_parent)[1].to_i +      if status==:error \ +      or @md.opt.act[:maintenance][:set]==:on +        puts %{node: #{node},    parent node: #{node_parent}  #{status.upcase}} +        if status==:error +          node_ln=/^([0-6])/.match(node)[1].to_i +          node_parent_ln=/^([0-6])/.match(node_parent)[1].to_i +          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])}) +--        } +        end +      end +    end +    def warning_incorrect_parent_level_or_level(txt) +      puts %{warning, +#{txt} +has incorrect level and/or parent level} +    end      def ocn                                                                      #and auto segment numbering increment        data=@data        @o_array=[]        node=ocn=ocn_dv=ocn_sp=ocnh=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image        regex_exclude_ocn_and_node = /#{Rx[:meta]}|^@\S+?:\s|^4~endnotes|^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^\^~ |<:e[:_]\d+?>|^<:\#|<:- |<[:!]!4|<hr width|#{Mx[:br_endnotes]}|\A\s*\Z/mi #ocn here #  added with Tune.code #¡        parent=node1=node2=node3=node4=node5=node6=nil +      node0='0:0;0'        @collapsed_lv1=1        data.each do |dob|          h={} @@ -840,17 +899,20 @@ module SiSU_DAL_DocumentStructureExtract                if ln==1 \                or ln=~@md.lv1; ocnh1+=1                     #heading                  node1="1:#{ocnh1};#{ocn}" +                document_structure_check_info(node1,node0)                  @collapsed_lv1=1                  collapsed_level=@collapsed_lv1 -                node,ocn_sp,parent=node1,"h#{ocnh}",0 #FIX +                node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX                elsif ln==2 \                or ln=~@md.lv2; ocnh2+=1                  node2="2:#{ocnh2};#{ocn}"                  parent=if node1 +                  document_structure_check_info(node2,node1)                    @collapsed_lv2=@collapsed_lv1+1                    node1                  else -                  0 +                  document_structure_check_info(node2,node0,:error) +                  node0                  end                  collapsed_level=@collapsed_lv2                  node,ocn_sp=node2,"h#{ocnh}" @@ -858,15 +920,21 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv3; ocnh3+=1                  node3="3:#{ocnh3};#{ocn}"                  parent=if node2 +                  document_structure_check_info(node3,node2)                    @collapsed_lv3=@collapsed_lv2+1                    node2                  elsif node1 -                  puts "warning, incorrect parent or node level, parent is :A~ parent should be :B~ else this node should be :B~ rather than :C~" unless @md.opt.cmd=~/q/ +                  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 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ -                  0 +                  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}" @@ -874,17 +942,21 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv4; ocnh4+=1                  node4="4:#{ocnh4};#{ocn}"                  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                  else -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ -                  0 +                  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}" @@ -892,22 +964,27 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv5; ocnh5+=1                  node5="5:#{ocnh5};#{ocn}"                  parent=if node4 +                  document_structure_check_info(node5,node4)                    @collapsed_lv5=@collapsed_lv4+1                    node4                  elsif node3 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node5,node3,:error)                    @collapsed_lv5=@collapsed_lv3+1                    node3                  elsif node2 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node5,node2,:error)                    @collapsed_lv5=@collapsed_lv2+1                    node2                  elsif node1 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node5,node1,:error)                    @collapsed_lv5=@collapsed_lv1+1                    node1                  else -                  0 +                  document_structure_check_info(node5,node0,:error) +                  node0                  end                  collapsed_level=@collapsed_lv5                  node,ocn_sp=node5,"h#{ocnh}" @@ -915,26 +992,35 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv6; ocnh6+=1                  node6="6:#{ocnh6};#{ocn}"                  parent=if node5 +                  document_structure_check_info(node6,node5)                    @collapsed_lv6=@collapsed_lv5+1                    node5                  elsif node4 -                  puts "warning, incorrect parent or node level, parent is 4~ parent should be 5~ else this node should be 5~ rather than 6~" unless @md.opt.cmd=~/q/ +                  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}" #level 6 +                  document_structure_check_info(node6,node4,:error)                    @collapsed_lv6=@collapsed_lv4+1                    node4                  elsif node3 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node6,node3,:error)                    @collapsed_lv6=@collapsed_lv3+1                    node3                  elsif node2 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node6,node2,:error)                    @collapsed_lv6=@collapsed_lv2+1                    node2                  elsif node1 -                  puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/ +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node6,node1,:error)                    @collapsed_lv6=@collapsed_lv1+1                    node1                  else -                  0 +                  document_structure_check_info(node6,node0,:error) +                  node0                  end                  collapsed_level=@collapsed_lv6                  node,ocn_sp=node6,"h#{ocnh}" diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb index 54ef7ccc..4f5087dc 100644 --- a/lib/sisu/v4/options.rb +++ b/lib/sisu/v4/options.rb @@ -1072,6 +1072,6 @@ module SiSU_Commandline    end  end  __END__ -note usually named @opt is carried in Param usually as @md @opt is a subset of -@md where @md is passed, contents of @opt are available as @md.opt passing @opt -as well is duplication check for fns & fnb +note usually named @opt is carried in Param (usually as @md.opt), @opt is a +subset of @md where @md is passed, contents of @opt are available as @md.opt +passing @opt as well is duplication check for fns & fnb diff --git a/lib/sisu/v5/dal_doc_str.rb b/lib/sisu/v5/dal_doc_str.rb index edf826de..409c28ab 100644 --- a/lib/sisu/v5/dal_doc_str.rb +++ b/lib/sisu/v5/dal_doc_str.rb @@ -796,12 +796,71 @@ module SiSU_DAL_DocumentStructureExtract      def initialize(md,data)        @md,@data=md,data      end +    def structure_info +      def lv +        %w[0 A~ B~ C~ 1 2 3] +      end +      def possible_parents(child) +        case child +        when /A~/ +          'none' +        when /B~/ +          'A~' +        when /C~/ +          'B~' +        when /1/ +          'A~, B~, C~' +        when /2/ +          '1' +        when /3/ +          '3' +        end +      end +      def possible_children(parent) +        case parent +        when /A~/ +          'B~, 1' +        when /B~/ +          'C~, 1' +        when /C~/ +          '1' +        when /1/ +          '2' +        when /2/ +          '3' +        when /3/ +          'none' +        end +      end +      self +    end +    def document_structure_check_info(node,node_parent,status=:ok) +      node_ln=/^([0-6])/.match(node)[1].to_i +      node_parent_ln=/^([0-6])/.match(node_parent)[1].to_i +      if status==:error \ +      or @md.opt.act[:maintenance][:set]==:on +        puts %{node: #{node},    parent node: #{node_parent}  #{status.upcase}} +        if status==:error +          node_ln=/^([0-6])/.match(node)[1].to_i +          node_parent_ln=/^([0-6])/.match(node_parent)[1].to_i +          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])}) +--        } +        end +      end +    end +    def warning_incorrect_parent_level_or_level(txt) +      puts %{warning, +#{txt} +has incorrect level and/or parent level} +    end      def ocn                                                                      #and auto segment numbering increment        data=@data        @o_array=[]        node=ocn=ocn_dv=ocn_sp=ocnh=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image        regex_exclude_ocn_and_node = /#{Rx[:meta]}|^@\S+?:\s|^4~endnotes|^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^\^~ |<:e[:_]\d+?>|^<:\#|<:- |<[:!]!4|<hr width|#{Mx[:br_endnotes]}|\A\s*\Z/mi #ocn here #  added with Tune.code #¡        parent=node1=node2=node3=node4=node5=node6=nil +      node0='0:0;0'        @collapsed_lv1=1        data.each do |dob|          h={} @@ -840,17 +899,20 @@ module SiSU_DAL_DocumentStructureExtract                if ln==1 \                or ln=~@md.lv1; ocnh1+=1                     #heading                  node1="1:#{ocnh1};#{ocn}" +                document_structure_check_info(node1,node0)                  @collapsed_lv1=1                  collapsed_level=@collapsed_lv1 -                node,ocn_sp,parent=node1,"h#{ocnh}",0 #FIX +                node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX                elsif ln==2 \                or ln=~@md.lv2; ocnh2+=1                  node2="2:#{ocnh2};#{ocn}"                  parent=if node1 +                  document_structure_check_info(node2,node1)                    @collapsed_lv2=@collapsed_lv1+1                    node1                  else -                  0 +                  document_structure_check_info(node2,node0,:error) +                  node0                  end                  collapsed_level=@collapsed_lv2                  node,ocn_sp=node2,"h#{ocnh}" @@ -858,19 +920,21 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv3; ocnh3+=1                  node3="3:#{ocnh3};#{ocn}"                  parent=if node2 +                  document_structure_check_info(node3,node2)                    @collapsed_lv3=@collapsed_lv2+1                    node2                  elsif node1 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect parent or node level, parent is :A~ parent should be :B~ else this node should be :B~ rather than :C~" -                  end +                  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 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end -                  0 +                  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}" @@ -878,19 +942,21 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv4; ocnh4+=1                  node4="4:#{ocnh4};#{ocn}"                  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                  else -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end -                  0 +                  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}" @@ -898,28 +964,27 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv5; ocnh5+=1                  node5="5:#{ocnh5};#{ocn}"                  parent=if node4 +                  document_structure_check_info(node5,node4)                    @collapsed_lv5=@collapsed_lv4+1                    node4                  elsif node3 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node5,node3,:error)                    @collapsed_lv5=@collapsed_lv3+1                    node3                  elsif node2 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node5,node2,:error)                    @collapsed_lv5=@collapsed_lv2+1                    node2                  elsif node1 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node5,node1,:error)                    @collapsed_lv5=@collapsed_lv1+1                    node1                  else -                  0 +                  document_structure_check_info(node5,node0,:error) +                  node0                  end                  collapsed_level=@collapsed_lv5                  node,ocn_sp=node5,"h#{ocnh}" @@ -927,34 +992,35 @@ module SiSU_DAL_DocumentStructureExtract                or ln=~@md.lv6; ocnh6+=1                  node6="6:#{ocnh6};#{ocn}"                  parent=if node5 +                  document_structure_check_info(node6,node5)                    @collapsed_lv6=@collapsed_lv5+1                    node5                  elsif node4 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect parent or node level, parent is 4~ parent should be 5~ else this node should be 5~ rather than 6~" -                  end +                  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}" #level 6 +                  document_structure_check_info(node6,node4,:error)                    @collapsed_lv6=@collapsed_lv4+1                    node4                  elsif node3 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node6,node3,:error)                    @collapsed_lv6=@collapsed_lv3+1                    node3                  elsif node2 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node6,node2,:error)                    @collapsed_lv6=@collapsed_lv2+1                    node2                  elsif node1 -                  unless @md.opt.act[:quiet][:set]==:on -                    puts "warning, incorrect node and or parent level" -                  end +                  warning_incorrect_parent_level_or_level(dob.obj) +                  document_structure_check_info(node6,node1,:error)                    @collapsed_lv6=@collapsed_lv1+1                    node1                  else -                  0 +                  document_structure_check_info(node6,node0,:error) +                  node0                  end                  collapsed_level=@collapsed_lv6                  node,ocn_sp=node6,"h#{ocnh}" diff --git a/lib/sisu/v5/options.rb b/lib/sisu/v5/options.rb index 6f23d5a1..5bf851e3 100644 --- a/lib/sisu/v5/options.rb +++ b/lib/sisu/v5/options.rb @@ -682,16 +682,6 @@ module SiSU_Commandline            { bool: false, set: :off }          else { bool: true, set: :na }          end -        act[:manifest]=if mod.inspect =~/"--inc-manifest"/ -          { bool: true, set: :on } -        elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ -        || act[:switch][:off].inspect =~/"manifest"/ -          { bool: false, set: :off } -        elsif act[:manifest]=(cmd =~/y/ \ -        || mod.inspect =~/"--manifest"/) -          { bool: true, set: :on } -        else { bool: true, set: :na } -        end          act[:links_to_manifest]=if mod.inspect =~/"--inc-links-to-manifest"|"--inc-manifest-links"/            { bool: true, set: :on }          elsif mod.inspect =~/"--(?:exc|no)-manifest"/ \ | 
