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/html_format.rb | 242 +++++++++++++++++++-------------------------- 1 file changed, 103 insertions(+), 139 deletions(-) (limited to 'lib/sisu/v0/html_format.rb') diff --git a/lib/sisu/v0/html_format.rb b/lib/sisu/v0/html_format.rb index af36dc30..1d82ddfe 100644 --- a/lib/sisu/v0/html_format.rb +++ b/lib/sisu/v0/html_format.rb @@ -61,10 +61,9 @@ module SiSU_HTML_Format include SiSU_Viz class Paragraph_number - def initialize(md,paranum) - @md=md - @paranum=paranum[/(\d+)/m,1] - @paranum ||='' + def initialize(md,ocn) + @md,@ocn=md,ocn[/(\d+)/m,1] + @ocn ||='' vz=SiSU_Env::Get_init.instance.skin @skin_no_ocn=if defined? vz.ocn_display_off \ and vz.ocn_display_off == true @@ -77,75 +76,31 @@ module SiSU_HTML_Format or @md.mod.inspect =~/--no-ocn/ \ or @skin_no_ocn ocn_class='ocn_off' - @paranum.gsub(/^(\d+|)$/, + @ocn.gsub(/^(\d+|)$/, %{}) - elsif @paranum.to_i == 0 - @paranum.gsub(/^(\d+|)$/, - %{}) + elsif @ocn.to_i == 0 + @ocn.gsub(/^(\d+|)$/, + %{}) else ocn_class='ocn' - @paranum.gsub(/^(\d+|)$/, - %{}) + @ocn.gsub(/^(\d+|)$/, + %{}) end end def name - %{} + %{} end def id #w3c? "tidy" complains about numbers as identifiers ! annoying - %{id="o#@paranum"} + %{id="o#{@ocn}"} end def goto - %{} - end - end - class Paragraph_id_ocn #used by table version #work area 2003w48 - attr_accessor :paranum,:font,:p_num - def initialize(md,paranum) - @paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,Paragraph_number.new(md,paranum) #font - #@paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,SiSU_HTML_Format::Paragraph_number.new(md,paranum) #font - end - def txt - %{

#{@p_num.name} - } - end - def txt_00 - %{

#{@p_num.name} - } - end - def font_citation - %{} - end - def endnote - %{

#{@p_num.name} - } - end - def table - %{

#{@p_num.name} - } - end - def tiny - %{

#{@p_num.name} - } - end - def small - %{

#{@p_num.name} - } # keep but not used? - end - def font_tiny - %{} - end - def font_small - %{} - end - def header_ - %{

#{@p_num.name} - } + %{} end end class Head_information include SiSU_Viz attr_reader :md,:sfx,:pdf,:rdf,:vz - def initialize(md='') + def initialize(md) @md=md @sfx,@pdf=@md.sfx,@md.pdf @rdf=SiSU_XML_tags::RDF.new(md) @@ -1038,27 +993,39 @@ WOK class Format_text_object @vz=SiSU_Env::Get_init.instance.skin @@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,@one,@two,@three=md,txt[0],txt[1],txt[2] - rgx=/^#{Mx[:lv_o]}\d:\S*?#{Mx[:lv_c]}/ - @one_stripped=@one.gsub(rgx,'') if @one =~rgx - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern - rgx=/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/ #problem introduced - @one_stripped=@one.gsub(rgx,'\1') if @one =~rgx #problem introduced - @format,@parablock=txt[0],txt[1] - @one.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') if @one - @parablock.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') if @parablock - if txt[2]=~/\d+/ - @paranum=txt[2][/(\d+)/m,1] # unless paranum =~/#/ - @p_num=Paragraph_number.new(@md,@paranum) - @para_id=Paragraph_id_ocn.new(@md,@paranum) #used by table version + attr_accessor :md,:t_o,:txt,:ocn,:format,:table,:link,:linkname,:paranum,:p_num,:headname,:banner,:url + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @ocn =t_o[:ocn] || nil + @ocn_display =t_o[:ocn_display] || nil + @headname =t_o[:headname] || nil + @trailer =t_o[:trailer] || nil + @endnote_part_a =t_o[:endnote_part_a] || nil + @endnote_part_b =t_o[:endnote_part_b] || nil + @lnk_url =t_o[:lnk_url] || nil + @lnk_txt =t_o[:lnk_txt] || nil + @format =t_o[:format] || nil + @target =t_o[:target] || nil #occasionally passed but not used + else + if @md.cmd =~/M/ + p t_o.class + p caller + end + end + if @txt and not @txt.empty? + @txt.gsub!(/#{Mx[:mk_o]}[-~]##{Mx[:mk_c]}/,'') + end + if @ocn and @ocn=~/\d+/ #WATCH FIX + @p_num=Paragraph_number.new(@md,@ocn) end - @headname='' - if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ - headname=$1 #format[/\d~(\S+)/m,1] - @headname=if headname =~/^[a-zA-Z]/; %{} #consider: h_#{headname} - else %{} + if @format and not @format.empty? + if @format=~/^\d:(\S+)/ #need more reliable marker #if @format =~ /#{Rx[:lv]}/ + headname=$1 #format[/\d~(\S+)/m,1] + @headname=if headname =~/^[a-zA-Z]/; %{} #consider: h_#{headname} + else %{} + end end end @vz=SiSU_Env::Get_init.instance.skin @@ -1066,14 +1033,14 @@ WOK def endnote_body %{

- #@one + #{@txt}

} end def endnote_body_indent %{

- #@one + #{@txt}

} end @@ -1082,7 +1049,7 @@ WOK

