aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v2/xml_dom.rb95
1 files 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}<heading>
#{Ax[:tab]*n2}<object id="#{dob.ocn}">
#{Ax[:tab]*n3}<ocn>#{dob.ocn}</ocn>#{tag}
-#{Ax[:tab]*n3}<text>#{dob.obj}</text>
+#{Ax[:tab]*n3}<text class="#{type}">#{dob.obj}</text>
#{Ax[:tab]*n2}</object>
#{Ax[:tab]*n1}</heading>#{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}<object id="#{dob.ocn}">}
+ @@xml[:body] << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>} if defined? dob.ocn
+ end
+ #@@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>}
+ #@@xml[:body] << %{#{Ax[:tab]*7}<text class="#{dob.is}">#{Ax[:tab]*1}}
+ @@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{Ax[:tab]*1}}
+ @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
+ @@xml[:body] << %{#{Ax[:tab]*7}</text>}
+ @@xml[:body] << %{#{Ax[:tab]*6}</object>}
+ 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,
'<endnote><number>\1</number><note>\2</note></endnote> ')
dob.obj.strip!
- @@xml[:body] << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*7}<text class="group">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}</text>}
- @@xml[:body] << "#{Ax[:tab]*6}</object>"
+ dob
end
def poem_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
dob.obj.strip!
- @@xml[:body] << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*7}<text class="verse">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}</text>}
- @@xml[:body] << "#{Ax[:tab]*6}</object>"
+ dob
end
def code_structure(dob)
dob=@trans.markup_group(dob) #decide check & FIX
dob.obj.gsub!(/\s\s/,'&#160;&#160;')
dob.obj.strip!
- @@xml[:body] << %{#{Ax[:tab]*6}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*7}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*7}<text class="code">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*8}#{dob.obj}#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*7}</text>}
- @@xml[:body] << "#{Ax[:tab]*6}</object>"
+ dob
end
def table_structure(dob) #tables
table=SiSU_XHTML_shared::Table_xhtml.new(dob)
- @@xml[:body] << %{#{Ax[:tab]*0}<object id="#{dob.ocn}">}
- @@xml[:body] << %{#{Ax[:tab]*1}<ocn>#{dob.ocn}</ocn>}
- @@xml[:body] << %{#{Ax[:tab]*1}<text class="table">#{Ax[:tab]*1}}
- @@xml[:body] << %{#{Ax[:tab]*2}#{table.table.obj}}
- @@xml[:body] << %{#{Ax[:tab]*1}</text>}
- @@xml[:body] << "#{Ax[:tab]*0}</object>"
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}<object id="#{dob.ocn}">}
+ 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}<ocn>#{dob.ocn}</ocn>" if defined? dob.ocn
- @@xml[:body] << %{#{Ax[:tab]*7}<text class="#{type}">#{dob.obj}</text>} if defined? dob.obj # main text, contents, body KEEP
- @@xml[:body] << "#{Ax[:tab]*6}</object>"
+ add_to_body(dob,type)
end
elsif dob.obj =~/(#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
elsif dob.obj =~/(MetaData)/