aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/ao_doc_str.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-08-08 00:34:25 -0400
committerRalph Amissah <ralph@amissah.com>2014-08-08 00:36:15 -0400
commit6bc3b814011e829db684ec96bb3abd1e4abb29c3 (patch)
tree72d759c1d89a72c4fc5e3c46f6917f69e72699e6 /lib/sisu/v5/ao_doc_str.rb
parentv5: merged v6 libraries (diff)
v5 v6: extend document structure, headings A - D, 1 - 4
* sql db table structure changed (needs to be rebuilt)
Diffstat (limited to 'lib/sisu/v5/ao_doc_str.rb')
-rw-r--r--lib/sisu/v5/ao_doc_str.rb78
1 files changed, 67 insertions, 11 deletions
diff --git a/lib/sisu/v5/ao_doc_str.rb b/lib/sisu/v5/ao_doc_str.rb
index 931e51d3..11990abf 100644
--- a/lib/sisu/v5/ao_doc_str.rb
+++ b/lib/sisu/v5/ao_doc_str.rb
@@ -1223,7 +1223,7 @@ module SiSU_AO_DocumentStructureExtract
end
def structure_info
def lv
- %w[A~ B~ C~ D~ 1 2 3]
+ %w[A~ B~ C~ D~ 1 2 3 4]
end
def possible_parents(child)
case child
@@ -1234,6 +1234,7 @@ module SiSU_AO_DocumentStructureExtract
when /1/ then 'A~, B~, C~, D~'
when /2/ then '1'
when /3/ then '2'
+ when /4/ then '3'
end
end
def possible_children(parent)
@@ -1244,20 +1245,21 @@ module SiSU_AO_DocumentStructureExtract
when /D~/ then '1'
when /1/ then '2'
when /2/ then '3'
- when /3/ then 'none'
+ when /3/ then '4'
+ when /4/ then '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
+ node_ln=/^([0-7])/.match(node)[1].to_i
+ node_parent_ln=/^([0-7])/.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
+ node_ln=/^([0-7])/.match(node)[1].to_i
+ 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}"}
@@ -1297,12 +1299,12 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"
required_headers_present?
data=@data
@o_array=[]
- node=ocn=ocn_dv=ocn_sp=ocnh=ocnh0=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image
+ node=ocn=ocn_dv=ocn_sp=ocnh=ocnh0=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocnh7=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 #&nbsp; added with Tune.code #ยก
- parent=node1=node2=node3=node4=node5=node6=nil
+ parent=node1=node2=node3=node4=node5=node6=node7=nil
node0='0:0;0'
@collapsed_lv0=0
- @lev_occurences={ a: 0, b: 0, c: 0, d: 0, l1: 0, l2: 0, l3: 0 }
+ @lev_occurences={ a: 0, b: 0, c: 0, d: 0, l1: 0, l2: 0, l3: 0, l4: 0 }
data.each do |dob|
h={}
if (dob.obj !~ regex_exclude_ocn_and_node || dob.is==:code) \
@@ -1336,7 +1338,8 @@ SKIPPED processing file: [#{@md.opt.lng}] "#{@md.fns}"
or ln.to_s =~@md.lv3 \
or ln.to_s =~@md.lv4 \
or ln.to_s =~@md.lv5 \
- or ln.to_s =~@md.lv6)
+ or ln.to_s =~@md.lv6 \
+ or ln.to_s =~@md.lv7)
if not dob.obj =~/~#|-#/
ocnh+=1
end
@@ -1523,7 +1526,7 @@ or this level should be level :B~ rather than #{dob.lv}}
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
+or this level should be 5~ rather #{dob.lv}"
document_structure_check_info(node6,node4,:error)
@collapsed_lv6=@collapsed_lv4+1
node4
@@ -1549,6 +1552,59 @@ or this level should be 5~ rather #{dob.lv}" #level 6
end
collapsed_level=@collapsed_lv6
node,ocn_sp=node6,"h#{ocnh}"
+ elsif ln==7 \
+ or ln=~@md.lv7
+ @lev_occurences[:l4] += 1
+ if not dob.obj =~/~#|-#/
+ ocn_flag=true
+ ocnh7+=1
+ node7="7:#{ocnh7};#{ocn}"
+ else
+ ocn_flag=false
+ node7="7:0;0"
+ end
+ parent=if node6
+ document_structure_check_info(node7,node6)
+ @collapsed_lv7=@collapsed_lv6+1
+ 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}"
+ 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}
+either parent should be level 6~
+or this level should be 6~ rather #{dob.lv}"
+ document_structure_check_info(node7,node4,:error)
+ @collapsed_lv6=@collapsed_lv4+1
+ node4
+ elsif node3
+ warning_incorrect_parent_level_or_level(dob.obj)
+ document_structure_check_info(node7,node3,:error)
+ @collapsed_lv6=@collapsed_lv3+1
+ node3
+ elsif node2
+ warning_incorrect_parent_level_or_level(dob.obj)
+ document_structure_check_info(node7,node2,:error)
+ @collapsed_lv6=@collapsed_lv2+1
+ node2
+ elsif node1
+ warning_incorrect_parent_level_or_level(dob.obj)
+ document_structure_check_info(node7,node1,:error)
+ @collapsed_lv6=@collapsed_lv1+1
+ node1
+ else
+ warning_incorrect_parent_level_or_level(dob.obj)
+ document_structure_check_info(node7,node0,:error)
+ node0
+ end
+ collapsed_level=@collapsed_lv7
+ node,ocn_sp=node7,"h#{ocnh}"
end
else
unless @lev_occurences[:l1] > 0