- #@one #@two + #{@txt}

} @@ -1094,7 +1061,7 @@ WOK
#{@p_num.ocn_display} #{ul}<#{tag} class="#{attrib}" #{@p_num.id}> - #@parablock + #{@txt} #{ulc}
} @@ -1123,8 +1090,7 @@ WOK
#{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} - #@headname - #@parablock + #{@headname}#{@txt}
} @@ -1154,7 +1120,7 @@ WOK %{
<#{tag} class="#{attrib}"> - #@one + #{@txt}
} @@ -1176,13 +1142,13 @@ WOK
} end - def dl - "
#@one #@two
" + def dl #check :trailer + "
#{@txt} #{@trailer}
" end def table_css_end # ' @@ -1190,66 +1156,66 @@ WOK ' end def gsub_body - case @one + case @txt when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\((i+|iv|v|vi+|ix|x|xi+)\)/ - @one.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') - @one.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') + @txt.gsub!(/^\((i+|iv|v|vi+|ix|x|xi+)\)/,'(\1)') + @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((i+|iv|v|vi+|ix|x|xi+)\)/,'\1(\2)') when /^(?:#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}\s*)?\(?(\d|[a-z])+\)/ - @one.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') - @one.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') + @txt.gsub!(/^\((\d+|[a-z])+\)/,'(\1)') + @txt.gsub!(/^(#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]})\s*\((\d+|[a-z])+\)/,'\1(\2)') when /^\s*\d{1,3}\.\s/ - @one.gsub!(/^\s*(\d+\.)/,'\1') + @txt.gsub!(/^\s*(\d+\.)/,'\1') when /^\s*[A-Z]\.\s/ - @one.gsub!(/^\s*([A-Z]\.)/,'\1') + @txt.gsub!(/^\s*([A-Z]\.)/,'\1') end end def bold_para %{#{@vz.margin_txt_0}

- #@one + #{@txt}

#{@vz.margin_num_css}     #{@vz.table_close}} end def bold_header - @one.gsub!(/[1-9]~(\S+)/,'') - @one.gsub!(/[1-9]~/,'') - @one.gsub!(/#{Mx[:id_o]}~0;[um]\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}\s*$/i,'') #watch & do differently + @txt.gsub!(/[1-9]~(\S+)/,'') + @txt.gsub!(/[1-9]~/,'') + @txt.gsub!(/#{Mx[:id_o]}~0;[um]\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}\s*$/i,'') #watch & do differently %{

