From 08c69d074001507d64cd5960c8679ec91a5a8353 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 23 Aug 2008 12:01:59 -0400 Subject: pass Hash to Format classes; some match tuning in dal --- lib/sisu/v0/xml_format.rb | 57 +++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'lib/sisu/v0/xml_format.rb') diff --git a/lib/sisu/v0/xml_format.rb b/lib/sisu/v0/xml_format.rb index 20eb6736..a801f9d2 100644 --- a/lib/sisu/v0/xml_format.rb +++ b/lib/sisu/v0/xml_format.rb @@ -282,64 +282,74 @@ WOK end class Format_text_object @@dp=nil - attr_accessor :md,:one,:two,:three,:parablock,:table,:link,:linkname,:format,:paranum,:p_num,:para_id,:headname,:margin,:paragraph,:table,:banner,:url,:icon,:font,:one_stripped - def initialize(md,*txt) - @md=md - txt[0].gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=txt[0],txt[1],txt[2] - @format,@parablock=txt[0],txt[1] - if txt[2]=~/\d+/ - @paranum=/(\d+)/m.match(txt[2])[1] + attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @format =t_o[:format] || nil + @lnk_url =t_o[:lnk_url] || nil + @lnk_txt =t_o[:lnk_txt] || nil + @ocn =t_o[:ocn] || nil + #@h_name =t_o[:h_name] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + if @t_o[:ocn]=~/\d+/ + @paranum=/(\d+)/m.match(@t_o[:ocn])[1] @headname='' #if txt[2]=~/\d+/ - m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(format) + m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(@format) headname=m[1] if m @headname=%{} unless headname.nil? @p_num=SiSU_XML_format::Paragraph_number.new(@md,@paranum) end - #{ rgx=/^[1-6-]~{1,2}/ #watch - link=txt[0].gsub(rgx,'') if @one =~rgx + @lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/~\{\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}\}~/ - link=txt[0].gsub(rgx,'\1') if txt[0] =~rgx - @link,@linkname=link,txt[1] + @lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#{@txt} " end end class Format_scroll < Format_text_object - def initialize(*txt) - super(*txt) + def initialize(md,t_o) + super(md,t_o) end def heading_body - %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.name}#{@headname}#{@txt}

} + %{

#{@p_num.display}

\n} end def heading_body1 - %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.name}#{@headname}#{@txt}

} + %{

#{@p_num.display}

\n} end def heading_body2 - %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.name}#{@headname}#{@txt}

} + %{

#{@p_num.display}

\n} end def heading_body3 - %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.name}#{@headname}#{@txt}

} + %{

#{@p_num.display}

\n} end def heading_body4 - %{

#{@p_num.name}#@headname#@parablock

} + + %{

#{@p_num.name}#{@headname}#{@txt}

} + %{

#{@p_num.display}

\n} end def heading_body5 - %{
#{@p_num.name}#@headname#@parablock
} + + %{
#{@p_num.name}#{@headname}#{@txt}
} + %{

#{@p_num.display}

\n} end def heading_body6 - %{
#{@p_num.name}#@headname#@parablock
} + + %{
#{@p_num.name}#{@headname}#{@txt}
} + %{

#{@p_num.display}

\n} end end @@ -347,4 +357,3 @@ WOK end end __END__ - -- cgit v1.2.3