diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-02-03 20:41:32 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-02-03 20:41:36 -0500 |
commit | 7e3cee576368c095fe491014bd279eb280c598ba (patch) | |
tree | d8b198e2e09066bcaffc5a93a5a4c434a954c6bf | |
parent | v3 v3dv: path & url links, updates for multiple output directory structures (diff) |
v3dv, dal +, use symbols to identify document objects type (is) and group (of)sisu_3.1.13
* (dal & code affected as a result)
44 files changed, 603 insertions, 469 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 38d02189..ce9abf00 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -24,6 +24,13 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.1.13.orig.tar.xz * v3 v3dv, path & url links, updates for multi output directory structure possibilities (fixes) +* v3dv, dal (& code affected as a result), use symbols to identify document + objects type (is) and group (of) + +* v3dv, epub, html, some cleaning of redundancy + +* v3dv, texinfo BROKEN, since 3.1.12 at least + * v3 v3dv, vim syntax highlighting, patch from Thilo Six <T.Six@gmx.de> applied Re: <http://thread.gmane.org/gmane.editors.vim.devel/32151> & <http://vimdoc.sourceforge.net/htmldoc/options.html#cpo-l> diff --git a/lib/sisu/v3dv/concordance.rb b/lib/sisu/v3dv/concordance.rb index bc238543..82c53e7a 100644 --- a/lib/sisu/v3dv/concordance.rb +++ b/lib/sisu/v3dv/concordance.rb @@ -238,8 +238,9 @@ WOK @dal_array.each do |line| if defined? line.ocn \ and line.ocn.to_s =~/\d/ - if line.is =~/heading/ \ - and line.ln==4 + if (line.is ==:heading \ + || line.is ==:heading_insert) \ + && line.ln==4 @seg=line.name end ocn=line.ocn.to_s diff --git a/lib/sisu/v3dv/constants.rb b/lib/sisu/v3dv/constants.rb index d39c56ea..439dee68 100644 --- a/lib/sisu/v3dv/constants.rb +++ b/lib/sisu/v3dv/constants.rb @@ -273,8 +273,8 @@ puts "#{__FILE__} #{__LINE__} #{o.inspect}" puts __FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect puts %{-\t#{__FILE__}::#{__LINE__}::#{caller}:\n"#{name}"} p "\t" + txt.obj + " << #{__FILE__} #{__LINE__} >>" -p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + dob.inspect) if dob.is=='heading' -data.each {|o| p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect) if o.is=='heading'} +p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + dob.inspect) if dob.is==:heading +data.each {|o| p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect) if o.is==:heading} puts "#{__FILE__} #{__LINE__} #{para}" if @opt.cmd =~/M/ puts "#{__FILE__} #{__LINE__} #{t_o}" if @opt.cmd =~/M/ dr ┌ 9484 dR ┍ 9485 Dr ┎ 9486 DR ┏ 9487 dl ┐ 9488 dL ┑ 9489 Dl ┒ 9490 LD ┓ 9491 ur └ 9492 uR ┕ 9493 Ur ┖ 9494 UR ┗ 9495 ul ┘ 9496 uL ┙ 9497 Ul ┚ 9498 UL ┛ 9499 vr ├ diff --git a/lib/sisu/v3dv/dal.rb b/lib/sisu/v3dv/dal.rb index d5a4a948..bd8d32dd 100644 --- a/lib/sisu/v3dv/dal.rb +++ b/lib/sisu/v3dv/dal.rb @@ -349,7 +349,7 @@ module SiSU_DAL print %{OF: #{o.of}; } end if defined? o.is - print %{IS: #{o.is}; } + print %{IS: #{o.is.to_s}; } end if defined? o.ocn print %{OCN: #{o.ocn}; } @@ -386,15 +386,15 @@ module SiSU_DAL @data.each do |o| if defined? o.ocn filename_txt.puts case o.is - when 'heading' - "[#{o.is} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}" - else "[#{o.is} [#{o.ocn}]] #{o.obj}" + when :heading + "[#{o.is.to_s} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}" + else "[#{o.is.to_s} [#{o.ocn}]] #{o.obj}" end else filename_txt.puts case o.is - when 'meta' + when :meta "[m~#{o.tag}] #{o.obj}" - else "[#{o.is}] #{o.obj}" + else "[#{o.is.to_s}] #{o.obj}" end end end @@ -402,8 +402,8 @@ module SiSU_DAL @data.each do |o| if defined? o.ocn case o.is - when 'heading' - filename_debug.puts "#{o.is} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" + when :heading + filename_debug.puts "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" end end end diff --git a/lib/sisu/v3dv/dal_character_check.rb b/lib/sisu/v3dv/dal_character_check.rb index 4ec95f82..e5ab7578 100644 --- a/lib/sisu/v3dv/dal_character_check.rb +++ b/lib/sisu/v3dv/dal_character_check.rb @@ -68,7 +68,7 @@ module SiSU_DAL_CharacterCheck @tuned_file,@endnote_array=[],[] endnote_no=1 data.each do |dob| - unless dob.is =='table' + unless dob.is ==:table dob.obj=dob.obj.strip. gsub(/^[{~}]\s*$/,''). gsub(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}"). @@ -84,7 +84,7 @@ module SiSU_DAL_CharacterCheck gsub(/\\copy(?:right)?\b/,'©'). gsub(/\\trademark\b|\\tm\b/,'®') dob.obj=dob.obj + "\n" - unless dob.is =~/^code/ + unless dob.is ==:code case dob.obj when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ sub_dob=dob.obj.dup diff --git a/lib/sisu/v3dv/dal_doc_objects.rb b/lib/sisu/v3dv/dal_doc_objects.rb index c476b0ce..e413993a 100644 --- a/lib/sisu/v3dv/dal_doc_objects.rb +++ b/lib/sisu/v3dv/dal_doc_objects.rb @@ -67,11 +67,11 @@ module SiSU_DAL_DocumentStructure def initialize @tags={} @is=@tmp=@digest=nil - @of='meta' + @of=:meta end def metadata(tags) of= @of #String, classification - group - is= 'meta' #String, classification - specific type + is= :meta #String, classification - specific type tags= tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag obj= nil @of,@is,@tags,@obj=of,is,tags,obj @@ -82,11 +82,11 @@ module SiSU_DAL_DocumentStructure attr_accessor :obj,:is,:of,:tag,:digest,:tmp def initialize @is=@obj=@tag=@digest=@digest=@tmp=nil - @of='meta' + @of=:meta end def metadata(h,o=nil) of= @of #String, classification - group - is= 'meta' #String, classification - specific type + is= :meta #String, classification - specific type tag= h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @@ -98,7 +98,7 @@ module SiSU_DAL_DocumentStructure class ObjectHeading attr_accessor :obj,:is,:tags,:of,:lv,:ln,:toc_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp def initialize - @of='para' + @of=:para @is=@obj=@lv=@ln=@toc_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil @tags=[] end @@ -135,7 +135,7 @@ module SiSU_DAL_DocumentStructure h[:lv]=heading_lv(h[:ln]) end of= @of #String, classification - group - is= 'heading' #String, classification - specific type + is= :heading #String, classification - specific type name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content @@ -162,20 +162,20 @@ module SiSU_DAL_DocumentStructure end def heading_insert(h,o=nil) heading(h,o=nil) - @is= 'heading_insert' #String, classification - specific type + @is= :heading_insert #String, classification - specific type self end end class ObjectPara attr_accessor :obj,:is,:tags,:of,:name,:idx,:bullet_,:indent,:hang,:ocn,:odv,:osp,:parent,:note_,:image_,:ocn_,:digest,:tmp def initialize - @of='para' + @of=:para @is=@obj=@name=@idx=@bullet_=@indent=@hang=@size=@ocn=@odv=@osp=@parent=@note_=@image_=@ocn_=@digest=@tmp=nil @tags=[] end def paragraph(h,o=nil) of= @of #String, classification - group - is= 'para' #String, classification - specific type + is= :para #String, classification - specific type name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content @@ -199,7 +199,7 @@ module SiSU_DAL_DocumentStructure end def docinfo(h,o=nil) of= @of #String, classification - group - is= 'docinfo' #String, classification - specific type + is= :docinfo #String, classification - specific type name= h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? tags= h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content @@ -225,13 +225,13 @@ module SiSU_DAL_DocumentStructure class ObjectBlockTxt attr_accessor :obj,:is,:of,:tags,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp def initialize - @of='block' + @of=:block @is=@obj=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil @tags=[] end def code(h,o=nil) of= @of #String, classification - group #alt 'code' - is= 'code' #String, classification - specific type + is= :code #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -251,7 +251,7 @@ module SiSU_DAL_DocumentStructure end def block(h,o=nil) of= @of #String, classification - group - is= 'block' #String, classification - specific type + is= :block #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -270,7 +270,7 @@ module SiSU_DAL_DocumentStructure end def group(h,o=nil) of= @of #String, classification - group - is= 'group' #String, classification - specific type + is= :group #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -289,7 +289,7 @@ module SiSU_DAL_DocumentStructure end def alt(h,o=nil) #see block of= @of #String, classification - group - is= 'alt' #String, classification - specific type + is= :alt #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -308,7 +308,7 @@ module SiSU_DAL_DocumentStructure end def verse(h,o=nil) #part of poem decide how you deal with this of= @of #String, classification - group - is= 'verse' #String, classification - specific type + is= :verse #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? @@ -329,13 +329,13 @@ module SiSU_DAL_DocumentStructure class ObjectTable attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:number,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp def initialize - @of='block' + @of=:block @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@number,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@digest=@tmp=nil @tags=[] end def table(h,o=nil) of= @of #String, classification - group - is= 'table' #String, classification - specific type + is= :table #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any cols= h[:cols] || ((defined? o.cols) ? o.cols : nil) widths= h[:widths] || ((defined? o.widths) ? o.widths : nil) @@ -359,13 +359,13 @@ module SiSU_DAL_DocumentStructure class ObjectImage attr_accessor :obj,:is,:of,:lv,:idx,:size,:ocn,:parent,:note_,:ocn_,:digest,:tmp def initialize - @of='image' + @of=:image @is=@obj=@lv=@idx=@size=@ocn=@parent=@note_=@ocn_=@tmp=@digest=nil @tags=[] end def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider of= @of #String, classification - group - is= 'image' #String, classification - specific type + is= :image #String, classification - specific type tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content size= h[:size] || ((defined? o.size) ? o.size : nil) @@ -387,12 +387,12 @@ module SiSU_DAL_DocumentStructure class ObjectStructure attr_accessor :obj,:tag,:node,:lv,:ln,:status,:is,:of,:tmp def initialize - @of='structure' + @of=:structure @is=@obj=@node=@lv=@ln=@status=@tmp=nil end def xml_dom(h,o=nil) of= @of #String, classification - group - is= 'xml_dom' #String, classification - specific type + is= :xml_dom #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-C then 1-6 ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 @@ -406,12 +406,12 @@ module SiSU_DAL_DocumentStructure class ObjectComment attr_accessor :obj,:is,:of,:tmp def initialize - @of='comment' + @of=:comment @is=@obj=@tmp=nil end def comment(h,o=nil) of= @of #String, classification - group - is= 'comment' #String, classification - specific type + is= :comment #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp @@ -421,12 +421,12 @@ module SiSU_DAL_DocumentStructure class ObjectLayout attr_accessor :obj,:is,:of,:tmp def initialize - @of='layout' + @of=:layout @is=@obj=@tmp=nil end def break(h,o=nil) #decide how to deal with, perhaps no obj? of= @of #String, classification - group - is= 'break' #String, classification - specific type + is= :break #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp @@ -434,7 +434,7 @@ module SiSU_DAL_DocumentStructure end def insert(h,o=nil) #decide how to deal with, could mimic paragraph? of= @of #String, classification - group - is= 'insert' #String, classification - specific type + is= :insert #String, classification - specific type obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use @of,@is,@obj,@tmp=of,is,obj,tmp 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) diff --git a/lib/sisu/v3dv/dal_endnotes.rb b/lib/sisu/v3dv/dal_endnotes.rb index eb5e3429..191260c4 100644 --- a/lib/sisu/v3dv/dal_endnotes.rb +++ b/lib/sisu/v3dv/dal_endnotes.rb @@ -74,9 +74,9 @@ module SiSU_DAL_Endnotes if @md.opt.mod.inspect =~/--no-dagger|--no-annotate/ dob.obj=dob.obj.gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') end - if defined? dob.obj \ - and defined? dob.is \ - and dob.is !~/^code/ + if (defined? dob.obj) \ + && (defined? dob.is) \ + && dob.is !=:code case dob.obj # auto-numbered endnotes <!e!> <!e_!> --> when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ dob.obj=dob.obj.gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,' \1') # required 2003w31 diff --git a/lib/sisu/v3dv/dal_hash_digest.rb b/lib/sisu/v3dv/dal_hash_digest.rb index 40f81197..ad201752 100644 --- a/lib/sisu/v3dv/dal_hash_digest.rb +++ b/lib/sisu/v3dv/dal_hash_digest.rb @@ -76,8 +76,10 @@ module SiSU_DAL_Hash unless t_o.obj.class==Array t_o.obj=t_o.obj.strip end - if t_o.of !~/structure|comment|layout/ \ - and t_o.ocn.class==Fixnum + if (t_o.of !=:structure \ + && t_o.of !=:comment \ + && t_o.of !=:layout) \ + && t_o.ocn.class==Fixnum if sha_ for hash_class in [ Digest::SHA256 ] @tuned_file << stamped(t_o,hash_class) @@ -120,7 +122,7 @@ module SiSU_DAL_Hash stripped=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_markup markup=SiSU_TextRepresentation::Alter.new(t_o).semi_revert_markup digests=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst - unless t_o.is=='code' + unless t_o.is==:code case t_o.obj when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m en_and_t_o,en_and_t_o_digest=[],[] diff --git a/lib/sisu/v3dv/dal_idx.rb b/lib/sisu/v3dv/dal_idx.rb index 5f4a38e0..21567c14 100644 --- a/lib/sisu/v3dv/dal_idx.rb +++ b/lib/sisu/v3dv/dal_idx.rb @@ -75,8 +75,9 @@ module SiSU_DAL_BookIndex tuned_file=[] idx_array=[] data.each do |dob| - if dob.is =~/heading/ \ - and dob.ln==4 + if (dob.is ==:heading \ + || dob.is ==:heading_insert) \ + && dob.ln==4 @seg=dob.name end idx_array << "#{dob.idx}~#{dob.ocn}~#{@seg}" if defined? dob.idx and not (dob.idx.nil? or dob.idx.empty?) diff --git a/lib/sisu/v3dv/dal_images.rb b/lib/sisu/v3dv/dal_images.rb index 0f65b814..6455daf1 100644 --- a/lib/sisu/v3dv/dal_images.rb +++ b/lib/sisu/v3dv/dal_images.rb @@ -80,7 +80,7 @@ module SiSU_DAL_Images end end data.each do |dob| - unless dob.is =~/^table/ + unless dob.is ==:table dob.obj=dob.obj.strip if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ if dob.obj !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+/ diff --git a/lib/sisu/v3dv/dal_numbering.rb b/lib/sisu/v3dv/dal_numbering.rb index 332db4bf..f5a09ef6 100644 --- a/lib/sisu/v3dv/dal_numbering.rb +++ b/lib/sisu/v3dv/dal_numbering.rb @@ -77,8 +77,10 @@ module SiSU_DAL_Numbering def number_plaintext_para(data) @tuned_file=[] data.each do |dob| - if dob.of !~/(?:block|comment|layout)/ \ - and dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX + if (dob.of !=:block \ + && dob.of !=:comment \ + && dob.of !=:layout) \ + && dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks end unless dob.obj.class==Array @@ -139,8 +141,8 @@ module SiSU_DAL_Numbering data.each do |dob| #@md.seg_names << [additions to segment names] title_no=nil dob=SiSU_DAL_DocumentStructureExtract::Structure.new(@md,dob).structure_markup #must happen earlier, node info etc. require - if dob.is =='heading' \ - and dob.autonum_ \ + if dob.is ==:heading \ + && dob.autonum_ \ and defined? @md.make.num_top \ and @md.make.num_top !~/^$/ if dob.lv=='1' \ @@ -206,7 +208,7 @@ module SiSU_DAL_Numbering dob.tags=[dob.name,dob.tags].flatten if dob.name !~/^\d+$/ #check whether will work across file types with stop signs dob.name.gsub(/^([a-z_\.]+)-$/,'\1') end - elsif dob.is =='heading' \ + elsif dob.is ==:heading \ and dob.autonum_ \ and @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 #here lies a bug, as is nil when run from -Dv --update, FIX @@ -240,11 +242,14 @@ module SiSU_DAL_Numbering number_small,letter_small=0,0 letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z ) data.each do |dob| - if dob.of =~/heading|para|block/ - if dob.is =='heading' \ + if dob.of ==:heading \ + || dob.of ==:heading_insert \ + || dob.of ==:para \ + || dob.of ==:block + if dob.is ==:heading \ and dob.ln.to_s=~/^[1-9]/ #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) number_small,letter_small=0,0 - elsif dob.is =~/para/ + elsif dob.is ==:para if dob.obj =~/^#[ 1]/ \ and dob.obj !~/^#\s+(?:~#)?$/ letter_small=0 @@ -286,8 +291,8 @@ module SiSU_DAL_Numbering end ocn_html_seg=[] data.each do |dob| - if dob.is=='heading' \ - and dob.ln \ + if dob.is==:heading \ + && dob.ln \ and dob.ln.to_s =~/^[456]/ if dob.ln==4 \ and not dob.name \ @@ -333,12 +338,13 @@ module SiSU_DAL_Numbering puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" end end - if dob.is =~/heading/ \ - and dob.ln==4 + if (dob.is ==:heading \ + || dob.is ==:heading_insert) \ + && dob.ln==4 @seg=dob.name end - @tuned_file << if dob.is=='heading' \ - and (@md.pagenew or @md.pagebreak) + @tuned_file << if dob.is==:heading \ + && (@md.pagenew || @md.pagebreak) m=dob.ln.to_s dob_tmp=[] if @md.pagenew.inspect =~/#{m}/ @@ -353,11 +359,11 @@ module SiSU_DAL_Numbering end if defined? dob.ocn \ and dob.ocn - @segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ + @segname=((dob.is==:heading || dob.is==:heading_insert) && dob.ln==4 && (defined? dob.name)) \ ? (dob.name) : @segname tags["#{dob.ocn}"]={ segname: @segname } - ocn_html_seg[dob.ocn]=if dob.is =~/heading/ + ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) x=if dob.ln =~/[1-3]/ { seg: nil, level: dob.ln } else #elsif dob.ln =~/[4-6]/ @@ -428,7 +434,7 @@ module SiSU_DAL_Numbering unless @md.set_heading_seg if defined? dob.ln and dob.ln.to_s !~/^[123]/m \ and dob.obj !~/\A\s*\Z/m \ - and dob.is !='layout' + and dob.is !=:layout @md.set_heading_seg=true head=if @md.title.main ; dob.ln,dob.name,dob.obj=4,'seg',@md.title.main else dob.ln,dob.name,dob.obj=4,'seg','[segment]' diff --git a/lib/sisu/v3dv/dal_syntax.rb b/lib/sisu/v3dv/dal_syntax.rb index a8ece51e..73bb6a64 100644 --- a/lib/sisu/v3dv/dal_syntax.rb +++ b/lib/sisu/v3dv/dal_syntax.rb @@ -135,7 +135,10 @@ module SiSU_DAL_Syntax dob=SiSU_Sem::Tags.new(dob,@md).rm.all end def breaks(dob) - if dob.is !~/^(?:meta|comment|code|table)/ + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table dob.obj=dob.obj.gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). gsub(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}") # depreciated end @@ -147,7 +150,11 @@ module SiSU_DAL_Syntax and @md.make.italics[:str]) \ or (defined? @vz.markup_make_italic[:str] \ and @vz.markup_make_italic[:str]) - dob.obj=if dob.is !~/^(?:meta|heading|code|comment)/ + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment word=dob.obj.scan(@line_scan_ital) word=word.flatten.compact line_array=[] @@ -202,7 +209,12 @@ module SiSU_DAL_Syntax and @md.make.bold[:str]) \ or (defined? @vz.markup_make_bold[:str] \ and @vz.markup_make_bold[:str]) - dob.obj=if dob.is !~/^(?:meta|heading|code|comment|table)/ + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment \ + && dob.is !=:table line_array=[] word=dob.obj.scan(@line_scan_bold) word=word.flatten.compact @@ -227,10 +239,13 @@ module SiSU_DAL_Syntax else dob.obj end else - dob.obj=if dob.is !~/^(?:heading|comment|meta)/ \ + dob.obj=if (dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:comment \ + && dob.is !=:meta) \ and dob.obj =~ /^!_\s+/ embolden(dob.obj) - elsif dob.is=='heading' \ + elsif dob.is==:heading \ and dob.ln.to_s =~/[7-9]/ embolden(dob.obj) else dob.obj @@ -297,7 +312,10 @@ module SiSU_DAL_Syntax # # #numbered (list) level 1 # _# #numbered (list) level 2 dob=dob.dup - if dob.is !~/^(?:meta|comment|code|table)/ + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table line_array=[] word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit if word @@ -315,7 +333,7 @@ module SiSU_DAL_Syntax gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) - if dob.is =='heading' \ + if dob.is ==:heading \ and dob.ln ==1 dob.obj=dob.obj.gsub(/\s*@title\b/," #{@md.title.full}") dob.obj=if defined? @md.creator.author \ @@ -329,7 +347,7 @@ module SiSU_DAL_Syntax and defined? @md.title.full \ and defined? @md.creator \ and @md.creator - if dob.is =='heading' + if dob.is ==:heading dob.obj=dob.obj.gsub(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ dob.obj=if dob.lv =~/[23]/ \ and defined? @md.creator.author \ @@ -426,9 +444,9 @@ module SiSU_DAL_Syntax "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need gsub(/\{\s*(.+?)\s*\}(image)/, "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image - elsif dob.is=='table' + elsif dob.is==:table dob=fontface(dob) - elsif dob.is =='code' + elsif dob.is ==:code dob.obj=dob.obj.gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). gsub(/(^|#{Mx[:gl_c]}|\s)<(br(?: \/)?)>([\s,.]|$)/,'\1<\2>\3') #convert <br> <br /> back, clumsy if dob.number_ diff --git a/lib/sisu/v3dv/db_import.rb b/lib/sisu/v3dv/db_import.rb index 93b47029..3bb6e210 100644 --- a/lib/sisu/v3dv/db_import.rb +++ b/lib/sisu/v3dv/db_import.rb @@ -261,10 +261,14 @@ module SiSU_DbImport data.obj.gsub!(/#{Mx[:gl_o]}(●)#{Mx[:gl_c]}\s*/,'\1 ') data.obj.gsub!(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check @col[:seg]=@@seg - if data.of =~/para|heading|block|group/ # regular text what of code-blocks grouped text etc. + if data.of ==:para \ + || :heading \ + || :heading_insert \ + || :block \ + || :group # regular text what of code-blocks grouped text etc. notedata=data.obj.dup - if data.is=='heading' \ - and data.ln.inspect=~/[123]/ + if data.is==:heading \ + && (data.ln.inspect=~/[123]/) @col[:lev],txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.ln,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' @col[:lid]+=1 txt=endnotes(txt).extract_any @@ -287,8 +291,8 @@ module SiSU_DbImport when /3/; @col[:lv3]+=1 end @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is=='heading' \ - and data.ln==4 + elsif data.is==:heading \ + && data.ln==4 @@seg,txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.name,data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' @col[:seg]=@@seg @col[:lv4]+=1 @@ -313,9 +317,12 @@ module SiSU_DbImport t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is=='heading' and data.ln==5 + elsif data.is==:heading \ + && data.ln==5 txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' - @@seg_full=data.name if data.is=='heading' and data.ln==5 and data.name #check data.name + @@seg_full=data.name if data.is==:heading \ + && data.ln==5 \ + && data.name #check data.name @@seg ||='' #nil # watch @col[:seg]=@@seg @col[:lv5]+=1 @@ -340,9 +347,10 @@ module SiSU_DbImport t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is=='heading' and data.ln==6 + elsif data.is==:heading \ + && data.ln==6 txt,@col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]=data.obj,data.ocn,data.lv,data.odv,data.osp,data.of,data.is,data.node,data.parent,'','' - @@seg_full=data.name if data.is=='heading' and data.ln==6 and data.name #check data.name + @@seg_full=data.name if data.is==:heading && data.ln==6 && data.name #check data.name @@seg ||='' #nil # watch @col[:seg]=@@seg @col[:lv6]+=1 @@ -367,6 +375,10 @@ module SiSU_DbImport t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' + elsif data.of==:structure \ + || data.of==:layout \ + || data.of==:comment + #added watch else #% regular text @col[:lid]+=1 txt='' @@ -390,9 +402,9 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - @col[:body]=if data.is=='table' + @col[:body]=if data.is==:table SiSU_FormatShared::CSS_Format.new(@md,data).html_table - elsif data.is=='code' + elsif data.is==:code SiSU_FormatShared::CSS_Format.new(@md,data).code elsif defined? data.indent \ and defined? data.hang \ diff --git a/lib/sisu/v3dv/db_select.rb b/lib/sisu/v3dv/db_select.rb index 478a25fa..bab898f0 100644 --- a/lib/sisu/v3dv/db_select.rb +++ b/lib/sisu/v3dv/db_select.rb @@ -196,6 +196,7 @@ module SiSU_DbSelect db_exist? @sdb_no.drop.tables when /^--(?:db=)?(?:(?:sq)?lite|pg(?:sql)?|my(?:sql)?)$/ + when /^--(?:v\d+|dev)$/ else help=SiSU_Help::Help.new help.summary diff --git a/lib/sisu/v3dv/digests.rb b/lib/sisu/v3dv/digests.rb index 91299d4c..bc4a37e5 100644 --- a/lib/sisu/v3dv/digests.rb +++ b/lib/sisu/v3dv/digests.rb @@ -300,9 +300,9 @@ module SiSU_DigestView data.each do |t_o| dgst=SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst if dgst - if t_o.is=='heading' + if t_o.is==:heading digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") - elsif t_o.is=='heading_insert' + elsif t_o.is==:heading_insert digests("#{@sp*0}[#{dgst[:ocn]}]#{@sp*(6-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]} #{t_o.lv}") else digests("#{@sp*0}#{dgst[:ocn]}#{@sp*(8-dgst[:ocn].to_s.length)}#{dgst[:dgst_stripped_txt]} #{dgst[:dgst_markedup_txt]} #{dgst[:is]}") @@ -325,7 +325,7 @@ module SiSU_DigestView dal_structure_tree("------------\n") dal_structure_tree("document structure[*]\n") data.each do |t_o| - if t_o.is=='heading' + if t_o.is==:heading x=case t_o.ln when 1; l[1] +=1 #fix Mx[:lv_o] ' '*0 +':A' @@ -342,7 +342,7 @@ module SiSU_DigestView else nil end end - ocn=t_o.ocn if defined? t_o.ocn and t_o.is !='heading_insert' + ocn=t_o.ocn if defined? t_o.ocn and t_o.is !=:heading_insert dal_structure_tree("#{x}\n") if x and not x.empty? end dal_structure_tree(" [*] heading levels\n") diff --git a/lib/sisu/v3dv/epub.rb b/lib/sisu/v3dv/epub.rb index c87112cf..7d90883b 100644 --- a/lib/sisu/v3dv/epub.rb +++ b/lib/sisu/v3dv/epub.rb @@ -160,7 +160,7 @@ module SiSU_EPUB format_head_scroll=SiSU_EPUB_Format::HeadScroll.new(@md) @data.each do |dob| pg=dob.dup - unless pg.is =~/^code/ + unless pg.is ==:code if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / endnote_array=[] if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m @@ -218,8 +218,8 @@ module SiSU_EPUB @ncx_cls=[] @level_a_first_occurrence=true @data.each do |dob| - if dob.is=='heading' \ - or dob.is=='heading_insert' + if dob.is==:heading \ + || dob.is==:heading_insert dob_toc=dob.dup toc=case dob_toc.ln when 1 diff --git a/lib/sisu/v3dv/epub_concordance.rb b/lib/sisu/v3dv/epub_concordance.rb index 40dd83f5..e2e5bb5c 100644 --- a/lib/sisu/v3dv/epub_concordance.rb +++ b/lib/sisu/v3dv/epub_concordance.rb @@ -206,7 +206,10 @@ WOK @word_map={} @dal_array.each do |line| if defined? line.ocn - if line.is =~/heading/ and line.ln==4; @seg=line.name + if (line.is ==:heading \ + || line.is ==:heading_insert) \ + && line.ln==4 + @seg=line.name end if line.ocn.to_s =~/\d+/; toy=line.ocn.to_s end diff --git a/lib/sisu/v3dv/epub_format.rb b/lib/sisu/v3dv/epub_format.rb index 344e4e7e..f88b6745 100644 --- a/lib/sisu/v3dv/epub_format.rb +++ b/lib/sisu/v3dv/epub_format.rb @@ -1901,7 +1901,7 @@ WOK @named=nametags_seg(@dob) @txt=((defined? t_o.obj) ? t_o.obj : nil) @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil) - @headname=((t_o.is=='heading' and defined? t_o.name) ? t_o.name : nil) + @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil) else if @md.opt.cmd =~/M/ p __FILE__ +':'+ __LINE__.to_s diff --git a/lib/sisu/v3dv/epub_segments.rb b/lib/sisu/v3dv/epub_segments.rb index a9747cd5..55c6c1f9 100644 --- a/lib/sisu/v3dv/epub_segments.rb +++ b/lib/sisu/v3dv/epub_segments.rb @@ -157,8 +157,8 @@ WOK @@seg[:heading_idx]='' end data.each do |dob| - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 @@seg_name << dob.name seg_name=dob.name @@ -183,8 +183,8 @@ WOK # # end # #end #end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 if dob.ocn==0 @@heading4=dob.obj @@ -192,27 +192,27 @@ WOK end @@is4=newfile=1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==3 @@heading3=dob.obj @@is4,@@is3=0,1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==2 @@heading2=dob.obj @@is4,@@is3,@@is2=0,0,1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==1 @@heading1=dob.obj @@is4,@@is3,@@is2,@@is1=0,0,0,1 end if (@@is1 && !@@is2 && !@@is3 && !@@is4) - if not (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if not (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==1 head1=$_ #; check end @@ -222,17 +222,17 @@ WOK if newfile==1 \ or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 if tracking != 0 SiSU_EPUB_Seg::Seg.new(@md).tail segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking-1]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') if @@seg_name_xhtml[tracking-1] - if dob.is=='heading' \ + if dob.is==:heading \ or @@seg_name_xhtml[tracking-1] !~/endnotes|book_index|metadata/ SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc).output - elsif dob.is=='heading_insert' + elsif dob.is==:heading_insert if @@seg_name_xhtml[tracking-1]=='endnotes' SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'endnotes').output elsif @@seg_name_xhtml[tracking-1]=='book_index' @@ -262,8 +262,8 @@ WOK end tracking=tracking+1 end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 \ and dob.name @@get_hash_to=dob.name @@ -341,23 +341,25 @@ WOK end def markup(dob) @debug=[] - format_head_seg=SiSU_EPUB_Format::HeadSeg.new(@md) - if dob.is =~/(?:heading|para)/ #extend as necessary FIX + if dob.is ==:heading \ + || dob.is ==:heading_insert \ + || dob.is ==:para + #extend as necessary FIX @p_num=SiSU_EPUB_Format::ParagraphNumber.new(@md,dob.ocn) end sto=SiSU_EPUB_Format::FormatTextObject.new(@md,dob) - dob_xhtml=if dob.is=='heading' \ - or dob.is=='heading_insert' \ - or dob.is=='para' - dob_xhtml=if dob.is=='heading' \ - or dob.is=='heading_insert' + dob_xhtml=if dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para + dob_xhtml=if dob.is==:heading \ + or dob.is==:heading_insert if dob.ln==4 sto.seg_heading4 # work on see SplitTextObject elsif dob.ln==5 sto.seg_heading5 elsif dob.ln==6; sto.seg_heading6 end - elsif dob.is=='para' + elsif dob.is==:para if dob.indent \ and dob.hang \ and dob.indent =~/[0-9]/ \ @@ -375,33 +377,37 @@ WOK else sto.para end end - elsif dob.is =~/^(?:block|group|alt)$/ + elsif dob.is ==:block \ + || dob.is ==:group \ + || dob.is ==:alt sto.para #fix this should be block type specific #FIX - elsif dob.is=='verse' + elsif dob.is==:verse sto.verse - elsif dob.is=='code' + elsif dob.is==:code sto.code - elsif dob.is=='table' + elsif dob.is==:table sto.table - elsif dob.is=='break' + elsif dob.is==:break sto.break end if @md.flag_separate_endnotes # may need to revisit, check dob.obj=dob.obj.gsub(/"\s+href="#note_ref(\d+)">/,%{" href=\"endnotes#{Sfx[:epub_xhtml]}#note_ref\\1">}) #endnote- twice #removed file type end - if dob.is =~/heading|para/ \ - and (not dob.ocn or dob.ocn.to_s.empty?) + if (dob.is ==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para) \ + && (not dob.ocn or dob.ocn.to_s.empty?) format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) end - if (dob.is=='heading' \ - || dob.is=='heading_insert' \ - || dob.is=='para') \ + if (dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is==:para) \ and dob.note_ #dob.obj =~/<a href="#note_ref\d+"> <sup id=/ #endnote- note- format_seg=SiSU_EPUB_Format::FormatSeg.new(@md,dob) dob.obj=format_seg.no_paranum end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 @@seg[:main] << %{\n<div class="content">\n} @@seg[:main] << dob_xhtml @@ -439,8 +445,8 @@ WOK data.each do |dob| dob.obj=dob.obj.gsub(/<a name=\"h\d.*?\">(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln.to_s =~/^[1234]/ \ and not @@fn.to_s.empty? @@seg_endnotes[@@fn]=[] @@ -448,8 +454,8 @@ WOK @@seg_endnotes_array=[] if dob.ln==4 @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/ end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ and dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs @@seg_subtoc[@@fn]=@@seg_subtoc_array @@seg_subtoc_array=[] @@ -463,7 +469,7 @@ WOK end end end - if dob.is=='heading' \ + if dob.is==:heading \ and dob.ln.to_s =~/^[56]/ case dob.ln when 5 @@ -478,7 +484,7 @@ WOK if @md.flag_auto_endnotes ast,pls='*','+' if dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(?:\d|#{ast}|#{pls})+ / \ - and dob.is !~/^code/ # endnote- + and dob.is !=:code # endnote- endnote_array=[] if dob.obj=~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m endnote_array << dob.obj.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m) diff --git a/lib/sisu/v3dv/epub_tune.rb b/lib/sisu/v3dv/epub_tune.rb index dfb19caf..34466926 100644 --- a/lib/sisu/v3dv/epub_tune.rb +++ b/lib/sisu/v3dv/epub_tune.rb @@ -225,7 +225,7 @@ module SiSU_EPUB_Tune @data.each do |dob| dob.obj=dob.obj.gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') - dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') unless dob.is==:table dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). @@ -309,7 +309,7 @@ module SiSU_EPUB_Tune data=@data @tuned_file=[] data.each do |dob| - unless dob.is=='code' + unless dob.is==:code if dob.obj =~/<::\s+/ #watch dob.obj=dob.obj.gsub(/<::\s+(\S+?)\s+!>/, %{<img src="#{@env.url.images_epub}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0" />}) @@ -369,7 +369,7 @@ module SiSU_EPUB_Tune a,s='_a','_s' ast,pls='*','+' data.each do |dob| - unless dob.is =~/^code/ + unless dob.is ==:code dob.obj=dob.obj.gsub(/(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(\d+)\s+(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/, %{#{Mx[:nbsp]}<a href="#note\\2">#{Mx[:nbsp]}<sup id="note_ref\\2">\\2</sup>#{Mx[:nbsp]}</a> } + #note- endnote- %{\\1\\2 <a href="#note_ref\\2">#{Mx[:nbsp]}<sup id="note\\2">\\2.</sup></a> \\3 \\4}). #endnote- note- (careful may have switched) diff --git a/lib/sisu/v3dv/html.rb b/lib/sisu/v3dv/html.rb index 5141c14b..ec7b0573 100644 --- a/lib/sisu/v3dv/html.rb +++ b/lib/sisu/v3dv/html.rb @@ -195,7 +195,7 @@ module SiSU_HTML format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) @data.each do |dob| pg=dob.dup - unless pg.is =~/^code/ + unless pg.is ==:code if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / endnote_array=[] if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m @@ -233,11 +233,11 @@ module SiSU_HTML @@firstseg=nil @@toc={ seg: [], seg_mini: [], scr: [] } @data.each do |dob| - if dob.is=='heading' \ - or dob.is=='heading_insert' + if dob.is==:heading \ + || dob.is==:heading_insert dob_toc=dob.dup - toc=if dob_toc.is =='heading' \ - or dob.is=='heading_insert' + toc=if dob_toc.is ==:heading \ + || dob.is==:heading_insert toc=case dob_toc.ln when 1; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_1 when 2; SiSU_HTML::Source::Toc.new(@md,dob_toc).level_2 diff --git a/lib/sisu/v3dv/html_format.rb b/lib/sisu/v3dv/html_format.rb index 7195fedb..29d1bfcb 100644 --- a/lib/sisu/v3dv/html_format.rb +++ b/lib/sisu/v3dv/html_format.rb @@ -921,7 +921,7 @@ WOK @named=nametags_seg(@dob) @txt=((defined? t_o.obj) ? t_o.obj : nil) @ocn=((defined? t_o.ocn) ? t_o.ocn.to_s : nil) - @headname=((t_o.is=='heading' and defined? t_o.name) ? t_o.name : nil) + @headname=((t_o.is==:heading and defined? t_o.name) ? t_o.name : nil) else if @md.opt.cmd =~/M/ p t_o.class @@ -956,9 +956,9 @@ WOK tags end def headname #check whether used - hn=if @t_o.is =='heading' \ + hn=if @t_o.is ==:heading \ and not @t_o.name.empty? #determine use - hn=if @t_o.is =='heading'; %{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>} + hn=if @t_o.is ==:heading; %{<a name="h#{@t_o.name}" id="h#{@t_o.name}"></a>} else %{<a name="#{@t_o.name}" id="#{@t_o.name}"></a>} end else nil diff --git a/lib/sisu/v3dv/html_minitoc.rb b/lib/sisu/v3dv/html_minitoc.rb index d70fa7e1..729eee50 100644 --- a/lib/sisu/v3dv/html_minitoc.rb +++ b/lib/sisu/v3dv/html_minitoc.rb @@ -74,7 +74,8 @@ toc=nil @toc=[] @data.each do |txt| - if (txt.is =='heading' or txt.is =='heading_insert') + if txt.is ==:heading \ + || txt.is ==:heading_insert txt.obj=txt.obj.gsub(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,''). #remove endnotes from toc gsub(/<a name="-\d+" href="#_\d+"> <sup>\d+<\/sup> <\/a>/,''). gsub(@pat_strip_heading_name,'\1') @@ -108,8 +109,9 @@ end def level_1 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end title=unless txt.obj =~/Document Information/; txt.obj @@ -128,8 +130,9 @@ end def level_2 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end txt_obj={ txt: txt.obj } @@ -165,8 +168,9 @@ end def level_5 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end toc={} @@ -180,8 +184,9 @@ end def level_6 txt=@data - if (txt.is =='heading' or txt.is =='heading_insert') \ - and txt.ocn !=0 + if (txt.is ==:heading \ + || txt.is ==:heading_insert) \ + && txt.ocn !=0 txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1') end toc={} diff --git a/lib/sisu/v3dv/html_scroll.rb b/lib/sisu/v3dv/html_scroll.rb index 89f88b04..a4d2089e 100644 --- a/lib/sisu/v3dv/html_scroll.rb +++ b/lib/sisu/v3dv/html_scroll.rb @@ -100,13 +100,14 @@ module SiSU_HTML_Scroll gsub(/href="#{Xx[:segment]}/m,'href="'). gsub(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>') if dob.obj !~/(^#{Rx[:meta]}|#{Mx[:br_eof]})/ - unless dob.is =~/^code/; dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') + unless dob.is ==:code + dob.obj=dob.obj.gsub(/(?:#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})\s*/m,' ') end if defined? dob.ocn @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) end sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) - para_html=if dob.is=='heading' + para_html=if dob.is==:heading x=if dob.ln==1 sto.heading_body1 elsif dob.ln==2 @@ -120,7 +121,7 @@ module SiSU_HTML_Scroll elsif dob.ln==6 sto.heading_body6 end - elsif dob.is=='heading_insert' + elsif dob.is==:heading_insert x=if dob.ln==1 sto.heading_body1 elsif dob.ln==2 @@ -152,7 +153,7 @@ module SiSU_HTML_Scroll elsif dob.ln==6 sto.heading_body6 end - elsif dob.is=='para' + elsif dob.is==:para if dob.indent \ and dob.hang \ and dob.indent =~/[0-9]/ \ @@ -171,19 +172,19 @@ module SiSU_HTML_Scroll end else sto.para end - elsif dob.is=='block' + elsif dob.is==:block sto.block - elsif dob.is=='group' + elsif dob.is==:group sto.group - elsif dob.is=='alt' + elsif dob.is==:alt sto.alt - elsif dob.is=='verse' + elsif dob.is==:verse sto.verse - elsif dob.is=='code' + elsif dob.is==:code sto.code - elsif dob.is=='table' + elsif dob.is==:table sto.table - elsif dob.is=='break' + elsif dob.is==:break sto.break end if dob =~/<a name="n\d+">/ \ diff --git a/lib/sisu/v3dv/html_segments.rb b/lib/sisu/v3dv/html_segments.rb index ba825ae4..eca87b12 100644 --- a/lib/sisu/v3dv/html_segments.rb +++ b/lib/sisu/v3dv/html_segments.rb @@ -167,8 +167,9 @@ module SiSU_HTML_Seg @@seg[:heading_idx]='' end data.each do |dob| - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is == :heading \ + || dob.is == :heading_insert) \ + && dob.ln == 4 @@seg_name << dob.name seg_name=dob.name end @@ -192,32 +193,37 @@ module SiSU_HTML_Seg end end end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 if dob.ocn==0 @@heading4=dob.obj else @@heading4=dob.obj end @@is4=newfile=1 end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==3 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==3 @@heading3=dob.obj @@is4,@@is3=0,1 end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==2 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==2 @@heading2=dob.obj @@is4,@@is3,@@is2=0,0,1 end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==1 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==1 @@heading1=dob.obj @@is4,@@is3,@@is2,@@is1=0,0,0,1 end if (@@is1 && !@@is2 && !@@is3 && !@@is4) - if not (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==1 + if not (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==1 head1=$_ #; check end end @@ -225,8 +231,9 @@ module SiSU_HTML_Seg if newfile==1 \ or dob.obj =~/^#{Mx[:br_endnotes]}|^#{Mx[:br_eof]}/ newfile=0 - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 if tracking != 0 dirout=SiSU_Env::InfoEnv.new(@md.fns) dir_sisu=dirout.path.output @@ -240,10 +247,10 @@ module SiSU_HTML_Seg minitoc=(@env.html_minitoc?) \ ? @minitoc : '' - if dob.is=='heading' \ - or @@seg_name_html[tracking-1] !~/endnotes|book_index|metadata/ + if dob.is==:heading \ + || (@@seg_name_html[tracking-1] !~/endnotes|book_index|metadata/) SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc).output - elsif dob.is=='heading_insert' + elsif dob.is==:heading_insert if @@seg_name_html[tracking-1]=='endnotes' SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'endnotes').output elsif @@seg_name_html[tracking-1]=='book_index' @@ -273,8 +280,13 @@ module SiSU_HTML_Seg end tracking=tracking+1 end - @@get_hash_to=dob.name if (dob.is=='heading' or dob.is=='heading_insert') and dob.ln==4 and dob.name - @@get_hash_fn=dob.name if (dob.is=='heading' or dob.is=='heading_insert') and dob.ln==4 and dob.name + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 \ + && dob.name + @@get_hash_to=dob.name + @@get_hash_fn=dob.name + end if dob.obj.class==String markup(dob) elsif dob.obj.class==Array @@ -293,8 +305,9 @@ module SiSU_HTML_Seg end def heading_art(dob) format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln.to_s =~/^[1-6]/ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && (dob.ln.to_s =~/^[1-6]/) if @@tracker < @@seg_total-1; @@seg[:dot_nav]=format_head_seg.dot_control_pre_next else @@seg[:dot_nav]=format_head_seg.dot_control_pre end @@ -370,14 +383,18 @@ module SiSU_HTML_Seg def markup(dob) @debug=[] format_head_seg=SiSU_HTML_Format::HeadSeg.new(@md) - if dob.is !~/meta/ |