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/concordance.rb | 5 +- lib/sisu/v3dv/constants.rb | 4 +- lib/sisu/v3dv/dal.rb | 16 ++--- lib/sisu/v3dv/dal_character_check.rb | 4 +- lib/sisu/v3dv/dal_doc_objects.rb | 54 ++++++++-------- lib/sisu/v3dv/dal_doc_str.rb | 56 ++++++++++------- lib/sisu/v3dv/dal_endnotes.rb | 6 +- lib/sisu/v3dv/dal_hash_digest.rb | 8 ++- lib/sisu/v3dv/dal_idx.rb | 5 +- lib/sisu/v3dv/dal_images.rb | 2 +- lib/sisu/v3dv/dal_numbering.rb | 40 +++++++----- lib/sisu/v3dv/dal_syntax.rb | 38 ++++++++--- lib/sisu/v3dv/db_import.rb | 34 ++++++---- lib/sisu/v3dv/db_select.rb | 1 + lib/sisu/v3dv/digests.rb | 8 +-- lib/sisu/v3dv/epub.rb | 6 +- lib/sisu/v3dv/epub_concordance.rb | 5 +- lib/sisu/v3dv/epub_format.rb | 2 +- lib/sisu/v3dv/epub_segments.rb | 94 ++++++++++++++------------- lib/sisu/v3dv/epub_tune.rb | 6 +- lib/sisu/v3dv/html.rb | 10 +-- lib/sisu/v3dv/html_format.rb | 6 +- lib/sisu/v3dv/html_minitoc.rb | 23 ++++--- lib/sisu/v3dv/html_scroll.rb | 23 +++---- lib/sisu/v3dv/html_segments.rb | 115 +++++++++++++++++++-------------- lib/sisu/v3dv/html_tune.rb | 6 +- lib/sisu/v3dv/hub.rb | 4 +- lib/sisu/v3dv/manpage.rb | 22 +++---- lib/sisu/v3dv/odf.rb | 42 +++++++------ lib/sisu/v3dv/plaintext.rb | 30 ++++----- lib/sisu/v3dv/po4a.rb | 56 ++++++++--------- lib/sisu/v3dv/shared_html_lite.rb | 6 +- lib/sisu/v3dv/shared_markup_alt.rb | 28 +++++---- lib/sisu/v3dv/shared_xml.rb | 8 +-- lib/sisu/v3dv/texinfo.rb | 119 ++++++++++++++++++++--------------- lib/sisu/v3dv/texinfo_format.rb | 4 +- lib/sisu/v3dv/texpdf.rb | 66 ++++++++++--------- lib/sisu/v3dv/texpdf_format.rb | 24 +++---- lib/sisu/v3dv/xhtml.rb | 23 +++---- lib/sisu/v3dv/xml.rb | 22 +++---- lib/sisu/v3dv/xml_dom.rb | 26 ++++---- lib/sisu/v3dv/xml_format.rb | 2 +- lib/sisu/v3dv/xml_scaffold.rb | 6 +- 43 files changed, 596 insertions(+), 469 deletions(-) (limited to 'lib') 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 --> 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>|
)/,"#{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

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 =~/ \n} @@seg[:main] << dob_xhtml @@ -439,8 +445,8 @@ WOK data.each do |dob| dob.obj=dob.obj.gsub(/(.+?)<\/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]}/,'
') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). @@ -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+!>/, %{\\1}) @@ -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]}
#{Mx[:nbsp]}\\2#{Mx[:nbsp]} } + #note- endnote- %{\\1\\2 #{Mx[:nbsp]}\\2. \\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'; %{} + hn=if @t_o.is ==:heading; %{} else %{} 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(/ \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,'


