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 --- data/doc/sisu/CHANGELOG_v4 | 2 + data/doc/sisu/CHANGELOG_v5 | 2 + lib/sisu/v4/dal_doc_str.rb | 118 ++++++++++++++++++++++++++++++++------ lib/sisu/v5/dal_doc_str.rb | 138 +++++++++++++++++++++++++++++++++------------ 4 files changed, 208 insertions(+), 52 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v4 b/data/doc/sisu/CHANGELOG_v4 index 8010587b..a5caddc3 100644 --- a/data/doc/sisu/CHANGELOG_v4 +++ b/data/doc/sisu/CHANGELOG_v4 @@ -30,6 +30,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_4.2.9.orig.tar.xz sisu_4.2.9.orig.tar.xz sisu_4.2.9-1.dsc +* dal, document_structure_check_info + %% 4.2.8.orig.tar.xz (2013-10-23:42/3) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_4.2.8 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_4.2.8-1 diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 046883b7..dcf26372 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -30,6 +30,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.0.22.orig.tar.xz sisu_5.0.22.orig.tar.xz sisu_5.0.22-1.dsc +* dal, document_structure_check_info + %% 5.0.21.orig.tar.xz (2013-10-23:42/3) http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.0.21 http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/sisu_5.0.21-1 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|
|^<:\#|<:- |<[:!]!4|