From fc14d48727e251c0da232ddc966e4078b0bb6d9e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 22 Mar 2010 20:09:22 -0400 Subject: xml_dom, behavior fixes --- lib/sisu/v2/xml_dom.rb | 95 ++++++++++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/lib/sisu/v2/xml_dom.rb b/lib/sisu/v2/xml_dom.rb index 8a4589ba..ff38ff86 100644 --- a/lib/sisu/v2/xml_dom.rb +++ b/lib/sisu/v2/xml_dom.rb @@ -158,7 +158,7 @@ WOK end @@xml[:sc]=sc end - def xml_element(dob,xml_el='',xml_content='') + def xml_element(dob,xml_el='',xml_content='',type='norm') n=n1=n2=n3=0 if dob.is=='heading' lv=dob.ln @@ -179,7 +179,7 @@ WOK #{Ax[:tab]*n1} #{Ax[:tab]*n2} #{Ax[:tab]*n3}#{dob.ocn}#{tag} -#{Ax[:tab]*n3}#{dob.obj} +#{Ax[:tab]*n3}#{dob.obj} #{Ax[:tab]*n2} #{Ax[:tab]*n1}#{xml_content} WOK @@ -281,53 +281,47 @@ WOK end end xml_el ||='' - xml_element(dob,xml_el,xml_content) + xml_element(dob,xml_el,xml_content,type) if lv @level[lv]=true ((lv+1)..6).each { |x| @level[x]=false } end end + def add_to_body(dob,type='norm') + if defined? dob.obj # main text, contents, body KEEP + if defined? dob.ocn \ + and dob.ocn + @@xml[:body] << %{#{Ax[:tab]*6}} + @@xml[:body] << %{#{Ax[:tab]*7}#{dob.ocn}} if defined? dob.ocn + end + #@@xml[:body] << %{#{Ax[:tab]*7}#{dob.obj}} + #@@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} + @@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} + @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}} + @@xml[:body] << %{#{Ax[:tab]*7}} + @@xml[:body] << %{#{Ax[:tab]*6}} + end + end def group_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX dob.obj.gsub!(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/m, '\1\2 ') dob.obj.strip! - @@xml[:body] << %{#{Ax[:tab]*6}} - @@xml[:body] << %{#{Ax[:tab]*7}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*7}} - @@xml[:body] << "#{Ax[:tab]*6}" + dob end def poem_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX dob.obj.strip! - @@xml[:body] << %{#{Ax[:tab]*6}} - @@xml[:body] << %{#{Ax[:tab]*7}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*7}} - @@xml[:body] << "#{Ax[:tab]*6}" + dob end def code_structure(dob) dob=@trans.markup_group(dob) #decide check & FIX dob.obj.gsub!(/\s\s/,'  ') dob.obj.strip! - @@xml[:body] << %{#{Ax[:tab]*6}} - @@xml[:body] << %{#{Ax[:tab]*7}#{dob.ocn}} - @@xml[:body] << %{#{Ax[:tab]*7}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}} - @@xml[:body] << %{#{Ax[:tab]*7}} - @@xml[:body] << "#{Ax[:tab]*6}" + dob end def table_structure(dob) #tables table=SiSU_XHTML_shared::Table_xhtml.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] << "#{Ax[:tab]*0}" end def markup(data) xml_sc(@md) @@ -348,60 +342,69 @@ WOK if dob !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ @p_num=SiSU_XML_format::Paragraph_number.new(@md,dob.ocn) if defined? dob.ocn if not @rcdc - if defined? dob.ocn and dob.ocn.to_s =~/\d+/ + if defined? dob.ocn \ + and dob.ocn.to_s =~/\d+/ format_scroll=SiSU_XML_format::Format_scroll.new(@md,dob) if dob.is=='para' and dob.indent ##FIX x=SiSU_XML_format::Format_seg.new(@md,dob) if dob.is=='heading' if dob.ln==1 + type="heading_section_#{dob.ln.to_s}" xml_markup(dob) - xml_structure(dob) + xml_structure(dob,type) dob.obj=x.heading_body1 elsif dob.ln==2 + type="heading_section_#{dob.ln.to_s}" xml_markup(dob) - xml_structure(dob) + xml_structure(dob,type) dob.obj=x.heading_body2 elsif dob.ln==3 + type="heading_section_#{dob.ln.to_s}" xml_markup(dob) - xml_structure(dob) + xml_structure(dob,type) dob.obj=x.heading_body3 elsif dob.ln==4 + type="heading_content_#{dob.lv}" xml_markup(dob) - xml_structure(dob) + xml_structure(dob,type) dob.obj=x.heading_body4 elsif dob.ln==5 + type="heading_content_#{dob.lv}" xml_markup(dob) - xml_structure(dob) + xml_structure(dob,type) dob.obj=x.heading_body5 elsif dob.ln==6 - xml_markup(dob) - xml_structure(dob) + type="heading_content_#{dob.lv}" + xml_structure(dob,type) dob.obj=x.heading_body6 end else ocn=dob.ocn if dob.is=='verse' + type='verse' poem_structure(dob) #redo elsif dob.is=='group' + type='group' group_structure(dob) #redo elsif dob.is=='code' + type='code' code_structure(dob) #redo elsif dob.is=='table' # tables come as single block #work area 2005w13 + type='table' table_structure(dob) elsif dob.is=='para' \ - and dob.indent.to_s =~/[0-9]/ \ + and dob.indent.to_s =~/[1-9]/ \ and dob.bullet_ + type="indent_bullet#{dob.indent.to_s}" + xml_markup(dob) elsif dob.is=='para' \ - and dob.indent.to_s =~/[0-9]/ - else xml_structure(dob) - end - xml_markup(dob) - if defined? dob.ocn \ - and dob.ocn - @@xml[:body] << %{#{Ax[:tab]*6}} + and dob.indent.to_s =~/[1-9]/ + type="indent#{dob.indent.to_s}" + xml_markup(dob) + else + type='norm' + xml_markup(dob) end - @@xml[:body] << "#{Ax[:tab]*7}#{dob.ocn}" if defined? dob.ocn - @@xml[:body] << %{#{Ax[:tab]*7}#{dob.obj}} if defined? dob.obj # main text, contents, body KEEP - @@xml[:body] << "#{Ax[:tab]*6}" + add_to_body(dob,type) end elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ elsif dob.obj =~/(MetaData)/ -- cgit v1.2.3