') 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 =~/
/ \ 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/ - if dob.is =~/(?:heading|para)/ #extend as necessary FIX + if dob.is !=:meta + if dob.is==:heading \ + || dob.is==:heading_insert \ + || dob.is == :para @p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,dob.ocn) end sto=SiSU_HTML_Format::FormatTextObject.new(@md,dob) - dob_html=if dob.is =~/heading|para/ - dob_html=if (dob.is=='heading' \ - or dob.is=='heading_insert') + dob_html=if dob.is == :heading \ + || dob.is==:heading_insert \ + || dob.is==:para + dob_html=if dob.is==:heading \ + || dob.is==:heading_insert x=if dob.ln==4 sto.seg_heading4 elsif dob.ln==5 @@ -385,7 +402,7 @@ module SiSU_HTML_Seg 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]/ \ @@ -405,26 +422,30 @@ module SiSU_HTML_Seg else sto.para end 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 @md.flag_separate_endnotes dob.obj=dob.obj.gsub(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">}) #endnote- twice #removed file type end if dob.obj !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/ - 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 \ + || (dob.ocn.to_s.empty?)) format_seg=SiSU_HTML_Format::FormatSeg.new(@md,dob) end dob.obj=dob.obj.gsub(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint @@ -433,9 +454,9 @@ module SiSU_HTML_Seg dob=format_seg.no_paranum end end - if (dob.is=='heading' \ - || dob.is=='heading_insert') \ - and dob.ln==4 + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 @@seg[:main] << %{\n
\n} @@seg[:main] << dob_html @@seg[:main] << @@seg_subtoc[@@get_hash_fn] #% insertion of sub-toc @@ -473,16 +494,18 @@ module SiSU_HTML_Seg data.each do |dob| dob.obj=dob.obj.gsub(/(.+?)<\/a>/mi,'\1') if @md.flag_auto_endnotes - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln.to_s =~/^[1234]/ \ + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && (dob.ln.to_s =~/^[1234]/) \ and not @@fn.to_s.empty? @@seg_endnotes[@@fn]=[] @@seg_endnotes[@@fn] << @@seg_endnotes_array @@seg_endnotes_array=[] if dob.ln==4 @@fns_previous=@md.fns if dob.ln==4 and dob.name =~/^meta/ end - if (dob.is=='heading' or dob.is=='heading_insert') \ - and dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs + if (dob.is==:heading \ + || dob.is==:heading_insert) \ + && dob.ln==4 #% EXTRACTION OF SUB-TOCs & SEGMENT NAME, after EXTRACTION OF ENDNOTES & SUB-TOCs @@seg_subtoc[@@fn]=@@seg_subtoc_array @@seg_subtoc_array=[] if dob.name \ @@ -496,8 +519,8 @@ module SiSU_HTML_Seg end end end - if dob.is=='heading' \ - and dob.ln.to_s =~/^[56]/ + if dob.is==:heading \ + && (dob.ln.to_s =~/^[56]/) case dob.ln when 5 txt_obj={ txt: dob.obj.strip, ocn: dob.ocn } @@ -511,8 +534,8 @@ module SiSU_HTML_Seg @@seg_subtoc_array << subtoc end if @md.flag_auto_endnotes - if dob.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+  \2  ' + #note- endnote- '\1\2  \2. \3 \4'). #endnote- note- (careful may have switched) @@ -341,7 +341,7 @@ module SiSU_HTML_Tune def markup(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]}/,'
') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). diff --git a/lib/sisu/v3dv/hub.rb b/lib/sisu/v3dv/hub.rb index c2477267..4924297a 100644 --- a/lib/sisu/v3dv/hub.rb +++ b/lib/sisu/v3dv/hub.rb @@ -364,8 +364,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX flag=SiSU_Env::InfoProcessingFlag.new if @opt.cmd =~/[vVM]/ #% version information - if @opt.cmd =~/V/ \ - and @opt.files.empty? #% environment + if (@opt.cmd =~/V/) \ + && (@opt.files.empty?) #% environment SiSU_Help::Help.new('env',@opt).environment else SiSU_Help::Help.new('env',@opt).sisu_version end diff --git a/lib/sisu/v3dv/manpage.rb b/lib/sisu/v3dv/manpage.rb index dd681967..0571a0e6 100644 --- a/lib/sisu/v3dv/manpage.rb +++ b/lib/sisu/v3dv/manpage.rb @@ -192,16 +192,16 @@ at: <#{vz.url_site}> WOK end def manpage_structure(dob='',hname='') #% Used to extract the structure of a document - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 else lv=nil end - wrapped=if dob.is=='para' \ - or dob.is=='heading' + wrapped=if dob.is==:para \ + || dob.is==:heading paragraph=dob.obj - if dob.is=='para' + if dob.is==:para if dob.indent =~/[1-9]/ \ and dob.indent == dob.hang util=if dob.bullet_ @@ -259,8 +259,8 @@ WOK fix=[] manpage_metadata data.each do |dob| - if dob.is=='comment' \ - or dob.is=='heading_insert' + if dob.is==:comment \ + || dob.is==:heading_insert dob.obj='' end dob.obj=dob.obj.gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check @@ -275,7 +275,7 @@ WOK gsub(/\A\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?#{Mx[:br_line]}/m,"#{Mx[:br_line]}.BI \\1\\2#{Mx[:br_line]}"). gsub(/\s*#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.B \\1\\2#{Mx[:br_line]}"). gsub(/\s*#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}([,.:!?](?: |$))?/,"#{Mx[:br_line]}.I \\1\\2#{Mx[:br_line]}") - unless dob.is=='code' + unless dob.is==:code dob.obj=dob.obj.gsub(/(?:^|\s)#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1 #{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3"). gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}([,.:!?](?: |$))?/,"\\1#{@brace_url.txt_open}\\2#{@brace_url.txt_close}\\3") @manpage[:endnotes]=extract_endnotes(dob.obj) @@ -305,7 +305,7 @@ WOK gsub(/-/,'\-') #manpages use this dob.obj=dob.obj.gsub(/~/,'~') if dob.obj #manpages use this if dob.is =~/block|group|verse|alt|code/ - if dob.is =='code' + if dob.is ==:code dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< gsub(/(^|[^}])_([<>])/m,'\1\2'). # _<_< gsub(/\A(.+)?\Z/m,".nf\n\n\\1\n\n.fi") @@ -340,7 +340,7 @@ WOK @p_num=SiSU_ManpageFormat::ParagraphNumber.new(paranum) end x=SiSU_ManpageFormat::FormatTextObject.new(@md,dob) - if dob.is=='heading' + if dob.is==:heading manpage_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -350,7 +350,7 @@ WOK when 5; x.heading_body5 when 6; x.heading_body6 end - elsif dob.is=='para' + elsif dob.is==:para manpage_structure(dob) else if dob.obj =~/#{table_message}/ @@ -367,7 +367,7 @@ WOK gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'). gsub(/#{Mx[:pa_o]}\S+#{Mx[:pa_c]}/,' ') - unless dob.is =='code' + unless dob.is ==:code dob.obj=dob.obj.gsub(//,' '). gsub(/<:\S+>/,' ') end diff --git a/lib/sisu/v3dv/odf.rb b/lib/sisu/v3dv/odf.rb index 1b928548..68aa6e40 100644 --- a/lib/sisu/v3dv/odf.rb +++ b/lib/sisu/v3dv/odf.rb @@ -305,11 +305,11 @@ module SiSU_ODF %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}). gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj= if dob.is=='para' \ + dob.obj= if dob.is==:para \ and dob.indent.to_s =~/[0-9]/ \ and dob.indent == dob.hang %{#{dob.obj}#{p_num}} - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang %{#{dob.obj}#{p_num}} @@ -432,7 +432,7 @@ module SiSU_ODF dob end def code(dob,p_num) #P5 - if dob.is=='code' + if dob.is==:code dob.obj=dob.obj.gsub(/\s\s/,'  ') parray=[] dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| @@ -449,14 +449,14 @@ module SiSU_ODF dob end def table(dob,p_num) # - if dob.is =='table' + if dob.is ==:table table=SiSU_ODF_Format::Table.new(@md,dob,p_num) dob=table.table end dob end def obj_break(dob) - if dob.is =='break' + if dob.is ==:break br=SiSU_ODF_Format::FormatObjBreak.new(@md,dob) if dob.obj==Mx[:br_page] \ or dob.obj==Mx[:br_page_new] @@ -469,7 +469,7 @@ module SiSU_ODF end def odf_structure(md,dob) @md,@dob=md,dob - dob=if dob.is !='code' + dob=if dob.is !=:code dob=image(dob) if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ dob=text_link(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ dob=text_link_relative(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ @@ -486,19 +486,19 @@ module SiSU_ODF end end dob=footnote(dob) - if dob.is=='heading' + if dob.is==:heading @@odf[:body] << heading(dob,p_num).obj << @br*2 - elsif dob.is =='verse' + elsif dob.is ==:verse @@odf[:body] << poem(dob,p_num).obj << @br*2 - elsif dob.is=='group' + elsif dob.is==:group @@odf[:body] << group(dob,p_num).obj << @br*2 - elsif dob.is=='block' + elsif dob.is==:block @@odf[:body] << block(dob,p_num).obj << @br*2 - elsif dob.is=='code' + elsif dob.is==:code @@odf[:body] << code(dob,p_num).obj << @br*2 - elsif dob.is=='table' #elsif dob.obj =~ /|>)/m,'\1>'). gsub(/(^|[^}])_(?:<|<)/m,'\1<').gsub(/(^|[^}])_(?:>|>)/m,'\1>') end - if dob.of=='block' + if dob.of==:block dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ') end dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). @@ -560,7 +560,7 @@ module SiSU_ODF gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;'). gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;'). gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'') - if dob.is=='para' \ + if dob.is==:para \ and dob.bullet_ dob.obj=' ' + dob.obj @@ -595,11 +595,17 @@ module SiSU_ODF dob.obj=tidywords(wordlist).join(' ').strip @rcdc=true if @rcdc==false \ and (dob.obj =~/~metadata/ or dob =~/#{Mx[:lv_o]}1:meta#{Mx[:lv_x]}\s*Document Information/) #fix Mx[:lv_o] - if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ + if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check if defined? dob.ocn and dob.ocn =~/\d+/ @p_num=SiSU_ODF_Format::ParagraphNumber.new(dob.ocn) end - if dob.is=~/heading|para|group|verse|code|table|break/ # extend, include other types + if dob.is ==:heading \ + || dob.is ==:para \ + || dob.is ==:group \ + || dob.is ==:verse \ + || dob.is ==:code \ + || dob.is ==:table \ + || dob.is ==:break odf_structure(@md,dob) end if dob.obj ## Clean Prepared Text diff --git a/lib/sisu/v3dv/plaintext.rb b/lib/sisu/v3dv/plaintext.rb index ba1f30d2..557c5f1b 100644 --- a/lib/sisu/v3dv/plaintext.rb +++ b/lib/sisu/v3dv/plaintext.rb @@ -216,15 +216,15 @@ WOK end def plaintext_structure(dob='',p_num='') #% Used to extract the structure of a document lv=n=n3=nil - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=lv - 1 n3=lv + 2 end util=nil - wrapped=if dob.is =='para' \ - or dob.is=='heading' - if dob.is=='para' + wrapped=if dob.is ==:para \ + or dob.is==:heading + if dob.is==:para if dob.hang \ and dob.hang =~/[0-9]/ \ and dob.indent != dob.hang @@ -299,7 +299,7 @@ WOK "#{Px[:strike_o]}\\1#{Px[:strike_c]}"). gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, "#{Px[:monospace_o]}\\1#{Px[:monospace_c]}") - unless dob.is=='code' + unless dob.is==:code dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). @@ -323,12 +323,12 @@ WOK gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©'). gsub(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'\\') end - dob.obj=if dob.of=='block' # watch + dob.obj=if dob.of==:block # watch dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* "). gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") end - if dob.is=='code' + if dob.is==:code dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< end @@ -352,16 +352,16 @@ WOK p_num=SiSU_PlaintextFormat::ParagraphNumber.new(dob.ocn).display end end - if dob.is=='heading' \ - or dob.is=='para' + if dob.is==:heading \ + or dob.is==:para plaintext_structure(dob,p_num) - elsif dob.is=='group' \ - or dob.is=='block' \ - or dob.is=='verse' \ - or dob.is=='code' \ - or dob.is=='table' + elsif dob.is==:group \ + or dob.is==:block \ + or dob.is==:verse \ + or dob.is==:code \ + or dob.is==:table @plaintext[:body] << dob.obj + p_num << @br - elsif dob.is=='break' + elsif dob.is==:break sp=' ' ln='-' @plaintext[:body] <<=if dob.obj==Mx[:br_page] \ diff --git a/lib/sisu/v3dv/po4a.rb b/lib/sisu/v3dv/po4a.rb index 945b07b8..adb977c2 100644 --- a/lib/sisu/v3dv/po4a.rb +++ b/lib/sisu/v3dv/po4a.rb @@ -509,7 +509,7 @@ GSUB util=nil fn=(dob_src.name=~/[a-z\d]/i) ? dob_src.name : '' mark="#{dob_src.lv}~#{fn} " - d="#{dob_src.is} (level #{dob_src.lv})" + d="#{dob_src.is.to_s} (level #{dob_src.lv})" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for headings is marker at the start of the line/object, indicating the heading level, and if provided an associated name tag, this heading is "#{mark}"} @@ -538,7 +538,7 @@ GSUB s_mark=desc=orig=trans='' if dob_src.bullet_ mark="_#{dob_src.indent}* " - d="#{dob_src.is}: indent #{dob_src.indent}, bullet" + d="#{dob_src.is.to_s}: indent #{dob_src.indent}, bullet" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented bullet text is at the start of the line/object, an underscore followed by the indent level and an asterisk "#{mark}"} @@ -547,7 +547,7 @@ GSUB desc="#{d}#{s_mark}#{instruct}" else mark="_#{dob_src.indent} " - d="#{dob_src.is}: indent #{dob_src.indent}" + d="#{dob_src.is.to_s}: indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by the indent level "#{mark}"} @@ -562,7 +562,7 @@ GSUB and dob_src.indent != dob_src.hang s_mark=desc=orig=trans='' mark="_#{dob_src.hang}_#{dob_src.indent} " - d="#{dob_src.is}: hang #{dob_src.hang} indent #{dob_src.indent}" + d="#{dob_src.is.to_s}: hang #{dob_src.hang} indent #{dob_src.indent}" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented text with a first line indented to a different level from the rest of the paragraph, is at the start of the line/object, an underscore and the first indent level a second underscore and the indent level for the rest of the paragraph, "#{mark1}"} @@ -576,7 +576,7 @@ GSUB s_mark=desc=orig=trans='' if dob_src.bullet_ mark='_* ' - d="#{dob_src.is}: bullet" + d="#{dob_src.is.to_s}: bullet" instruct=s_mark='' if @md.opt.cmd=~/M/ instruct=%{\n# markup for indented text is at the start of the line/object, an underscore followed by an asterisk "#{mark}"} @@ -587,7 +587,7 @@ GSUB trans=(dob_trn=='') ? '' : "#{s_mark}#{dob_trn.obj}" else mark='' - d=dob_src.is + d=dob_src.is.to_s instruct=%{\n# regular paragraph, no special markup} if @md.opt.cmd=~/M/ instruct="\n# " @@ -613,7 +613,7 @@ GSUB end def pot_structure_block(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="block{\\n\\n...\\n\\n}block" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# block text is a text block with an opening and closing marker, the content of which may be wrapped" @@ -628,7 +628,7 @@ GSUB end def pot_structure_group(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="group{\\n\\n...\\n\\n}group" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# group text is a text block with an opening and closing marker, the content of which may be wrapped" @@ -643,7 +643,7 @@ GSUB end def pot_structure_verse(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="poem{\n\nverse\n\nverse\n\n...\n\n}poem" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# verse are part of the text block described as a poem, the first verse is preceeded by an opening marker, and the last verse by a closing marker, the content of which should remain unwrapped" @@ -658,7 +658,7 @@ GSUB end def pot_structure_code(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="code{\\n\\n...\\n\\n}code" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# codeblocks are a text block with an opening and closing marker, the content of which should remain unwrapped" @@ -673,7 +673,7 @@ GSUB end def pot_structure_table(dob_src='',notes_s='',dob_trn='',notes_t='') #% Used to extract the structure of a document mark="table{\\n\\n...\\n\\n}table" - d=dob_src.is + d=dob_src.is.to_s instruct=s_mark='' if @md.opt.cmd=~/M/ instruct="\n# tables are a text block with an opening and closing marker, the content of which should remain unwrapped" @@ -729,22 +729,22 @@ GSUB and data_trn[t] break end - if data_src[s].of == 'comment' \ - and data_trn[t].of == 'comment' \ + if data_src[s].of == :comment \ + and data_trn[t].of == :comment \ and (data_src[s].is == data_trn[t].is) s+=1;t+=1 next end - if (data_src[s].is == 'comment' or data_trn[t].is == 'comment') \ + if (data_src[s].is == :comment or data_trn[t].is == :comment) \ and (data_src[s].is != data_trn[t].is) - if data_src[s].is == 'comment' + if data_src[s].is == :comment puts "src (comment):\n\t" + data_src[s].obj if @md.opt.cmd =~/M/ s+=1 - #next if data_src[s].is == 'comment' - elsif data_trn[t].is == 'comment' + #next if data_src[s].is == :comment + elsif data_trn[t].is == :comment puts "trans (comment):\n\t" + data_trn[t].obj if @md.opt.cmd =~/M/ t+=1 - #next if data_trn[t].is == 'comment' + #next if data_trn[t].is == :comment end end if (defined? data_src[s].ocn and data_src[s].ocn.class == Fixnum) \ @@ -814,13 +814,13 @@ GSUB @p_num=SiSU_Po4aUtils::ParagraphNumber.new(paranum) end case dob_src.is - when 'heading'; pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) - when 'para'; pot_structure_para(dob_src,notes_s,dob_trn,notes_t) - when 'group'; pot_structure_group(dob_src,notes_s,dob_trn,notes_t) - when 'block'; pot_structure_block(dob_src,notes_s,dob_trn,notes_t) - when 'verse'; pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) - when 'code'; pot_structure_code(dob_src,notes_s,dob_trn,notes_t) - when 'table'; pot_structure_table(dob_src,notes_s,dob_trn,notes_t) + when :heading; pot_structure_heading(dob_src,notes_s,dob_trn,notes_t) + when :para; pot_structure_para(dob_src,notes_s,dob_trn,notes_t) + when :group; pot_structure_group(dob_src,notes_s,dob_trn,notes_t) + when :block; pot_structure_block(dob_src,notes_s,dob_trn,notes_t) + when :verse; pot_structure_verse(dob_src,notes_s,dob_trn,notes_t) + when :code; pot_structure_code(dob_src,notes_s,dob_trn,notes_t) + when :table; pot_structure_table(dob_src,notes_s,dob_trn,notes_t) end if defined? dob_src.idx \ and not dob_src.idx.nil? \ @@ -858,7 +858,7 @@ GSUB gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/, "#{Px[:po_monospace_o]}\\1#{Px[:po_monospace_c]}") notes='' - unless dob.is=='code' + unless dob.is==:code dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,'\1'). gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'\1'). gsub(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1 [link: <\2>]'). @@ -887,12 +887,12 @@ GSUB gsub(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~'). gsub(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'©') end - dob.obj=if dob.of=='block' # watch + dob.obj=if dob.of==:block # watch dob.obj.gsub(/#{Mx[:gl_o]}●#{Mx[:gl_c]}/,"* "). gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n") else dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,"\n\n") end - if dob.is=='code' + if dob.is==:code dob.obj=dob.obj.gsub(/(^|[^}])_([<>])/m,'\1\2'). # _> _< gsub(/(^|[^}])_([<>])/m,'\1\2') # _<_< end diff --git a/lib/sisu/v3dv/shared_html_lite.rb b/lib/sisu/v3dv/shared_html_lite.rb index 94413c69..27a228eb 100644 --- a/lib/sisu/v3dv/shared_html_lite.rb +++ b/lib/sisu/v3dv/shared_html_lite.rb @@ -68,7 +68,7 @@ module SiSU_FormatShared @md,@t_o=md,t_o @txt=@t_o.obj @id=@ocn=@t_o.ocn if defined? @t_o.ocn - @lv=@t_o.lv.to_s if @t_o.is=='heading' + @lv=@t_o.lv.to_s if @t_o.is==:heading if @md.fns != @@fns @@fns,@@hname=@md.fns,'' end @@ -139,7 +139,7 @@ module SiSU_FormatShared @words=@words.join(' ') end def markup_generic(s) - s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1') + s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). @@ -152,7 +152,7 @@ module SiSU_FormatShared end def markup_object(t_o) s=t_o.obj - s=if t_o.is !='code' + s=if t_o.is !=:code s=markup_generic(s) if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)|\S+/) diff --git a/lib/sisu/v3dv/shared_markup_alt.rb b/lib/sisu/v3dv/shared_markup_alt.rb index 9719dd3e..dabb765e 100644 --- a/lib/sisu/v3dv/shared_markup_alt.rb +++ b/lib/sisu/v3dv/shared_markup_alt.rb @@ -123,13 +123,14 @@ module SiSU_TextRepresentation gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~'). gsub(/#{Mx[:en_a_o]}([\d*+]+\s+.+?)#{Mx[:en_a_c]}/,'~{\1}~'). # endnote marker marked up gsub(/#{Mx[:en_b_o]}([\d*+]+\s+.+?)#{Mx[:en_b_c]}/,'~[\1]~') # endnote marker marked up - if @t_o.is=='heading' or @t_o.is=='para' + if @t_o.is==:heading \ + || @t_o.is==:para @s=@s.gsub(/ [ ]+/,' ') @s=@s.gsub(/(?:#{Mx[:nbsp]})+/,' ') - if @t_o.is=='heading' + if @t_o.is==:heading @s=@t_o.lv + '~ ' + @s end - if @t_o.is=='para' + if @t_o.is==:para if @t_o.bullet_ @s='_* ' + @s end @@ -139,11 +140,11 @@ module SiSU_TextRepresentation end end end - if @t_o.is=='block' \ - or @t_o.is=='group' \ - or @t_o.is=='code' + if @t_o.is==:block \ + || @t_o.is==:group \ + || @t_o.is==:code @s=@s.gsub(/#{Mx[:nbsp]}/,' ') - @s="#{@t_o.is}{\n\n#{@s}\n\n}#{@t_o.is}" + @s="#{@t_o.is.to_s}{\n\n#{@s}\n\n}#{@t_o.is.to_s}" @s=@s.gsub(/(?:#{Mx[:br_nl]}|\n)+/m,"\n\n") end #dealing with poem and verse calls for change in dal, where start and end verse of poem are marked as such @@ -162,7 +163,7 @@ module SiSU_TextRepresentation gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - if @t_o.is !='code' + if @t_o.is !=:code if @s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ wm=@s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\S+/) words=urls(wm) @@ -176,7 +177,7 @@ module SiSU_TextRepresentation else @s=@s.gsub(//m,'>') end - if @t_o.is=='paragraph' + if @t_o.is==:paragraph if @t_o.bullet_ @s=@s end @@ -184,7 +185,7 @@ module SiSU_TextRepresentation @s=@s end end - if @t_o.is=='heading' + if @t_o.is==:heading @s=@s end else @@ -291,7 +292,9 @@ module SiSU_TextRepresentation en_dgst end def dgst - if @t_o.of !='comment' and @t_o.of !='structure' and @t_o.of !='layout' + if @t_o.of !=:comment \ + && @t_o.of !=:structure \ + && @t_o.of !=:layout en_dgst,img_dgst={},{} txt_stripped_dgst=digest(stripped_clean(@t_o)) txt_markup_reverted_dgst=digest(markup_reverted(@t_o)) @@ -300,7 +303,8 @@ module SiSU_TextRepresentation notes=@t_o.obj.scan(rgx_notes) endnotes_dgst=endnotes(notes) rgx_image=/#{Mx[:lnk_o]}(\S+\.(?:png|jpg|gif))\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - imgs=if (@t_o.is=='para' or @t_o.is=='image') \ + imgs=if (@t_o.is==:para \ + || @t_o.is==:image) \ and @t_o.obj =~rgx_image imgs=@t_o.obj.scan(rgx_image).flatten line_image=images(imgs) diff --git a/lib/sisu/v3dv/shared_xml.rb b/lib/sisu/v3dv/shared_xml.rb index dbaed6d8..6b85d756 100644 --- a/lib/sisu/v3dv/shared_xml.rb +++ b/lib/sisu/v3dv/shared_xml.rb @@ -343,7 +343,7 @@ module SiSU_XML_Munge def markup(dob='') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip - unless dob.is=='table' + unless dob.is==:table dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/u,'
'). gsub(/#{Mx[:br_paragraph]}/u,'
'). gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') @@ -364,13 +364,13 @@ module SiSU_XML_Munge gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). gsub(/<:pb>\s*/,''). #Fix gsub(/<+[-~]#>+/,'') - if dob.is !~/^code/ + if dob.is !=:code #embeds a red-bullet image --> dob.obj=dob.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1') - dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is=='table' + dob.obj=dob.obj.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'
') unless dob.is==:table dob.obj=dob.obj.gsub(/#{Mx[:br_page]}\s*/,''). gsub(/#{Mx[:br_page_new]}\s*/,''). gsub(/#{Mx[:pa_non_object_no_heading]}|#{Mx[:pa_non_object_dummy_heading]}/,''). @@ -399,7 +399,7 @@ module SiSU_XML_Munge else dob.obj=dob.obj.gsub(//m,'>') end - if dob.of=='block' + if dob.of==:block dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ') end dob.obj=dob.obj.gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, diff --git a/lib/sisu/v3dv/texinfo.rb b/lib/sisu/v3dv/texinfo.rb index 121cf1ae..145712e1 100644 --- a/lib/sisu/v3dv/texinfo.rb +++ b/lib/sisu/v3dv/texinfo.rb @@ -137,19 +137,22 @@ module SiSU_TexInfo end def songsheet begin - @data=pre - @data=endnote - @data=markup - @data=tail - output + data=@data + data=pre(data) + data=endnote(data) + data=markup(data) + objects=tail(data) + #output(objects) + output(@tex_file) + #output(data.compact) makeinfo #KEEP reinstate when fixed #% place_info rescue; STDERR.puts SiSU_Screen::Ansi.new(@md.opt.cmd,$!,$@).rescue ensure end end - def pre - data=@data + def pre(data) + data_new=[] data.each do |dob| # DEBUG 2003w16 this is a kludge, because i could not get parameters # from param, Sort out ... revert to more elegant solution @@ -161,13 +164,15 @@ module SiSU_TexInfo gsub(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') do_mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) dob.obj=do_mono.spec_char(dob.obj) + data_new << dob end - data + data_new end - def endnote - data,data_new=@data,[] + def endnote(data) + data_new=[] data.each do |dob| - if dob.of=~/para|block/ + if dob.of==:para \ + || dob.of==:block dob.obj=dob.obj.gsub(/\s*#{Mx[:en_a_o]}(?:\d+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} '). gsub(/\s*#{Mx[:en_a_o]}(\*+)\s+(.+?)#{Mx[:en_a_c]}/m,' @footnote{ \1} ') end @@ -176,24 +181,24 @@ module SiSU_TexInfo data_new end def poem - data=@data + data,data_new=@data,[] @tex_file=[] @@counting=0 data.each do |dob| - if dob.is =='code' + if dob.is ==:code @@flag['code']=true @@counting=1 end - if dob.is =='verse' + if dob.is ==:verse @@flag['poem']=1 end if @@flag['code'] if @@flag['code'] \ - and dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/ #watch change not tested 200501 #fix + && (dob.obj =~ /#{Mx[:gr_o]}code[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix @@flag['code']=false end if @@flag['code'] \ - and dob.obj =~ /\S/ + && (dob.obj =~ /\S/) sub_array=dob.obj.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -201,11 +206,11 @@ module SiSU_TexInfo end elsif @@flag['poem']==1 if @@flag['poem']==1 \ - and dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/ #watch change not tested 200501 #fix + && (dob.obj =~ /#{Mx[:gr_o]}verse[-_](?:end|close)#{Mx[:gr_c]}/) #watch change not tested 200501 #fix @@flag['poem']=0 end if @@flag['poem']==1 \ - and dob.obj =~ /\S/ + && (dob.obj =~ /\S/) sub_array=dob.obj.dup @@line_mode=sub_array.scan(/.+/) Tune.code_lines(@@line_mode) @@ -213,13 +218,15 @@ module SiSU_TexInfo end end @tex_file << dob.obj + data_new << dob end + data_new end def code_lines data,data_new=@data,[] data.each do |line| - if line =~ /\S/ \ - and line !~ /#{Mx[:gr_o]}(code|verse).+/ #fix + if (line =~ /\S/) \ + && (line !~ /#{Mx[:gr_o]}(code|verse).+/) #fix line=if @@flag['code'] line.gsub(/^\s*(.+)/m,"\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") @@counting+=1 if @@flag['code'] @@ -230,7 +237,7 @@ module SiSU_TexInfo end end def tables - data=@data + data,data_new=@data,[] @tex_file=[] @@tableheader=0 data.each do |dob| @@ -239,10 +246,12 @@ module SiSU_TexInfo dob.obj=do_mono.longtable # using longtable latex package end @tex_file << dob.obj + data_new << dob end + data_new end - def markup - data=@data + def markup(data) + data_new=[] @tex_file=[] @row_break='\\\\\\' @break_page="#{@row_break}\n#{@row_break} \n" @@ -254,12 +263,12 @@ module SiSU_TexInfo n_menu,n_submenu=0,0 @submenu,@subsubmenu={},{} data.each do |dob| - if dob.is =='heading' \ - and dob.ln.to_s =~ /^[1-3]$/ + if dob.is ==:heading \ + && (dob.ln.to_s =~ /^[1-3]$/) toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu - elsif dob.is =='heading' \ - and dob.ln.to_s =~ /^[4-6]$/ + elsif dob.is ==:heading \ + && (dob.ln.to_s =~ /^[4-6]$/) toc=SiSU_TexInfoFormat::Texinfo.new(@md,dob) texinfo_menu << toc.menu case dob.ln @@ -278,7 +287,9 @@ module SiSU_TexInfo else dob.obj=dob.obj.gsub(/\s*(?:<:?br>|
)\s*/,"\n\n") end + data_new << dob end + data=data_new texinfo_menu=texinfo_menu.compact texinfo_menu << "* Dublin Core::" @tex_file << texinfo_menu @@ -287,15 +298,16 @@ module SiSU_TexInfo "@c %% 5\n\n" n_menu,n_submenu=0,0 @@do_submenu,@@do_subsubmenu=1,1 + data_new=[] data.each do |dob| mono=SiSU_TexInfoFormat::Texinfo.new(@md,dob) - if dob.is=='heading' + if dob.is==:heading case dob.ln - when 1; mono.level1 - when 2; mono.level2 - when 3; mono.level3 + when 1; dob=mono.level1 + when 2; dob=mono.level2 + when 3; dob=mono.level3 when 4; - mono.level4 + dob=mono.level4 n_menu+=1 @@do_submenu,@@do_subsubmenu=1,1 when 5; @@ -305,7 +317,7 @@ module SiSU_TexInfo menu=SiSU_TexInfoFormat::TeXinfoTxt.new(@md,dob,@submenu[n_menu]) dob.obj="#{menu.submenu}#{mono.level5.obj}" @@do_submenu=0 - else mono.level5 + else dob=mono.level5 end when 6; if @@do_submenu==1 @@ -313,37 +325,42 @@ module SiSU_TexInfo dob.obj="#{menu.subsubmenu}#{mono.level6.obj}" @@do_subsubmenu=0 else - mono.level6 + dob=mono.level6 end end else if dob.obj !~/\S/ dob.obj=nil else - if dob.is=='para' \ - and dob.obj !~/##{dob.ocn}/ + if dob.is==:para \ + && (dob.obj !~/##{dob.ocn}/) dob.obj="#{dob.obj} ##{dob.ocn}" end end end #%case with endnotes dob.obj=dob.obj.gsub(/\s*[0-8]\\+(\S+)?\s+/,' ') if dob.obj - @tex_file << dob.obj if dob.obj and dob.is !~/structure|comment/ #sort exceptions + if dob.obj \ + && (dob.is !=:structure \ + && dob.is !=:comment) + @tex_file << dob.obj + end + data_new << dob end - data=@tex_file + data_new end def number_titles - data=@data + data,data_new=@data,[] @tex_file=[] input=%{#{@md.markup}}[/(num_top\s*=\s*(\d?))?/m,2] # else default usually 4 # this was a bit of a trick required to pass nil to input if nothing matched... #puts input num_top=input.to_i t_no1=0; t_no2=0; t_no3=0; t_no4=0; no1=num_top; no2=(num_top + 1); no3=(num_top + 2); no4=(num_top + 3); data.each do |dob| - if @md.markup =~ /num_top/i \ - and dob.obj !~ /#{Rx[:meta]}/ - if dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*/ \ - and dob.obj !~ /<:\d-endnotes>/ + if (@md.markup =~ /num_top/i) \ + && (dob.obj !~ /#{Rx[:meta]}/) + if (dob.obj =~ /^[1-6]\\+(?:~\S+)?\s*/) \ + && (dob.obj !~ /<:\d-endnotes>/) header=dob.obj[//m, 1].gsub(/-/m,'.') dob.obj=dob.obj.gsub(/^(?:[1-6]\\+(?:~\S+)|<:([12356]|4-.+?-)>)\s*/, "\\1 #{header} ") @@ -355,16 +372,18 @@ module SiSU_TexInfo end @tex_file << dob.obj end - data=@tex_file + data_new << dob end - def tail - data=@data + def tail(data) tex=SiSU_TexInfoFormat::Texinfo.new(@md) - data << tex.dublincore - data << tex.tail + objects=[] + data.each do |dob| + objects << dob.obj if dob.obj + end + objects << tex.dublincore << tex.tail + objects end - def output - data=@data.compact + def output(data) filename_texinfo=%{#{@env.processing_path.texi}/#{@md.fnb}.texinfo} file_texinfo=File.new(filename_texinfo,'w+') puts filename_texinfo if @md.opt.cmd =~/M/ diff --git a/lib/sisu/v3dv/texinfo_format.rb b/lib/sisu/v3dv/texinfo_format.rb index ed9769fc..0555809d 100644 --- a/lib/sisu/v3dv/texinfo_format.rb +++ b/lib/sisu/v3dv/texinfo_format.rb @@ -293,7 +293,7 @@ WOK "@bye" end def clean(dob) - if dob.is=='heading' \ + if dob.is==:heading \ and dob.obj !~/##{dob.ocn}/ dob.obj="#{dob.obj} ##{dob.ocn}" end @@ -556,7 +556,7 @@ WOK @md,@dob,@txt=md,dob,txt end def clean(dob,txt) - if dob.is=='heading' \ + if dob.is==:heading \ and txt !~/##{dob.ocn}/ txt="#{dob.obj} ##{dob.ocn}" end diff --git a/lib/sisu/v3dv/texpdf.rb b/lib/sisu/v3dv/texpdf.rb index f8010511..c69f7b9c 100644 --- a/lib/sisu/v3dv/texpdf.rb +++ b/lib/sisu/v3dv/texpdf.rb @@ -345,26 +345,26 @@ module SiSU_TeX # from param, Sort out ... revert to more elegant solution # even more of a kludge as had to insert newlines where code is used not satisfactory, think about dob.tmp=dob.obj #.dup - if dob.is=='para' \ - or dob.is=='heading' + if dob.is==:para \ + || dob.is==:heading dob.tmp=dob.tmp.gsub(/#{Mx[:mk_o]}:name#\S+?#{Mx[:mk_c]}/,'') dob.tmp=SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters if dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ dob.tmp=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob.tmp).url_str_internal(dob.tmp) end - elsif dob.is =='code' + elsif dob.is ==:code dob.tmp=if @codeblock_box=='listings' dob.tmp else SiSU_TeX_Pdf::SpecialCharacters.new(@md,dob.tmp).special_characters_code end - elsif dob.is =='break' + elsif dob.is ==:break if dob.obj==Mx[:br_page]; dob.tmp='\newpage' elsif dob.obj==Mx[:br_page_new]; dob.tmp='\clearpage' elsif dob.obj==Mx[:br_obj]; dob.tmp='\parasep' end - elsif dob.is=='comment' \ - or dob.is=='meta' + elsif dob.is==:comment \ + || dob.is==:meta dob.tmp='' #dob.tmp=nil end end @@ -403,7 +403,7 @@ module SiSU_TeX data.each do |dob| @tex_file << if dob.class==String \ or dob.class==Hash; dob - elsif dob.is=='table' + elsif dob.is==:table tables_hash(@md,dob) #Hash result else dob end @@ -463,16 +463,18 @@ module SiSU_TeX def markup_common(dob) tex_f=nil txt_obj={ dal: dob } - if dob.of=='block' - @lineone=case dob.is - when /block|group|alt|verse/ + if dob.of==:block + @lineone=if dob.is==:block \ + || dob.is==:group \ + || dob.is==:alt \ + || dob.is==:verse dob.tmp=dob.tmp.gsub(/#{Mx[:nbsp]}/m,'{~}'). gsub(/#{Mx[:gl_bullet]}/m,'$\txtbullet$\hspace{\enspace}'). #Bullet environment not used for grouped text, ∴ no hanging indent here gsub(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway ocn=SiSU_TeX_Pdf::FormatTextObject.new(@md).ocn_display(dob) - dob.tmp=if dob.is=='group' \ - or dob.is=='block' \ - or dob.is=='alt' + dob.tmp=if dob.is==:group \ + || dob.is==:block \ + || dob.is==:alt ocn \ + @tex_ml.paraskip_small \ + "\n" \ @@ -482,7 +484,7 @@ module SiSU_TeX + '\\end{footnotesize}' \ + "\n" \ + @tex_ml.paraskip_normal - elsif dob.is=~/verse/ + elsif dob.is==:verse ocn \ + @tex_ml.paraskip_tiny \ + "\n" \ @@ -495,7 +497,7 @@ module SiSU_TeX + "\n\\linebreak\n" end dob - when /code/ + elsif dob.is ==:code dob=if @codeblock_box == 'listings' box_listings(dob,ocn) elsif @codeblock_box == 'boites' @@ -511,7 +513,7 @@ module SiSU_TeX else tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob) case dob.is - when 'heading' + when :heading case dob.ln when 1..3 tst.heading_major @@ -523,7 +525,7 @@ module SiSU_TeX tst.level6 else dob end - when 'heading_insert' + when :heading_insert br="\n\\\\\n" if dob.name=='book_index' h=tst.heading_major @@ -555,7 +557,7 @@ module SiSU_TeX dob.tmp=h.tmp + ' ' + '\begin{scriptsize}' + metadata.join(br) + '\end{scriptsize}' else dob.tmp='' # dob.tmp={ l: '', p: '' } end - when 'para' + when :para if dob.bullet_ dob.tmp=tst.bullet elsif dob.indent \ @@ -572,7 +574,7 @@ module SiSU_TeX dob=enclose(dob) unless dob.tmp =~/^$/ end else - dob.tmp=dob.tmp.strip unless dob.is=='code' + dob.tmp=dob.tmp.strip unless dob.is==:code dob=enclose(dob) unless dob.tmp =~/^$/ end if dob.class==String @@ -582,20 +584,20 @@ module SiSU_TeX dob end if dob.tmp =~/(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image\b)/m \ - && dob.is !='code' + && dob.is !=:code dob=SiSU_TeX_Pdf::BareUrls.new(@md,dob).bare_urls tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob) dob=tst.urls_txt_and_images dob elsif dob.tmp =~/https?:\/\/\S+\b/m \ - && dob.is =='code' \ + && dob.is ==:code \ && @codeblock_box !='listings' dob=SiSU_TeX_Pdf::BareUrls.new(@md,dob).bare_urls_in_code dob end if dob.class !=Hash \ && dob.tmp =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image\b/ \ - && dob.is !='code' + && dob.is !=:code tst=SiSU_TeX_Pdf::FormatTextObject.new(@md,dob) end dob @@ -763,10 +765,10 @@ WOK x=nil data.each do |dob| #% case follows with levels 1-6 indents & graphics if dob.class==Hash - elsif dob.of=='para' \ - or dob.of=='block' #GATEWAY FIX FIX stuff + elsif dob.of==:para \ + || dob.of==:block #GATEWAY FIX FIX stuff dob=markup_common(dob) - elsif dob.is=='table' + elsif dob.is==:table if ( dob.tmp['a4'] \ or dob.tmp['a5'] \ or dob.tmp['b5'] \ @@ -809,7 +811,7 @@ WOK @tex_file << "\n\\end{document}" end def number_paras_numbering(dob) # need tables and other types of object - if dob.of =~/para/ #\ + if dob.of ==:para paranum=dob.ocn ? dob.ocn : '' paranum = '' if paranum.to_i==0 paranumber_display=if @md.markup.inspect =~/no_ocn/ \ @@ -860,7 +862,9 @@ WOK else p "#{__FILE__}:#{__LINE__}" if @md.opt.cmd.inspect =~/M/ end else - dob=if dob.of !~/comment|meta|layout/ + dob=if dob.of !=:comment \ + || dob.of !=:meta \ + || dob.of !=:layout number_paras_numbering(dob) else dob end @@ -928,13 +932,13 @@ WOK elsif morph.class.inspect =~ /SiSU_DAL_DocumentStructure/ \ and morph.tmp \ and morph.tmp.class==String - if morph.is !='code' \ - && morph.of !='block' + if morph.is !=:code \ + && morph.of !=:block morph.tmp=morph.tmp.gsub(/^\s+/,'') else morph.tmp end - if morph.tmp !~/\A\s*\Z/ \ - or morph.is=='code' + if (morph.tmp !~/\A\s*\Z/) \ + || morph.is==:code file[:portrait].puts morph.tmp,"\n" file[:landscape].puts morph.tmp,"\n" end diff --git a/lib/sisu/v3dv/texpdf_format.rb b/lib/sisu/v3dv/texpdf_format.rb index b82bf687..fdcdc3d1 100644 --- a/lib/sisu/v3dv/texpdf_format.rb +++ b/lib/sisu/v3dv/texpdf_format.rb @@ -123,7 +123,7 @@ module SiSU_TeX_Pdf def longtable_landscape end_table='\end{longtable}' row_break='\\\\\\' - txt=if @dob.is=='table' + txt=if @dob.is==:table tw=case @dob.tmp[:paper_size] when /a4/i; @tx.a4.landscape.w #European default, SiSU default when /letter/i; @tx.letter.landscape.w #U.S. default @@ -168,7 +168,7 @@ module SiSU_TeX_Pdf def longtable_portrait end_table='\end{longtable}' row_break='\\\\\\' - txt=if @dob.is=='table' + txt=if @dob.is==:table tw=case @dob.tmp[:paper_size] when /a4/i; @tx.a4.portrait.w #European default, SiSU default when /letter/i; @tx.letter.portrait.w #U.S. default @@ -1176,12 +1176,12 @@ WOK end end class SpecialCharacters - def initialize(md,str,is='') + def initialize(md,str,is=:default) @md,@txt,@is=md,str,is @brace_url=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::SystemCall.new.tex2pdf_engine end - def xetex_code_listings(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + def xetex_code_listings(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ para_array=[] str=if word @@ -1194,7 +1194,7 @@ WOK para_array << w end str=para_array.join(' ') - str=str.strip unless is=='code' + str=str.strip unless is==:code str else '' end @@ -1226,7 +1226,7 @@ WOK gsub(/&atild;<\/font><\/sup>/,' '). gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript end - def xetex_special_characters_1(str,is='') # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list + def xetex_special_characters_1(str,is=:default) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list #str=Iconv.conv('ISO-8859-1', 'UTF-8', @txt) # `require': iconv will be deprecated in the future, use String#encode instead. word=str.scan(/\S+|\n/) #unless line =~/^(?:@\S|%+\s)/ para_array=[] @@ -1249,7 +1249,7 @@ WOK para_array << w end str=para_array.join(' ') - str=str.strip unless is=='code' + str=str.strip unless is==:code str else '' end @@ -1258,7 +1258,7 @@ WOK gsub(/#{Mx[:br_eof]}/,''). gsub(/#{Mx[:br_endnotes]}/,'') #problem sequence -> - str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is=='code' # < SiSU special character also LaTeX + str=str.gsub(/&(?:nbsp);|#{Mx[:nbsp]}/,'\hardspace') unless is==:code # < SiSU special character also LaTeX str=str.gsub(/&(?:lt|#060);/,'\lt'). # < SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#(?:gt|062)#{Mx[:gl_c]}/,'\gt'). # > SiSU special character also LaTeX gsub(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'\curlyopen'). # { SiSU special character also LaTeX @@ -1282,7 +1282,7 @@ WOK gsub(/&atild;<\/font><\/sup>/,' '). gsub(/\\copy(right|mark)?/,'<=copymark>') # ok problem with superscript end - def xetex_special_characters_2(str,is='') + def xetex_special_characters_2(str,is=:default) str=str.gsub(/#{Mx[:gl_o]}#156#{Mx[:gl_c]}/,'\oe '). gsub(/\$/,'\$'). gsub(/\#/,'\#'). @@ -1293,7 +1293,7 @@ WOK end str=str.gsub(/\{/,'\{'). gsub(/\}/,'\}') - str=if is=='code' + str=if is==:code str.gsub(/&/,'{\\\&}'). gsub(/\\~(\\\{)/,'{$\tilde$}\1'). gsub(/(\\\})\\~/,'\1{$\tilde$}'). @@ -1316,7 +1316,7 @@ WOK '\begin{scriptsize}\url{\1}\end{scriptsize}'). #special case \{ e.g. \}http://url gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '\begin{scriptsize}\\url{\1}\end{scriptsize}') #specially escaped url no decoration - unless is=='code' + unless is==:code str=str.gsub(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"\s]+?)([;.,]?(?=\s|$))/, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}\\3") #url matching with decoration positive lookahead, sequence issue with { linked }http://url cannot use \b at start end @@ -1334,7 +1334,7 @@ WOK gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,"\$^{\\textrm{\\1}}\$"). gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,"\$_{\\textrm{\\1}}\$"). gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\begin{monosp}\1\end{monosp}') - unless is=='code' + unless is==:code str=str.gsub(/"(.+?)"/,'“\1”'). # quote marks / quotations open & close " need condition exclude for code gsub(/\s+"/,' “'). # open " gsub(/^(#{Mx[:lv_o]}[1-6-]:\S*?#{Mx[:lv_c]}|<.+?>)?\s*"/,'\1“'). #fix Mx[:lv_o] # open " diff --git a/lib/sisu/v3dv/xhtml.rb b/lib/sisu/v3dv/xhtml.rb index 050e16d8..5d17128c 100644 --- a/lib/sisu/v3dv/xhtml.rb +++ b/lib/sisu/v3dv/xhtml.rb @@ -192,9 +192,10 @@ WOK tags end def xml_structure(dob,type='norm') - if dob.is =~/para|heading/ + if dob.is ==:para \ + || dob.is ==:heading named=name_tags(dob) - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 @@ -295,7 +296,7 @@ WOK end if not @rcdc x=SiSU_XML_Format::FormatSeg.new(@md,dob) - if dob.is=='heading' + if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -306,25 +307,25 @@ WOK when 6; x.heading_body6 end else - if dob.is =='verse' + if dob.is ==:verse poem_structure(dob) - elsif dob.is =='group' + elsif dob.is ==:group group_structure(dob) - elsif dob.is =='block' + elsif dob.is ==:block block_structure(dob) - elsif dob.is =='code' + elsif dob.is ==:code code_structure(dob) - elsif dob.is =='table' + elsif dob.is ==:table table_structure(dob) - elsif dob.is =='para' \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_==true xml_structure(dob,"indent_bullet#{dob.indent}") - elsif dob.is =='para' \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang xml_structure(dob,"indent#{dob.indent}") - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang xml_structure(dob,"hang#{dob.hang.to_s}_indent#{dob.indent.to_s}") diff --git a/lib/sisu/v3dv/xml.rb b/lib/sisu/v3dv/xml.rb index 776c0376..1187e02e 100644 --- a/lib/sisu/v3dv/xml.rb +++ b/lib/sisu/v3dv/xml.rb @@ -204,7 +204,7 @@ WOK @@xml[:sc]=sc end def xml_structure(dob,type='norm') - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n3=dob.ln + 2 @@ -306,7 +306,7 @@ WOK @trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8 dob=@trans.markup(dob) if @rcdc==false \ - and (dob.is =~/^meta/ \ + and (dob.is ==:meta \ and dob.obj =~/Document Information/) @rcdc=true end @@ -319,7 +319,7 @@ WOK if defined? dob.ocn \ and dob.ocn.to_s =~/\d+/ x=SiSU_XML_Format::FormatSeg.new(@md,dob) - if dob.is=='heading' + if dob.is==:heading xml_structure(dob) dob.obj=case dob.ln when 1; x.heading_body1 @@ -330,25 +330,25 @@ WOK when 6; x.heading_body6 end else - if dob.is=='verse' + if dob.is==:verse poem_structure(dob) - elsif dob.is=='group' + elsif dob.is==:group group_structure(dob) - elsif dob.is=='block' + elsif dob.is==:block block_structure(dob) - elsif dob.is=='code' + elsif dob.is==:code code_structure(dob) - elsif dob.is=='table' # FIX, check css, will need to modify + elsif dob.is==:table # FIX, check css, will need to modify table_structure(dob) - elsif dob.is =~ /^para/ \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_==true xml_structure(dob,"indent_bullet#{dob.indent}") - elsif dob.is =~ /^para/ \ + elsif dob.is ==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang xml_structure(dob,"indent#{dob.indent}") - elsif dob.is =~ /^para/ \ + elsif dob.is ==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang xml_structure(dob,"hang#{dob.hang.to_s}_indent#{dob.indent.to_s}") diff --git a/lib/sisu/v3dv/xml_dom.rb b/lib/sisu/v3dv/xml_dom.rb index ae45100d..e63f7ad7 100644 --- a/lib/sisu/v3dv/xml_dom.rb +++ b/lib/sisu/v3dv/xml_dom.rb @@ -165,7 +165,7 @@ WOK end def xml_element(dob,xml_el='',xml_content='',type='norm') n=n1=n2=n3=0 - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n1=dob.ln @@ -200,7 +200,7 @@ WOK end def xml_structure(dob,type='norm') n=n1=n2=n3=0 - if dob.is=='heading' + if dob.is==:heading lv=dob.ln n=dob.ln - 1 n1=dob.ln @@ -344,7 +344,7 @@ WOK @trans.char_enc.utf8(dob) if @sys.locale =~/utf-?8/i #% utf8 dob=@trans.markup(dob) if @rcdc==false \ - and (dob.is =~/^meta/ \ + and (dob.is ==:meta \ and dob.obj =~/Document Information/) @rcdc=true end @@ -353,9 +353,9 @@ WOK if not @rcdc if defined? dob.ocn \ and dob.ocn.to_s =~/\d+/ - format_scroll=SiSU_XML_Format::FormatScroll.new(@md,dob) if dob.is=='para' and dob.indent ##FIX + format_scroll=SiSU_XML_Format::FormatScroll.new(@md,dob) if dob.is==:para and dob.indent ##FIX x=SiSU_XML_Format::FormatSeg.new(@md,dob) - if dob.is=='heading' + if dob.is==:heading if dob.ln==1 type="heading_section_#{dob.ln.to_s}" xml_markup(dob) @@ -388,32 +388,32 @@ WOK end else ocn=dob.ocn - if dob.is=='verse' + if dob.is==:verse type='verse' poem_structure(dob) #redo - elsif dob.is=='group' + elsif dob.is==:group type='group' group_structure(dob) #redo - elsif dob.is=='block' + elsif dob.is==:block type='block' block_structure(dob) #redo - elsif dob.is=='code' + elsif dob.is==:code type='code' code_structure(dob) #redo - elsif dob.is=='table' # tables come as single block #work area 2005w13 + elsif dob.is==:table # tables come as single block #work area 2005w13 type='table' table_structure(dob) - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_ type="indent_bullet#{dob.indent.to_s}" xml_markup(dob) - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.indent.to_s =~/[1-9]/ \ and dob.indent == dob.hang type="indent#{dob.indent.to_s}" xml_markup(dob) - elsif dob.is=='para' \ + elsif dob.is==:para \ and dob.hang.to_s =~/[0-9]/ \ and dob.indent != dob.hang type="hang#{dob.hang.to_s}_indent#{dob.indent.to_s}" diff --git a/lib/sisu/v3dv/xml_format.rb b/lib/sisu/v3dv/xml_format.rb index 71a0bd68..50a9f5ac 100644 --- a/lib/sisu/v3dv/xml_format.rb +++ b/lib/sisu/v3dv/xml_format.rb @@ -1026,7 +1026,7 @@ WOK @ocn=if defined? t_o.ocn; t_o.ocn.to_s else nil end - @headname=if t_o.is=='heading' and defined? t_o.name; t_o.name + @headname=if t_o.is==:heading and defined? t_o.name; t_o.name else nil end else diff --git a/lib/sisu/v3dv/xml_scaffold.rb b/lib/sisu/v3dv/xml_scaffold.rb index 1ae31d0f..f43daacf 100644 --- a/lib/sisu/v3dv/xml_scaffold.rb +++ b/lib/sisu/v3dv/xml_scaffold.rb @@ -110,13 +110,13 @@ module SiSU_XML_Scaffold def structure_outline(data) puts "\ninfo outline --->\n\n" data.each do |o| - puts "#{o.ocn} #{o.ln} #{o.obj}" if o.is =~/^heading/ + puts "#{o.ocn} #{o.ln} #{o.obj}" if (o.is ==:heading || o.is ==:heading_insert) end end def structure_simple(data) puts "\nheading outline --->\n\n" data.each_with_index do |o,i| - if o.is =~ /^heading/; puts "<#{@s[o.ln]}>#{o.ocn} #{o.ln} #{o.obj}" + if (o.is ==:heading || o.is ==:heading_insert); puts "<#{@s[o.ln]}>#{o.ocn} #{o.ln} #{o.obj}" end end end @@ -125,7 +125,7 @@ module SiSU_XML_Scaffold h=[0,false,false,false] puts "<#{@s[0]}>" data.each_with_index do |o,i| - if o.is =~/^heading/ + if (o.is ==:heading || o.is ==:heading_insert) case o.ln when 1 structure_build_tag_close(o.ln,h) -- cgit v1.2.3