diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v2/odf.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v2/shared_metadata.rb | 3 | ||||
-rw-r--r-- | lib/sisu/v2/shared_xml.rb | 3 | ||||
-rw-r--r-- | lib/sisu/v2/texpdf.rb | 1 | ||||
-rw-r--r-- | lib/sisu/v2/xml_dom.rb | 95 |
5 files changed, 59 insertions, 48 deletions
diff --git a/lib/sisu/v2/odf.rb b/lib/sisu/v2/odf.rb index c51eab90..d4aeb616 100644 --- a/lib/sisu/v2/odf.rb +++ b/lib/sisu/v2/odf.rb @@ -418,10 +418,13 @@ module SiSU_ODF dob.obj=para_array.join(' ') dob.obj=dob.obj.strip end - if dob.obj =~/#{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix + if dob.is=='code' #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix dob.obj.gsub!(/(^|[^}])_</m,'\1<'); dob.obj.gsub!(/(^|[^}])_>/m,'\1>') dob.obj.gsub!(/(^|[^}])_</m,'\1<'); dob.obj.gsub!(/(^|[^}])_>/m,'\1>') end + if dob.of=='group' + dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') + end dob.obj.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') dob.obj.gsub!(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>') dob.obj.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>') diff --git a/lib/sisu/v2/shared_metadata.rb b/lib/sisu/v2/shared_metadata.rb index 7c8cc971..f39b2f79 100644 --- a/lib/sisu/v2/shared_metadata.rb +++ b/lib/sisu/v2/shared_metadata.rb @@ -474,6 +474,7 @@ WOK def meta_para url_brace=SiSU_Viz::Skin.new.url_decoration if @inf.class==String + @inf.gsub!(/<br>/,'<br />') @inf.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration @inf.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, @@ -484,7 +485,7 @@ WOK %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{url_brace.xml_close}}) if @inf !~/http:\/\// # improve upon, document crash where url contains '@' symbol end <<WOK -<text:p text:style-name="P1">#{@tag.capitalize}: #{@inf}</text:p>} +<text:p text:style-name="P1">#{@tag.capitalize}: #{@inf}</text:p> WOK end def metadata diff --git a/lib/sisu/v2/shared_xml.rb b/lib/sisu/v2/shared_xml.rb index d70e0808..8a58909b 100644 --- a/lib/sisu/v2/shared_xml.rb +++ b/lib/sisu/v2/shared_xml.rb @@ -392,6 +392,9 @@ module SiSU_XML_munge dob.obj.gsub!(/(^|[^}])_</m,'\1<'); dob.obj.gsub!(/(^|[^}])_>/m,'\1>') #code-block: angle brackets special characters dob.obj.gsub!(/(^|[^}])_</m,'\1<'); dob.obj.gsub!(/(^|[^}])_>/m,'\1>') end + if dob.of=='group' + dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') + end dob.obj.gsub!(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}") dob.obj.gsub!(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}") dob.obj.gsub!(/ |#{Mx[:nbsp]}/m,' ') diff --git a/lib/sisu/v2/texpdf.rb b/lib/sisu/v2/texpdf.rb index 00a4d16d..f0e04b33 100644 --- a/lib/sisu/v2/texpdf.rb +++ b/lib/sisu/v2/texpdf.rb @@ -413,6 +413,7 @@ module SiSU_TeX @lineone=case dob.is when /alt|group|verse/ dob.tmp.gsub!(/#{Mx[:nbsp]}/m,'{~}') + dob.tmp.gsub!(/#{Mx[:gl_bullet]}/m,'$\txtbullet$~~') dob.tmp.gsub!(/#{Mx[:br_nl]}+/m,"\n\n") #match not ideal, but currently not inserting extra newlines anyway ocn=SiSU_TeX_Pdf::Format_text_object.new(@md).ocn_display(dob) dob.tmp=if dob.is=='group' \ 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/,'  ') 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)/ |