- #@one + #{@txt}

#{@vz.margin_num_css}     #{@vz.table_close}} end def toc_head_copy_at - %{

#@one

\n} + %{

#{@txt}

\n} end def center - %{

#@one

\n} + %{

#{@txt}

\n} end def bold - %{

#@one

\n} + %{

#{@txt}

\n} end def center_bold - %{

#@one

\n} + %{

#{@txt}

\n} end end class Format_scroll < Format_text_object - def initialize(md='',*txt) - super(md,*txt) + def initialize(md,txt) + super(md,txt) @vz=SiSU_Env::Get_init.instance.skin end end class Format_seg < Format_text_object - def initialize(md='',*txt) - super(md,*txt) + def initialize(md,txt) + super(md,txt) end def navigation_toc_lev1_advert %{#{@banner.home_button}\n
-#@one +#{@txt} #@two

} end @@ -1263,7 +1229,7 @@ WOK - #@one + #{@txt}

#{@vz.table_close}} @@ -1275,7 +1241,7 @@ WOK - #@one + #{@txt}

#{@vz.table_close}} @@ -1286,7 +1252,7 @@ WOK

- #@one + #{@txt}

#{@vz.table_close}} end @@ -1298,41 +1264,41 @@ WOK fn='doc' if fn.empty? #you may wish to reconsider, sends to 'doc' where no segment info %{

- #@one#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#@two#@three + #{@endnote_part_a}#{@md.fnl[:pre]}#{fn}#{@md.fnl[:mid]}#{@md.sfx}#{@md.fnl[:post]}#{@endnote_part_b}

} end def subtoc_lev(tag,attrib) - one=if @one \ - and @one =~/<\/?i>|/mi - @one.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text - else @one + txt=if @txt \ + and @txt =~/<\/?i>|/mi + @txt.gsub(/<\/?i>|/mi,'') #removes name markers from subtoc, go directly to substantive text + else @txt end note='' - if one =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream + if txt =~/((?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*)/m #this is a clumsy fix, revisit and address upstream note=$1 note.gsub!(/[\n\s]+/m,' ') - one.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') - one.gsub!(/ \d+<\/sup> /m,'') + txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') + txt.gsub!(/ \d+<\/sup> /m,'') end %{<#{tag} class="#{attrib}"> - #{one} #{note} + #{txt} #{note} } end def subtoc_lev5 - subtoc_lev('h5','subtoc') if @one + subtoc_lev('h5','subtoc') if @txt end def subtoc_lev6 - subtoc_lev('h6','subtoc') if @one + subtoc_lev('h6','subtoc') if @txt end #% para sisu def header_sub(tag,attrib) - @parablock.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') + @txt.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') %{
#{@p_num.ocn_display} <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} #{@headname} - #{@parablock} + #{@txt}
} @@ -1348,8 +1314,8 @@ WOK
#{@p_num.ocn_display}

#{@p_num.name} - #@format - #@parablock + #{@t_o[:format]} + #{@txt}

} @@ -1358,42 +1324,40 @@ WOK %{

- #@parablock + #{@txt}

#{@vz.table_close}} end def navigation_header5 %{

- #@parablock + #{@txt}

} end def navigation_header6 %{

- #@parablock + #{@txt}

} end def navigation_center - "
#@parablock
" + "
#{@txt}
" end end class Format_toc < Format_text_object - def initialize(md='',*txt) - super(md,*txt) - @link,@linkname=@one,@two + def initialize(md,txt) + super(md,txt) end def links_guide - #@three distinguishes between _top and external, can be used e.g. for different colour scheme %{
  • - - #@linkname + + #{@lnk_txt}
  • } end def lev(tag,attrib) - if @one + if @txt %{<#{tag} class="#{attrib}"> - #@one + #{@txt} } else '' -- cgit v1.2.3