From d08020e7b2cfd7cabc3b5d0aa18e5d07465ecfc6 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 27 Oct 2013 23:27:13 -0400 Subject: v4 v5: dal, document_structure_check_info --- lib/sisu/v4/dal_doc_str.rb | 118 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 102 insertions(+), 16 deletions(-) (limited to 'lib/sisu/v4/dal_doc_str.rb') 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|