aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4/dal_doc_str.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-10-23 23:59:57 -0400
committerRalph Amissah <ralph@amissah.com>2013-10-23 23:59:57 -0400
commit8605801052c23ea408951b4d4054cb90d9caf1f6 (patch)
treeee82b5108ccc570222ba3f0fd72418a85ca70344 /lib/sisu/v4/dal_doc_str.rb
parentdebian/changelog (4.2.7-1) (diff)
parentv4 v5: dal, collapsed levels implemented (diff)
Merge tag 'sisu_4.2.8' into debian/sid
SiSU 4.2.8
Diffstat (limited to 'lib/sisu/v4/dal_doc_str.rb')
-rw-r--r--lib/sisu/v4/dal_doc_str.rb90
1 files changed, 84 insertions, 6 deletions
diff --git a/lib/sisu/v4/dal_doc_str.rb b/lib/sisu/v4/dal_doc_str.rb
index e4a0be2b..8a177569 100644
--- a/lib/sisu/v4/dal_doc_str.rb
+++ b/lib/sisu/v4/dal_doc_str.rb
@@ -802,6 +802,7 @@ module SiSU_DAL_DocumentStructureExtract
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 #&nbsp; added with Tune.code #ยก
parent=node1=node2=node3=node4=node5=node6=nil
+ @collapsed_lv1=1
data.each do |dob|
h={}
if (dob.obj !~ regex_exclude_ocn_and_node || dob.is==:code) \
@@ -839,27 +840,104 @@ module SiSU_DAL_DocumentStructureExtract
if ln==1 \
or ln=~@md.lv1; ocnh1+=1 #heading
node1="1:#{ocnh1};#{ocn}"
+ @collapsed_lv1=1
+ collapsed_level=@collapsed_lv1
node,ocn_sp,parent=node1,"h#{ocnh}",0 #FIX
elsif ln==2 \
or ln=~@md.lv2; ocnh2+=1
node2="2:#{ocnh2};#{ocn}"
- node,ocn_sp,parent=node2,"h#{ocnh}",node1
+ parent=if node1
+ @collapsed_lv2=@collapsed_lv1+1
+ node1
+ else
+ 0
+ end
+ collapsed_level=@collapsed_lv2
+ node,ocn_sp=node2,"h#{ocnh}"
elsif ln==3 \
or ln=~@md.lv3; ocnh3+=1
node3="3:#{ocnh3};#{ocn}"
- node,ocn_sp,parent=node3,"h#{ocnh}",node2
+ parent=if 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/
+ @collapsed_lv3=@collapsed_lv1+1
+ node1
+ else
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ 0
+ end
+ collapsed_level=@collapsed_lv3
+ node,ocn_sp=node3,"h#{ocnh}"
elsif ln==4 \
or ln=~@md.lv4; ocnh4+=1
node4="4:#{ocnh4};#{ocn}"
- node,ocn_sp,parent=node4,"h#{ocnh}",node3
+ parent=if node3
+ @collapsed_lv4=@collapsed_lv3+1
+ node3
+ elsif node2
+ @collapsed_lv4=@collapsed_lv2+1
+ node2
+ elsif node1
+ @collapsed_lv4=@collapsed_lv1+1
+ node1
+ else
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ 0
+ end
+ collapsed_level=@collapsed_lv4
+ node,ocn_sp=node4,"h#{ocnh}"
elsif ln==5 \
or ln=~@md.lv5; ocnh5+=1
node5="5:#{ocnh5};#{ocn}"
- node,ocn_sp,parent=node5,"h#{ocnh}",node4
+ parent=if node4
+ @collapsed_lv5=@collapsed_lv4+1
+ node4
+ elsif node3
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ @collapsed_lv5=@collapsed_lv3+1
+ node3
+ elsif node2
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ @collapsed_lv5=@collapsed_lv2+1
+ node2
+ elsif node1
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ @collapsed_lv5=@collapsed_lv1+1
+ node1
+ else
+ 0
+ end
+ collapsed_level=@collapsed_lv5
+ node,ocn_sp=node5,"h#{ocnh}"
elsif ln==6 \
or ln=~@md.lv6; ocnh6+=1
node6="6:#{ocnh6};#{ocn}"
- node,ocn_sp,parent=node6,"h#{ocnh}",node5
+ parent=if 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/
+ @collapsed_lv6=@collapsed_lv4+1
+ node4
+ elsif node3
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ @collapsed_lv6=@collapsed_lv3+1
+ node3
+ elsif node2
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ @collapsed_lv6=@collapsed_lv2+1
+ node2
+ elsif node1
+ puts "warning, incorrect node and or parent level" unless @md.opt.cmd=~/q/
+ @collapsed_lv6=@collapsed_lv1+1
+ node1
+ else
+ 0
+ end
+ collapsed_level=@collapsed_lv6
+ node,ocn_sp=node6,"h#{ocnh}"
end
else
ocno+=1
@@ -883,7 +961,7 @@ module SiSU_DAL_DocumentStructureExtract
end
end
if dob.is==:heading
- dob.ln,dob.node,dob.ocn,dob.odv,dob.osp,dob.parent=ln,node,ocn,ocn_dv,ocn_sp,parent
+ dob.ln,dob.node,dob.ocn,dob.odv,dob.osp,dob.parent,dob.lc=ln,node,ocn,ocn_dv,ocn_sp,parent,collapsed_level
else
if dob.of !=:meta \
&& dob.of !=:comment \