From 1323f18af45ea0d3aaef5cd9ead0efb5de8b9729 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 19 Apr 2015 14:44:38 -0400 Subject: c<-d: sync, roll develop into current dir branch (5==6) * two dir branches, same library contents (v5 synced & updated with v6) --- lib/sisu/current/xml_sax.rb | 145 +++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 70 deletions(-) (limited to 'lib/sisu/current/xml_sax.rb') diff --git a/lib/sisu/current/xml_sax.rb b/lib/sisu/current/xml_sax.rb index 21455628..21e5d50d 100644 --- a/lib/sisu/current/xml_sax.rb +++ b/lib/sisu/current/xml_sax.rb @@ -63,10 +63,11 @@ module SiSU_XML_SAX include SiSU_XML_Munge require_relative 'xml_format' # xml_format.rb include SiSU_XML_Format + require_relative 'xml_persist' # xml_persist.rb require_relative 'rexml' # rexml.rb include SiSU_Rexml require_relative 'shared_metadata' # shared_metadata.rb - @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0 + @@alt_id_count=0 @@tablefoot='' class Source def initialize(opt) @@ -159,18 +160,22 @@ module SiSU_XML_SAX include SiSU_TextUtils require_relative 'css' # css.rb require_relative 'xhtml_shared' # decide use, whether xml rather than xhtml - @@xml={ body: [], open: [], close: [], head: [] } def initialize(particulars) @env, @md, @ao_arr= particulars.env,particulars.md,particulars.ao_array @trans=SiSU_XML_Munge::Trans.new(@md) @sys=SiSU_Env::SystemCall.new + @per=SiSU_XML_Persist::Persist.new end def songsheet - pre - @data=markup(@ao_arr) - post - publish + begin + pre + @data=markup(@ao_arr) + post + publish + ensure + SiSU_XML_Persist::Persist.new.persist_init + end end protected def embedded_endnotes(dob='') @@ -219,7 +224,7 @@ WOK end def xml_head metadata=SiSU_Metadata::Summary.new(@md).xml_sax.metadata - @@xml[:head] << metadata + @per.head << metadata end def xml_sc(md='') sc=if @md.sc_info @@ -241,7 +246,7 @@ WOK WOK else '' end - @@xml[:sc]=sc + @per.sc=sc end def xml_structure(dob,type='norm') if dob.is==:heading @@ -257,16 +262,16 @@ WOK util=SiSU_TextUtils::Wrap.new(dob.obj,70) wrapped=util.line_wrap #end - @@xml[:body] << if defined? dob.ocn; %{#{Ax[:tab]*0}} + @per.body << if defined? dob.ocn; %{#{Ax[:tab]*0}} else "#{Ax[:tab]*0}" end - @@xml[:body] << "#{Ax[:tab]*1}#{dob.ocn}" if defined? dob.ocn - @@xml[:body] << if lv; %{#{Ax[:tab]*1}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}} + @per.body << "#{Ax[:tab]*1}#{dob.ocn}" if defined? dob.ocn + @per.body << if lv; %{#{Ax[:tab]*1}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}} else %{#{Ax[:tab]*1}\n#{Ax[:tab]*2}#{wrapped}\n#{Ax[:tab]*1}} # main text, contents, body KEEP end - @@xml[:body] << @endnotes if @endnotes - ##@@xml[:body] << "#{Ax[:tab]*1}#{dob[@regx,2]}" if dob[@regx,2] # old unwrapped main text, contents, body KEEP - @@xml[:body] << "#{Ax[:tab]*0}" + @per.body << @endnotes if @endnotes + ##@per.body << "#{Ax[:tab]*1}#{dob[@regx,2]}" if dob[@regx,2] # old unwrapped main text, contents, body KEEP + @per.body << "#{Ax[:tab]*0}" @endnotes=[] end def block_structure(dob='') @@ -275,13 +280,13 @@ WOK gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean dob=@trans.markup_block(dob) dob.obj=dob.obj.strip - @@xml[:body] << %{#{Ax[:tab]*0}} - @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*1}} - @@xml[:body] << "#{Ax[:tab]*0}" - @@xml[:body] << @endnotes if @endnotes + @per.body << %{#{Ax[:tab]*0}} + @per.body << %{#{Ax[:tab]*1}#{dob.ocn}} + @per.body << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*1}} + @per.body << "#{Ax[:tab]*0}" + @per.body << @endnotes if @endnotes @endnotes=[] end def group_structure(dob='') @@ -290,48 +295,48 @@ WOK gsub(/#{Mx[:en_b_o]}([\d*+]+)\s+(?:.+?)#{Mx[:en_b_c]}/,'\1') #footnote/endnote clean dob=@trans.markup_group(dob) dob.obj=dob.obj.strip - @@xml[:body] << %{#{Ax[:tab]*0}} - @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*1}} - @@xml[:body] << "#{Ax[:tab]*0}" - @@xml[:body] << @endnotes if @endnotes + @per.body << %{#{Ax[:tab]*0}} + @per.body << %{#{Ax[:tab]*1}#{dob.ocn}} + @per.body << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*1}} + @per.body << "#{Ax[:tab]*0}" + @per.body << @endnotes if @endnotes @endnotes=[] end def poem_structure(dob='') dob=@trans.markup_group(dob) #dob.obj.gsub(/\s\s/,'  ') dob.obj=dob.obj.strip - @@xml[:body] << %{#{Ax[:tab]*0}} - @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*0}} + @per.body << %{#{Ax[:tab]*0}} + @per.body << %{#{Ax[:tab]*1}#{dob.ocn}} + @per.body << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*0}} end def code_structure(dob='') dob=@trans.markup_group(dob) dob.obj=dob.obj.gsub(/\s\s/,'  ').strip - @@xml[:body] << %{#{Ax[:tab]*0}} - @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*1}} - @@xml[:body] << "#{Ax[:tab]*0}" + @per.body << %{#{Ax[:tab]*0}} + @per.body << %{#{Ax[:tab]*1}#{dob.ocn}} + @per.body << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*2}#{dob.obj}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*1}} + @per.body << "#{Ax[:tab]*0}" end def table_structure(dob) table=SiSU_XHTML_Shared::TableXHTML.new(dob) - @@xml[:body] << %{#{Ax[:tab]*0}} - @@xml[:body] << %{#{Ax[:tab]*1}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*2}#{table.table.obj}} - @@xml[:body] << %{#{Ax[:tab]*1}} - #@@xml[:body] << %{#{tab*1}} - @@xml[:body] << "#{Ax[:tab]*0}" - #@@xml[:body] << %{#{Ax[:tab]*0}} - #@@xml[:body] << %{#{Ax[:tab]*1}#{table}\n#{Ax[:tab]*1}} # unless lv # main text, contents, body KEEP - #@@xml[:body] << "#{Ax[:tab]*0}" + @per.body << %{#{Ax[:tab]*0}} + @per.body << %{#{Ax[:tab]*1}#{dob.ocn}} + @per.body << %{#{Ax[:tab]*1}#{Ax[:tab]*1}} + @per.body << %{#{Ax[:tab]*2}#{table.table.obj}} + @per.body << %{#{Ax[:tab]*1}} + #@per.body << %{#{tab*1}} + @per.body << "#{Ax[:tab]*0}" + #@per.body << %{#{Ax[:tab]*0}} + #@per.body << %{#{Ax[:tab]*1}#{table}\n#{Ax[:tab]*1}} # unless lv # main text, contents, body KEEP + #@per.body << "#{Ax[:tab]*0}" #@endnotes=[] end def markup(data) @@ -403,7 +408,7 @@ WOK elsif dob.obj =~/(Owner Details)/ # txt_obj={ txt: '
Owner Details' } # format_scroll=FormatScroll.new(@md,txt_obj) -# @@xml[:owner_details]=format_scroll.bold_para +# @per.owner_details=format_scroll.bold_para dob.obj='' end if dob.obj =~// \ @@ -424,41 +429,41 @@ WOK end 7.downto(4) do |x| y=x - 1; v=x - 3 - @@xml[:body] << "#{Ax[:tab]*5}\n#{Ax[:tab]*y}" if @level[x]==true + @per.body << "#{Ax[:tab]*5}\n#{Ax[:tab]*y}" if @level[x]==true end 3.downto(1) do |x| y=x - 1 - @@xml[:body] << "#{Ax[:tab]*y}" if @level[x]==true + @per.body << "#{Ax[:tab]*y}" if @level[x]==true end - #7.downto(1) { |x| y=x - 1; @@xml[:body] << "#{Ax[:tab]*y}" if @level[x]==true } + #7.downto(1) { |x| y=x - 1; @per.body << "#{Ax[:tab]*y}" if @level[x]==true } end def pre rdf=SiSU_XML_Tags::RDF.new(@md) - @@xml[:head],@@xml[:body]=[],[] + @per.head,@per.body=[],[] stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_sax').stylesheet encoding=if @sys.locale =~/utf-?8/i then '' else '' end - @@xml[:open] =< WOK - @@xml[:head] << '' - @@xml[:body] << '' + @per.head << '' + @per.body << '' end def post - @@xml[:head] << @@xml[:sc] - @@xml[:head] << '' - @@xml[:body] << '' - @@xml[:close] = '' + @per.head << @per.sc + @per.head << '' + @per.body << '' + @per.close = '' end def publish content=[] - content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] - content << @@xml[:owner_details] if @md.stmp =~/\w\w/ - content << @@xml[:tail] << @@xml[:close] + content << @per.open << @per.head << @per.body #<< @per.metadata + #content << @per.owner_details if @md.stmp =~/\w\w/ + content << @per.tail << @per.close content=content.flatten.compact Output.new(content,@md).xml @@xml={} @@ -496,11 +501,11 @@ WOK 'check document structure' ).colorize tell=SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - 'invert', - '', - '' - ) + @md.opt.act[:color_state][:set], + 'invert', + '', + '' + ) tell.grey_open end tidyfile='/dev/null' #don't want one or screen output, check for alternative flags -- cgit v1.2.3