From 7e3cee576368c095fe491014bd279eb280c598ba Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 3 Feb 2012 20:41:32 -0500 Subject: v3dv, dal +, use symbols to identify document objects type (is) and group (of) * (dal & code affected as a result) --- lib/sisu/v3dv/dal_doc_str.rb | 56 +++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'lib/sisu/v3dv/dal_doc_str.rb') diff --git a/lib/sisu/v3dv/dal_doc_str.rb b/lib/sisu/v3dv/dal_doc_str.rb index ba62ad9e..a3c697e0 100644 --- a/lib/sisu/v3dv/dal_doc_str.rb +++ b/lib/sisu/v3dv/dal_doc_str.rb @@ -561,9 +561,9 @@ module SiSU_DAL_DocumentStructureExtract @dob end def structure_markup #build structure where structure provided only in meta header - @dob=if @dob.is =~/para/ \ - and ((@dob.hang !~/[1-9]/ and @dob.indent !~/[1-9]/) \ - or (@dob.hang != @dob.indent)) \ + @dob=if @dob.is ==:para \ + && (((@dob.hang !~/[1-9]/) && (@dob.indent !~/[1-9]/)) \ + || (@dob.hang != @dob.indent)) \ and not @dob.bullet_ @dob=case @dob.obj when /^#{@md.lv1}/ @@ -651,12 +651,14 @@ module SiSU_DAL_DocumentStructureExtract parent=node1=node2=node3=node4=node5=node6=nil data.each do |dob| h={} - if (dob.obj !~ regex_exclude_ocn_and_node || dob.is =='code') \ - and dob.of !~/(?:comment|layout|meta)/ \ - and dob.obj !~/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/ \ - and dob.ocn_ + if (dob.obj !~ regex_exclude_ocn_and_node || dob.is ==:code) \ + && (dob.of !=:comment \ + && dob.of !=:layout \ + && dob.of !=:meta) \ + && dob.obj !~/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/ \ + && dob.ocn_ #dob.ln now is determined, and set earlier, check how best to remove this --> - if dob.is=='heading' + if dob.is==:heading ln=case dob.lv when 'A'; 1 when 'B'; 2 @@ -672,7 +674,7 @@ module SiSU_DAL_DocumentStructureExtract if not dob.obj =~/<:#>|~#|-#/ \ or not dob.toc_ # fix this no longer in dob.obj ocn+=1 - if dob.is=='heading' \ + if dob.is==:heading \ and (ln.to_s =~/^[1-9]/ \ or ln.to_s =~@md.lv1 \ or ln.to_s =~@md.lv2 \ @@ -708,26 +710,31 @@ module SiSU_DAL_DocumentStructureExtract end else ocno+=1 - if dob.is=='table' + if dob.is==:table ocnt+=1 ocn_sp,parent="t#{ocnt}",node - elsif dob.is=='code' + elsif dob.is==:code ocnc+=1 ocn_sp,parent="c#{ocnc}",node - elsif dob.is=~/^(?:group|block|alt|verse)/ + elsif dob.is==:group \ + || dob.is==:block \ + || dob.is==:alt \ + || dob.is==:verse ocng+=1 #group, poem ocn_sp,parent="g#{ocng}",node - elsif dob.is=~/image|#{Mx[:lnk_o]}\S+?\.(?:png|jpg|gif)\s+/m + elsif dob.is==:image #check ocni+=1 ocn_sp,parent="i#{ocni}",node else ocnp+=1 #paragraph ocn_sp,parent="p#{ocnp}",node end end - if dob.is=='heading' + if dob.is==:heading dob.ln,dob.node,dob.ocn,dob.odv,dob.osp,dob.parent=ln,node,ocn,ocn_dv,ocn_sp,parent else - unless dob.of=~/meta|comment|layout/ + if dob.of !=:meta \ + && dob.of !=:comment \ + && dob.of !=:layout dob.ocn,dob.odv,dob.osp,dob.parent=ocn,ocn_dv,ocn_sp,parent end end @@ -739,25 +746,31 @@ module SiSU_DAL_DocumentStructureExtract h elsif dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') - if dob.is=='para' + if dob.is==:para h={ obj: dob.obj, ocn_: false, ocn: nil } dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) - elsif dob.is=='heading' + elsif dob.is==:heading h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: true } dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) end elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') - if dob.is=='para' + if dob.is==:para h={ obj: dob.obj, ocn_: false, ocn: nil } dob=SiSU_DAL_DocumentStructure::ObjectPara.new.paragraph(h,dob) - elsif dob.is=='heading' + elsif dob.is==:heading h={ obj: dob.obj, ocn_: false, ocn: nil, toc_: false } dob=SiSU_DAL_DocumentStructure::ObjectHeading.new.heading(h,dob) end else dob end - dob.obj=dob.obj.gsub(/\n\n/,"\n") if dob.is =~/(?:code|verse|alt|group|block)/ #newlines taken out + if dob.is==:code \ + || dob.is==:verse \ + || dob.is==:alt \ + || dob.is==:group \ + || dob.is==:block + dob.obj=dob.obj.gsub(/\n\n/,"\n") #newlines taken out + end @o_array << dob end @o_array @@ -791,7 +804,8 @@ module SiSU_DAL_DocumentStructureExtract puts "<#{@s[0]}>" end data.each_with_index do |o,i| - if o.is =~/^heading/ + if o.is ==:heading \ + || o.is ==:heading_insert case o.ln when 1 tuned_file << tag_close(o.ln,hs) -- cgit v1.2.3