From 6149eecbced3c564088bab622a9491deb4f65646 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 11 Dec 2008 21:48:30 -0500 Subject: html tables, fix to structure and for (specified) column widths --- lib/sisu/v0/html_scroll.rb | 39 +++++++++++++++++++++------------------ lib/sisu/v0/html_table.rb | 24 ++++++++++++------------ 2 files changed, 33 insertions(+), 30 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index fb04f2f9..2f8bc1dd 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -112,33 +112,36 @@ module SiSU_HTML_scroll txt_obj={:txt =>@sto.text} format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) end - case @sto.format - when /^1:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body1 - when /^2:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body2 - when /^3:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body3 - when /^4:\S+?/; para=@sto.scroll_lev_para_ocn.heading_body4 # work on see Split_text_object4 - when /^5:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body5 - when /^6:\S*?/; para=@sto.scroll_lev_para_ocn.heading_body6 - when /^#{Mx[:gl_bullet]}/; para=@sto.scroll_lev_para_ocn.bullet + para=case @sto.format + when /^1:\S*?/; @sto.scroll_lev_para_ocn.heading_body1 + when /^2:\S*?/; @sto.scroll_lev_para_ocn.heading_body2 + when /^3:\S*?/; @sto.scroll_lev_para_ocn.heading_body3 + when /^4:\S+?/; @sto.scroll_lev_para_ocn.heading_body4 # work on see Split_text_object4 + when /^5:\S*?/; @sto.scroll_lev_para_ocn.heading_body5 + when /^6:\S*?/; @sto.scroll_lev_para_ocn.heading_body6 + when /^#{Mx[:gl_bullet]}/; @sto.scroll_lev_para_ocn.bullet when /^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}#{Mx[:gl_bullet]}/ #indent with bullet format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.format('li',"i#{$1}") + @sto.scroll_lev_para_ocn.format('li',"i#{$1}") when /^i([1-9])$/ #indent format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.format('p',"i#{$1}") - when /^center$/; para=@sto.scroll_lev_para_ocn.center - when /^(?:b|bold)$/; para=@sto.scroll_lev_para_ocn.bold - when /^(?:verse|group|alt)$/; para=@sto.scroll_lev_para_ocn.para - when /^code$/; para=@sto.scroll_lev_para_ocn.code + @sto.scroll_lev_para_ocn.format('p',"i#{$1}") + when /^center$/; @sto.scroll_lev_para_ocn.center + when /^(?:b|bold)$/; @sto.scroll_lev_para_ocn.bold + when /^(?:verse|group|alt)$/; @sto.scroll_lev_para_ocn.para + when /^code$/; @sto.scroll_lev_para_ocn.code when /ordinary/ # see whether u can improve - if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ + para=if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ format_txt_obj.gsub_body - para=@sto.scroll_lev_para_ocn.para - if para =~/#{Mx[:gr_o]}Th?.+/ # tables come as single block + para=if para =~/#{Mx[:gr_o]}Th?.+/ # tables come as single block + #@sto=nil table=SiSU_HTML_shared::Table.new(para) - para=table.table_split + table.table_split + else @sto.scroll_lev_para_ocn.para end + else para end + else para end elsif para =~/^#{Mx[:lv_o]}[1-9]:/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_c]}#@dp:#@dp#{Mx[:id_c]}$/ diff --git a/lib/sisu/v0/html_table.rb b/lib/sisu/v0/html_table.rb index 7f28ed93..067a7dd9 100644 --- a/lib/sisu/v0/html_table.rb +++ b/lib/sisu/v0/html_table.rb @@ -109,16 +109,16 @@ module SiSU_HTML_table tablefoot=[] @@tablefoot.each {|x| tablefoot << ''} @@tablefoot=[] - if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock="

\n" #table_end + if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock="

\n" #table_end end end if @@tablehead == 1 if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1,true)) + while @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u + @parablock.sub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u,table_row($1,true)) end - if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1,true)) + while @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u + @parablock.sub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u,table_cell($1,true)) end if @parablock =~/#{Mx[:tc_c]}/ @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) @@ -127,11 +127,11 @@ module SiSU_HTML_table end @parablock else - if @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_row($1)) + while @parablock =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u + @parablock.sub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u,table_row($1)) end - if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u - @parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,table_cell($1)) + while @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u + @parablock.sub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+)#{Mx[:tc_p]}/u,table_cell($1)) end if @parablock =~/#{Mx[:tc_c]}/ @parablock.gsub!(/#{Mx[:tc_c]}/,table_row_close) @@ -141,12 +141,12 @@ module SiSU_HTML_table @parablock end def table_split - @new_content=[] + content=[] @one.split(/\n/).each do |parablock| table=Table.new("#{parablock}\n") - @new_content << table.table + content << table.table end - @new_content.join + content.join end end end -- cgit v1.2.3