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/concordance.rb | 4 +- lib/sisu/v0/dal.rb | 2 +- lib/sisu/v0/dal_syntax.rb | 32 ++-- lib/sisu/v0/db_import.rb | 30 ++-- lib/sisu/v0/html.rb | 99 +++++++----- lib/sisu/v0/html_format.rb | 242 +++++++++++++---------------- lib/sisu/v0/html_scroll.rb | 30 ++-- lib/sisu/v0/html_segments.rb | 67 ++++---- lib/sisu/v0/manpage.rb | 18 +-- lib/sisu/v0/manpage_format.rb | 25 ++- lib/sisu/v0/odf.rb | 61 +++++--- lib/sisu/v0/odf_format.rb | 100 +++++++----- lib/sisu/v0/plaintext.rb | 3 +- lib/sisu/v0/plaintext_format.rb | 26 +++- lib/sisu/v0/shared_html_lite.rb | 85 ++++++----- lib/sisu/v0/shared_structure.rb | 43 ++++-- lib/sisu/v0/shared_txt.rb | 46 ------ lib/sisu/v0/texinfo.rb | 40 +++-- lib/sisu/v0/texinfo_format.rb | 330 +++++++++++++++++++++------------------- lib/sisu/v0/texpdf.rb | 32 ++-- lib/sisu/v0/texpdf_format.rb | 318 +++++++++++++++++++++----------------- lib/sisu/v0/xhtml.rb | 33 ++-- lib/sisu/v0/xml.rb | 26 ++-- lib/sisu/v0/xml_dom.rb | 25 ++- lib/sisu/v0/xml_format.rb | 57 ++++--- 25 files changed, 961 insertions(+), 813 deletions(-) diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index 3e073900..8fe8c4ed 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -240,6 +240,7 @@ WOK and toy !~/^0$/ for word in line.scan(@rgx_scanlist) #%take in word or other match #word.gsub!(@rxp_clean,'') + word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'') word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'') @@ -274,7 +275,8 @@ WOK word.gsub!(/^\(?[a-zA-Z]\)$/,'') word.gsub!(/^\d+(st|nd|rd|th)$/,'') word.gsub!(/^(\d+\.?)+$/, '') - word.gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') + word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'') + word.gsub!(/:name#\S+/,'') word.gsub!(/^\S$/,'') word=nil if word =~/^\S$/ word=nil if word =~/^\s*$/ #watch diff --git a/lib/sisu/v0/dal.rb b/lib/sisu/v0/dal.rb index cf6d8e09..3187a538 100644 --- a/lib/sisu/v0/dal.rb +++ b/lib/sisu/v0/dal.rb @@ -614,7 +614,7 @@ module SiSU_DAL @subnumber=0 if para =~/#{Mx[:lv_o]}#{no1}:/ end if para =~/^#{Mx[:lv_o]}[1-6]:[\w-]*#{Mx[:lv_c]}/ \ - and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s+[\d.]+)\s/ \ + and para !~ /(?:#{Mx[:lv_o]}[1-6]:[\w-]+-#{Mx[:lv_c]}|#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^#{Mx[:lv_o]}[1-6]:[a-z_\.]+#{Mx[:lv_c]}\s*[\d.]+)\s/ \ and para !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ if para =~/^#{Mx[:lv_o]}#{no1}:/ t_no1+=1; t_no2=0; t_no3=0 diff --git a/lib/sisu/v0/dal_syntax.rb b/lib/sisu/v0/dal_syntax.rb index 35f0582a..98c8cf51 100644 --- a/lib/sisu/v0/dal_syntax.rb +++ b/lib/sisu/v0/dal_syntax.rb @@ -240,7 +240,19 @@ module SiSU_Syntax end line.gsub!(/~\{(.+?)\}~/m,"#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}") line.gsub!(/~\[(.+?)\]~/m,"#{Mx[:en_b_o]}\\1#{Mx[:en_b_c]}") - line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 #{@md.title} - #{@md.subtitle},
\\2#{@md.dc_creator}") + if @md.subtitle and not @md.subtitle.empty? + if line =~/(?:by\s+)?(?:@creator|@author)/ + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.title} - #{@md.subtitle},
\\2#{@md.dc_creator}") + else + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") + end + else + if line =~/(?:by\s+)?(?:@creator|@author)/ + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s+(?:(by\s+)?(?:@creator|@author))\s*$/,"\\1#{@md.title},
\\2#{@md.dc_creator}") + else + line.gsub!(/^(#{Mx[:lv_o]}1:\??#{Mx[:lv_c]})\s*@title\s*$/,"\\1 #{@md.title}") + end + end line.gsub!(/^(1~\??) @title\s*$/,"\\1 #{@md.title} - #{@md.subtitle}") # line.gsub!(/^(#{Mx[:lv_o]}[23]:\??#{Mx[:lv_c]}) (?:(by\s+)?(?:@creator|@author))\s*$/,"\\1 \\2#{@md.dc_creator}") # line.gsub!(/<((?:https?|file):\/\/\S+?)>/,'< \1 >') #catch problem markup @@ -285,16 +297,16 @@ module SiSU_Syntax #line.gsub!(/(^| )\{~\^ (.+?)\s*\}((?:https?|file|ftp):\S+)\s+~\{(.+?)\}~/,'\1{ \2 }\3 ~{ \3 \4 }~') # watch line.gsub!(/<:?p([nb])>/,"#{Mx[:fa_o]}p\\1#{Mx[:fa_c]}") #indent used in endnotes, not implemented, replace when ready with: line.gsub!(/(?:
|
)\s*_([12])\s+/,'
<:i\1> ') # depreciated -->#{Mx[:fa_c]} - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)c\{(.+?)\}c/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)e\{(.+?)\}e/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)b\{(.+?)\}b/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)u\{(.+?)\}u/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)c\{(.+?)\}c/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)i\{(.+?)\}i/,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics # depreciated ^ - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore - line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)!\{(.+?)\}!/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #emphasis + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)\*\{(.+?)\}\*/,"\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}") #bold + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[\{]|\>)_\{(.+?)\}_/,"\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}") #underscore + line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|#{Mx[:lnk_o]}|[\(\[]|\(|\>)\/\{(.+?)\}\//,"\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}") #italics line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/,"\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}") #cite /blockquote? line.gsub!(/(^|[^\\])\^\{(.+?)\}\^/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript line.gsub!(/(^|#{Mx[:gl_c]}|\s+|['"]| |\(|\>|\S)9\{(.+?)\}9/,"\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index addd1ae1..52bb3ad2 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -402,7 +402,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_minus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_minus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -443,7 +444,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -482,7 +484,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -521,7 +524,8 @@ module SiSU_DB_import end txt=endnotes(txt).clean_text(@base_url) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus + txt_obj={:txt =>txt,:col =>@col} + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -570,11 +574,14 @@ module SiSU_DB_import if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end @col[:body]=if txt=~/#{Mx[:gr_o]}T[h]?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/ #watch - SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).html_table + txt_obj={:txt =>txt,:col =>@col} + SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).html_table elsif txt=~/^#{Mx[:pa_o]}:i([1-9])#{Mx[:pa_c]}/ - SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).indent($1) + txt_obj={:txt =>txt,:col =>@col} + SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).indent($1) else - SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).norm + txt_obj={:txt =>txt,:col =>@col} + SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).norm end special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @@ -593,7 +600,8 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote + txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} + body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) @@ -633,7 +641,8 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote + txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} + body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) @@ -674,7 +683,8 @@ module SiSU_DB_import nr,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,nr).endnote + txt_obj={:txt =>txt,:col =>@col,:endnote_nr =>nr} + body=SiSU_Format_Shared::CSS_Format.new(@md,txt_obj).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) diff --git a/lib/sisu/v0/html.rb b/lib/sisu/v0/html.rb index fd2294ba..2dc75d60 100644 --- a/lib/sisu/v0/html.rb +++ b/lib/sisu/v0/html.rb @@ -201,7 +201,8 @@ module SiSU_HTML else '_top' end s_lnk_url,s_lnk_lnk=l[:url],l[:say] - lev_para_ocn=SiSU_HTML_Format::Format_toc.new(@md,s_lnk_url,s_lnk_lnk,target) + txt_obj={:lnk_url =>s_lnk_url,:lnk_txt =>s_lnk_lnk,:target =>target} + lev_para_ocn=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) @links_guide_toc << lev_para_ocn.links_guide if s_lnk_lnk end end @@ -236,7 +237,8 @@ module SiSU_HTML endnote_array << pg.scan(/#{Mx[:en_b_o]}[\d+]+(.+?)#{Mx[:en_b_c]}/m) end endnote_array.flatten.each do |note| - format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,note) + txt_obj={:txt =>note} + format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,txt_obj) @scr_endnotes << format_scroll.endnote_body end end @@ -318,12 +320,17 @@ WOK @@toc[:scr] << format_head_scroll.toc_owner_details end end +#not used --> def level_endnotes if @md.flag_endnotes format_head_scroll=SiSU_HTML_Format::Head_scroll.new(@md) @@toc[:scr] << format_head_scroll.toc_endnote end end + def level_concordance + format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) + @@toc[:seg_mini] << format_head_toc.mini_seg_concordance + end def level_metadata format_head_toc=SiSU_HTML_Format::Head_toc.new(@md) @@toc[:scr] << format_head_toc.metadata @@ -336,6 +343,7 @@ WOK @@toc[:seg] << format_head_toc.concordance @@toc[:seg_mini] << format_head_toc.mini_concordance end +# <-- not used def level_1 para=@data unless para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -353,7 +361,8 @@ WOK %{#{linkname}} end toc={} - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:seg]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ format_toc.lev0 else format_toc.lev1 @@ -379,7 +388,8 @@ WOK end %{#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=if para =~/^#{Mx[:lv_o]}\d:meta^#{Mx[:lv_c]}\s*Document Information/ format_toc.lev0 else format_toc.lev1 @@ -392,12 +402,13 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') end para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,linkname) + txt_obj={:txt =>linkname} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev2 toc[:seg_mini]=format_toc.mini_lev2 @@ -407,7 +418,8 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev2 toc end @@ -416,12 +428,13 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') para.gsub(/(.*?)<\/a>(.*)/,'\1') #2002w42 altered gsub! - problematic? - suspect para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,linkname) + txt_obj={:txt =>linkname} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev3 toc[:seg_mini]=format_toc.mini_lev3 @@ -431,7 +444,8 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev3 toc end @@ -441,8 +455,8 @@ WOK unless para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ para.gsub!(@pat_strip_heading_name,'\1') para[@pat_heading] - linkname,link=$1.strip,$2 if $& - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) if link + linkname,ocn=$1.strip,$2 if $& + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn end para.gsub!(/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,'') if para =~/^#{Mx[:lv_o]}4:/ @@ -460,8 +474,9 @@ WOK %{\\1 \\2 \\3 }) end - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) if link - format_toc=SiSU_HTML_Format::Format_toc.new(@md,seg_link) + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) if ocn + txt_obj={:txt =>seg_link} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc={} toc[:seg]=format_toc.lev4 toc[:seg_mini]=format_toc.mini_lev4 @@ -471,7 +486,8 @@ WOK title=linkname else title=%{#{p_num.goto}#{linkname}} if p_num end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev4 toc end @@ -482,10 +498,10 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') end para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end toc={} if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -493,15 +509,17 @@ WOK para.gsub!(m,'') title=linkname else - lnk_n_txt=%{ + lnk_n_txt=%{ #{linkname} } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,lnk_n_txt) + txt_obj={:txt =>lnk_n_txt} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:seg]=format_toc.lev5 toc[:seg_mini]=format_toc.mini_lev5 title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev5 toc end @@ -511,10 +529,10 @@ WOK para.gsub!(@pat_strip_heading_name,'\1') end para[@pat_heading] - linkname,link=$1.strip,$2 if $& - if link \ - and link !~/#/ - p_num=SiSU_HTML_Format::Paragraph_number.new(@md,link) + linkname,ocn=$1.strip,$2 if $& + if ocn \ + and ocn !~/#/ + p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end toc={} if para =~/#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -522,15 +540,17 @@ WOK para.gsub!(m,'') title=linkname else - lnk_n_txt=%{ + lnk_n_txt=%{ #{linkname} } - format_toc=SiSU_HTML_Format::Format_toc.new(@md,lnk_n_txt) + txt_obj={:txt =>lnk_n_txt} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:seg]=format_toc.lev6 toc[:seg_mini]=format_toc.mini_lev6 title=%{#{p_num.goto}#{linkname}} end - format_toc=SiSU_HTML_Format::Format_toc.new(@md,title) + txt_obj={:txt =>title} + format_toc=SiSU_HTML_Format::Format_toc.new(@md,txt_obj) toc[:scr]=format_toc.lev6 toc end @@ -592,20 +612,23 @@ WOK tmp_head=nil doc_title_endnote=@md.title.gsub(/(\*+)/,'\1') tmp_head=doc_title_endnote + "\n" - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) + txt_obj={:txt =>tmp_head} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold if not @md.subtitle.nil? \ and not @md.subtitle.empty? tmp_head=@md.subtitle + "\n" - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) + txt_obj={:txt=>tmp_head} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end if @md.dc_creator creator_endnote=@md.dc_creator.gsub(/(\*+)/,%{ \\1}) tmp_head=creator_endnote + "\n" - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,tmp_head) + txt_obj={:txt =>tmp_head} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) toc_shared << format_txt_obj.center_bold @segtoc << format_txt_obj.center_bold end 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 '' diff --git a/lib/sisu/v0/html_scroll.rb b/lib/sisu/v0/html_scroll.rb index 01720862..9286df10 100644 --- a/lib/sisu/v0/html_scroll.rb +++ b/lib/sisu/v0/html_scroll.rb @@ -102,13 +102,16 @@ module SiSU_HTML_scroll unless para =~/^#{Mx[:gr_o]}code#{Mx[:gr_c]}/; para.gsub!(/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]}).+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})\s*/m,' ') end if para =~/.+?#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - paranum=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + ocn=para[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/,1] + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_scroll m=/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ #watch + if @sto.format =~/i[1-9]|ordinary/ #watch + 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 @@ -139,30 +142,33 @@ module SiSU_HTML_scroll 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]}$/ - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,para) + txt_obj={:txt =>para} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) para=format_txt_obj.bold_header elsif para =~/Endnotes?/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,'
    Note') + txt_obj={:txt =>'
    Note'} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) para=format_txt_obj.bold_para elsif para =~/Owner Details/ \ and para !~/#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) @scr[:owner_details]=format_txt_obj.bold_para para='' elsif para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ #watch - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + cont=if $2.empty? + $1 + else "#{$1} #{$2}" #watch, check desired where $2 is other than space + end + txt_obj={:txt =>cont} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.no_paranum end if para =~// \ and para =~/^(?:\^~\d+\s|)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though para='' end - if para =~/<:center>/ #rules changed now a

    (.*)/.match(para).captures - format_scroll=SiSU_HTML_Format::Format_scroll.new(@md,one,two) - end para.gsub!(/^#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/^<:\S?>/,'') para.gsub!(/#{Rx[:mx_fa_clean]}/,' '); para.gsub!(/<:\S?>/,' '); para.gsub!(//,' ') para.strip! diff --git a/lib/sisu/v0/html_segments.rb b/lib/sisu/v0/html_segments.rb index 7a4a4fb6..b457fe5c 100644 --- a/lib/sisu/v0/html_segments.rb +++ b/lib/sisu/v0/html_segments.rb @@ -228,41 +228,45 @@ module SiSU_HTML_seg @@seg[:tocband_bannerless] << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) @@seg[:headers] << format_head_seg.seg_head_escript if SiSU_HTML_Format::Head_seg.method_defined? :seg_head_escript #debug PHP move up in text #bug @@seg[:headers] << format_head_seg.title_banner(@md.title,@md.subtitle,@dc_creator).gsub(clean,'') - paranum=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if @@header1[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,@@header1,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>@@header1,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header1.gsub(clean,'') @@header1.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is2 == 1 header2=@@header2 - paranum=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if header2[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,header2,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>header2,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header2.gsub(clean,'') @@header2.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is3 == 1 header3=@@header3 - paranum=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if header3[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,header3,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>header3,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header3.gsub(clean,'') @@header3.gsub!(/  [\d*+]+<\/sup> <\/a>/,'') end if @@is4 == 1 header4=@@header4 - paranum=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 + ocn=if header4[/.+?#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/]; $1 else '' end - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) - format_seg=SiSU_HTML_Format::Format_seg.new(@md,header4,@p_num.ocn_display) + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) + txt_obj={:txt =>header4,:ocn_display =>@p_num.ocn_display} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) @@seg[:headers] << format_seg.title_header4.gsub(clean,'') end @@seg[:header_endnotes]=format_head_seg.title_endnote(@md.title,@md.subtitle,@dc_creator,@@seg[:dot_nav]) @@ -275,8 +279,8 @@ module SiSU_HTML_seg if para !~/^#{Rx[:meta]}/ m=para[/.+?#{Mx[:id_o]}~(\d+);(?:[ohm]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] if m - paranum=m[1].to_s - @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,paranum) + ocn=m[1].to_s + @p_num=SiSU_HTML_Format::Paragraph_number.new(@md,ocn) end if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/m \ or @@flag_alt==true @@ -299,14 +303,18 @@ module SiSU_HTML_seg end if para !~/^#{Mx[:lv_o]}[1-9]:|#{Rx[:meta]}/ if para =~/(.*)#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/ - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + cont="#{$1} #{$2}" #check where $2 is other than space + txt_obj={:txt =>cont} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.no_paranum end end if para[/#{Mx[:id_o]}~(\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp)#{Mx[:id_c]}$/] @sto=SiSU_HTML::Source::Split_text_object.new(@md,para).html_seg - format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ #watch + if @sto.format =~/i[1-9]|ordinary/ #watch + txt_obj={:txt =>@sto.text} + format_txt_obj=SiSU_HTML_Format::Format_text_object.new(@md,txt_obj) + end para=case @sto.format # work area 2003w29 ||@|def lev_segname_para_ocn| when /^4:/; @sto.seg_lev_para_ocn.header4 # work on see Split_text_object when /^5:/; @sto.seg_lev_para_ocn.header5 @@ -348,11 +356,13 @@ module SiSU_HTML_seg if para !~/#{@vz.margin_txt_w1}|#{@vz.margin_txt_w2}/ if para[/(.*)#{Mx[:id_o]}~0;(?:u|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}(.*)/] #% watch u & m? one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + txt_obj={:txt =>$1.strip,:trailing =>$2.strip} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) end para.gsub!(/\s*(-\{{2}~\d+|<:e[:_]\d+>).*/,'') #potentially dagerous - removes all paragraphs with #?? workpoint if para =~/ / #endnote- note- - format_seg=SiSU_HTML_Format::Format_seg.new(@md,para) + txt_obj={:txt =>para} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.no_paranum end end @@ -444,12 +454,12 @@ module SiSU_HTML_seg para.gsub!(/ <\/a>/,' ') case para # series changed 2002w42 when /^#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #remove [u]? req by pg texts, revist - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + txt_obj={:txt =>$1.strip,:ocn =>$2} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.subtoc_lev5 when /^#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.+)?#{Mx[:id_o]}~(\d+);(?:h|[56]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - one,two=$1,$2 - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + txt_obj={:txt =>$1.strip,:ocn =>$2} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) para=format_seg.subtoc_lev6 end @@seg_subtoc_array << para @@ -474,7 +484,8 @@ module SiSU_HTML_seg e_n=note_match_seg[/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,1] try=e_n.split(/
    /) try.each do |e| - format_seg=SiSU_HTML_Format::Format_seg.new(@md,e) + txt_obj={:txt =>e} + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) note_match=if e =~/#{Mx[:pa_o]}i[1-9]#{Mx[:pa_c]}/ format_seg.endnote_body_indent else format_seg.endnote_body @@ -484,9 +495,11 @@ module SiSU_HTML_seg try.join('
    ') #% creation of separate end segment/page of all endnotes referenced back to reference segment m=/(?:#{Mx[:en_a_o]}[\d*+]+|#{Mx[:en_b_o]}[*+]\d+)\s+(.+?href=")(#-[\d*+]+".+)(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/mi - one=note_match_seg[m,1] #note~ [a name] - two=note_match_seg[m,2] #note- - format_seg=SiSU_HTML_Format::Format_seg.new(@md,one,two) + endnote_part_a=note_match_seg[m,1] + endnote_part_b=note_match_seg[m,2] + txt_obj={:endnote_part_a =>endnote_part_a,:endnote_part_b =>endnote_part_b} + + format_seg=SiSU_HTML_Format::Format_seg.new(@md,txt_obj) note_match_all_seg=format_seg.endnote_seg_body(@@fn) #BUG WATCH 200408 @@seg[:endnote_all] << note_match_all_seg end diff --git a/lib/sisu/v0/manpage.rb b/lib/sisu/v0/manpage.rb index fb6f6b2e..77d6e408 100644 --- a/lib/sisu/v0/manpage.rb +++ b/lib/sisu/v0/manpage.rb @@ -66,7 +66,7 @@ module SiSU_manpage include SiSU_Param include SiSU_Viz require "#{SiSU_lib}/manpage_format" - include Format + include SiSU_Manpage_format require "#{SiSU_lib}/shared_txt" require "#{SiSU_lib}/shared_structure" pwd=Dir.pwd @@ -343,9 +343,9 @@ WOK if para !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ if para =~@regx #/.+?<~\d+;\w\d+;\w\d+>.*/ #watch change paranum=para[@regx,3] - @p_num=Format::Paragraph_number.new(paranum) + @p_num=SiSU_Manpage_format::Paragraph_number.new(paranum) end - @sto=SiSU_Structure::Split_text_object.new(@md,para).txt + @sto=SiSU_Structure::Split_text_object.new(@md,para).manpage ### problem in scroll, it appears tables are getting paragraph numbers m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m \ @@ -387,10 +387,6 @@ WOK #@@manpage[:owner_details]=formatMono.bold_para #para='' elsif para =~/(#{Mx[:tc_p]}|#{Mx[:gr_o]}Th?)/u #tables ! - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum end if (para =~/
    / \ and para =~/^(-\{{2}~\d+|)/) # -endnote @@ -399,18 +395,14 @@ WOK case para when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ if para =~/.*<:#>.*$/m - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(txt_obj) para=format_text.scr_indent_one_no_paranum end end if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end para.gsub!(/\s(\[)/m,' \ \1') if para #manpages use this para.gsub!(/(?:#{Mx[:br_line]}|#{Mx[:br_nl]})/,"\n\n") if para para.gsub!(/#{Mx[:gl_o]}#126#{Mx[:gl_c]}/,'~') if para #manpages use this diff --git a/lib/sisu/v0/manpage_format.rb b/lib/sisu/v0/manpage_format.rb index 02fbf216..28756455 100644 --- a/lib/sisu/v0/manpage_format.rb +++ b/lib/sisu/v0/manpage_format.rb @@ -58,7 +58,7 @@ ** Description: manpage formatting template =end -module Format +module SiSU_Manpage_format require "#{SiSU_lib}/param" include SiSU_Param include SiSU_Viz @@ -78,19 +78,28 @@ module Format end class Format_text_object @@dp=nil - def initialize(one,two,three) - one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=one,two,three + def initialize(md,t_o) + @md,@t_o=md,t_o + if @t_o.class == Hash + @txt =@t_o[:txt] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + #@txt.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ rgx=/^#{Mx[:lv_o]}[1-6-]:/ - @one.gsub!(rgx,'') if @one =~rgx + @txt.gsub!(rgx,'') if @txt =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ - @one.gsub!(rgx,'\1') if @one =~rgx - @link,@linkname=one,two + @txt.gsub!(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#{@txt} " end def heading_body1 end diff --git a/lib/sisu/v0/odf.rb b/lib/sisu/v0/odf.rb index 9fb6b51e..d21a8628 100644 --- a/lib/sisu/v0/odf.rb +++ b/lib/sisu/v0/odf.rb @@ -249,7 +249,7 @@ module SiSU_ODF txt.gsub!(/([)(\]\[])/,"\\\\\\1") txt.gsub!(/([+?*])/,"\\\\\\1") # problems with + url.gsub!(/([+?])/,"\\\\\\1") # problems with + - para.gsub!(/\{\s*#{txt}\}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url + para.gsub!(/#{Mx[:lnk_o]}\s*#{txt}#{Mx[:lnk_c]}#{url}/m,text_link_odf(txt,url,trail)) #make sure trailing ']' are not caught in url para.gsub!(/\\([)(\]\[?])/,'\1') #clumsy fix end m=nil @@ -358,11 +358,29 @@ module SiSU_ODF end def table(para) # if para =~/#{Mx[:gr_o]}Th?.+/ # tables come as single block - table=SiSU_ODF_format::Table.new(@md,para) + txt_obj={:table =>para} + table=SiSU_ODF_format::Table.new(@md,txt_obj) para=table.table_split end end - def odf_structure(para='',lv='',ocn='',hname='') #% Used to extract the structure of a document + def odf_structure(md,t_o) + @md,@t_o=md,t_o + @md,@t_o=md,t_o + if t_o.class == Hash + para =t_o[:txt] || nil + lv =t_o[:lv] || nil + ocn =t_o[:ocn] || nil + hname =t_o[:h_name] || nil + #@h_name =t_o[:h_name] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #@one,@two,@three=one,two,three + p t_o.class + p caller + end lv=lv.to_i n=lv - 1 n3=lv + 2 @@ -515,31 +533,35 @@ module SiSU_ODF and para=~/\S+/ para=case @sto.format when /^(1):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(2):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(3):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(4):(\S+)/ # work on see Split_text_object - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) # work on see SiSU_text_parts::Split_text_object para when /^(5):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para when /^(6):(\S*)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para - else odf_structure(para,nil,nil,nil) #watch may be problematic + else + txt_obj={:txt =>para} + odf_structure(@md,txt_obj) #watch may be problematic para end - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=SiSU_ODF_format::Format_text_object.new(one,two) - para=format_text.seg_no_paranum end if para =~// \ and para =~/^(-\{{2}~\d+|)/ # -endnote @@ -548,17 +570,14 @@ module SiSU_ODF if (para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/) # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=SiSU_ODF_format::Format_text_object.new(one,two) - para=format_text.center - end else if para =~ /^(4)~(\S+)/ - odf_structure(para,$1,@sto.ocn,$2) + txt_obj={:txt =>para,:lv =>$1,:ocn =>@sto.ocn,:h_name=>$2} + odf_structure(@md,txt_obj) para elsif para =~/#{Mx[:id_o]}~(\d+);m\d+;[mdv]\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - odf_structure(para,nil,nil,nil) #watch may be problematic + txt_obj={:txt =>para} + odf_structure(@md,txt_obj) #watch may be problematic para end end diff --git a/lib/sisu/v0/odf_format.rb b/lib/sisu/v0/odf_format.rb index 05e4a918..fe94bf5b 100644 --- a/lib/sisu/v0/odf_format.rb +++ b/lib/sisu/v0/odf_format.rb @@ -78,19 +78,28 @@ module SiSU_ODF_format end class Format_text_object @@dp=nil - def initialize(one,two,three) - one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=one,two,three + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #@one,@two,@three=one,two,three + p t_o.class + p caller + end rgx=/^#{Mx[:lv_o]}[1-6-]:/ - @one.gsub!(rgx,'') if @one =~rgx + @txt.gsub!(rgx,'') if @txt =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/#{Mx[:en_a_o]}\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ - @one.gsub!(rgx,'\1') if @one =~rgx - @link,@linkname=one,two + @txt.gsub!(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#@txt " end def heading_body1 #%{#@two} @@ -116,8 +125,21 @@ module SiSU_ODF_format @@tablefoot=[] #watch @@fns='' @@dp=nil - def initialize(md,one) - @md,@one,@parablock,@vz=md,one,one,SiSU_Env::Get_init.instance.skin + def initialize(md,t_o) + @md,@t_o,@vz=md,t_o,SiSU_Env::Get_init.instance.skin + if t_o.class == Hash + @txt =t_o[:txt] || nil + @table =t_o[:table] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + if @md.cmd =~/M/ + p t_o.class + p caller + end + end if @md.fns != @@fns @@table_counter=0 @@fns=@md.fns @@ -177,58 +199,60 @@ module SiSU_ODF_format %{#@br} end def table - @parablock='' if @parablock =~/^/,1] + @txt='' if @txt =~/^/,1] @@tablefoot << m if m - @parablock.gsub!(//,'') - @@tablehead=1 if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u - @@table_counter+=1 if @parablock =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u - if @parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1,true) - elsif @parablock =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @parablock=table_head(@@table_counter,$1) + @txt.gsub!(//,'') + @@tablehead=1 if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u + @@table_counter+=1 if @txt =~/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1,true) + elsif @txt =~/#{Mx[:gr_o]}T#{Mx[:tc_p]}\s+c(\d+).+?#{Mx[:tc_p]}~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u; @txt=table_head(@@table_counter,$1) end - if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ tablefoot=[] @@tablefoot.each {|x| tablefoot << ''} @@tablefoot=[] - if @parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @parablock=table_end + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/; @txt=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)) + if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{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)) + if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{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)) + if @txt =~/#{Mx[:tc_c]}/ + @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close(true)) end @@tablehead=0 end - @parablock + @txt 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)) + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{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)) + if @txt =~/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u + @txt.gsub!(/#{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) + if @txt =~/#{Mx[:tc_c]}/ + @txt.gsub!(/#{Mx[:tc_c]}/,table_row_close) end - @parablock + @txt end - @parablock + @txt end def table_split @new_content=[] - @one.split(/\s*#{Mx[:tc_o]}/).each do |parablock| + @table.split(/\s*#{Mx[:tc_o]}/).each do |parablock| table=if parablock =~/#{Mx[:gr_o]}/ - Table.new(@md,"#{parablock}") + txt_obj={:txt =>parablock} + Table.new(@md,txt_obj) else - Table.new(@md,"#{Mx[:tc_o]}#{parablock}") + txt_obj={:txt =>"#{Mx[:tc_o]}#{parablock}"} + Table.new(@md,txt_obj) end @new_content << table.table end diff --git a/lib/sisu/v0/plaintext.rb b/lib/sisu/v0/plaintext.rb index 9a246e49..132f2997 100644 --- a/lib/sisu/v0/plaintext.rb +++ b/lib/sisu/v0/plaintext.rb @@ -388,7 +388,8 @@ WOK case para when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ if para =~/.*<:#>.*$/m - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) para=format_text.scr_indent_one_no_paranum end end diff --git a/lib/sisu/v0/plaintext_format.rb b/lib/sisu/v0/plaintext_format.rb index e957d3a3..ddac2e32 100644 --- a/lib/sisu/v0/plaintext_format.rb +++ b/lib/sisu/v0/plaintext_format.rb @@ -78,19 +78,30 @@ module Format end class Format_text_object @@dp=nil - def initialize(one,two,three) - one.gsub!(/\.(html|pdf|php)/,'') if one =~/\.\.\/\S+/ - @one,@two,@three=one,two,three + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @lnk_url =t_o[:lnk_url] || nil + @lnk_txt =t_o[:lnk_txt] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #@one,@two,@three=one,two,three + p t_o.class + p caller + end rgx=/^#{Rx[:lv]}/ - @one.gsub!(rgx,'') if @one =~rgx + @txt.gsub!(rgx,'') if @txt =~rgx @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}#{Mx[:en_a_c]}/ - @one.gsub!(rgx,'\1') if @one =~rgx - @link,@linkname=one,two + @txt.gsub!(rgx,'\1') if @txt =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body - "#@one " + "#{@txt} " end def heading_body1 end @@ -109,4 +120,3 @@ module Format end end __END__ - diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 7be46abb..7a23be0b 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -65,20 +65,34 @@ module SiSU_Format_Shared class CSS_Format require "#{SiSU_lib}/defaults" @@fns=nil - def initialize(md,content=nil,col=nil,en=nil) - content.gsub!(/<:i[12]>/,'') - @md,@content=md,content - @id=@ocn=col[:id] - @ocnd,@ocns=col[:ocnd],col[:ocns] - @notenumber=en - @lv=col[:lev].to_s + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] #|| nil #s/@content/@txt/ + @col =t_o[:col] #|| nil + @notenumber =t_o[:endnote_nr] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #content.gsub!(/<:i[1-9]>/,'') + #@md,@content=md,content + p t_o.class + p caller + end + + @txt.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/,'') + @id=@ocn=@col[:id] + @ocnd,@ocns=@col[:ocnd],@col[:ocns] + @lv=@col[:lev].to_s @@hname=if @md.fns != @@fns @@fns=@md.fns '' end - @hname=if col[:seg] \ - and not col[:seg].to_s.empty? - @@hname=col[:seg].to_s + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? + @@hname=@col[:seg].to_s else @@hname end @tab="\t" @@ -87,7 +101,7 @@ module SiSU_Format_Shared @@tablehead,@@tablefoot=[],[] @vz=SiSU_Env::Get_init.instance.skin @env=SiSU_Env::Info_env.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" + @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" end def urls(data) @words=[] @@ -147,48 +161,48 @@ module SiSU_Format_Shared para end def paragraph - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def endnote #used only by db - @content=markup(@content) + @txt=markup(@txt) < -#{@tab*2}
    #@notenumber. #@content +#{@tab*1}

    +#{@tab*2}#{@notenumber}. #{@txt} #{@tab*1}

    GSUB end def lev_toc_hname - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def lev_toc - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def lev4_plus - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def lev4_minus - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def norm_comment - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} end def norm - @content=markup(@content) - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} + @txt=markup(@txt) + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} end def indent(t) - @content=markup(@content) - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} + @txt=markup(@txt) + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} end def para_table %{

    } end def ocn - %{#{@tab*1}} << "\n" + %{#{@tab*1}} << "\n" end def html_table # get rid of use html_table @new_content=[] - @content.split(/\n/).each do |parablock| + @txt.split(/\n/).each do |parablock| m=parablock[//,1] @@tablefoot</,'') @@ -233,27 +247,27 @@ GSUB @new_content.join end end - class CSS_Format_generic #does CSS_Format in one definition, needs to be told about class, despite brevity of generic, easier to see structure with CSS_Format - def initialize(css_class='',content='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) + class CSS_Format_generic #does CSS_Format in one definition, needs to be told about attrib, despite brevity of generic, easier to see structure with CSS_Format + def initialize(attrib='',txt='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) @tab="\t" - @class=css_class - @content=content + @attrib=attrib + @txt=txt @lv=@notenumber=lv.to_s - #@ocn=ocn.to_s + #{@ocn}=ocn.to_s @hname=hname.to_s @id=@ocn=id end def paragraph - css_class=%{class="#@class" } + attrib=%{class="#{@attrib}" } if @ocn - id=%{id="#@ocn" } + id=%{id="#{@ocn}" } type=%{type="substantive" } else id=%{id="none" } type=%{type="comment" } end - header=%{header="#@hname" } if @hname - %{#{@tab*1}

    \n#{@tab*2}#@content\n#{@tab*1}

    \n} << "\n" + header=%{header="#{@hname}" } if @hname + %{#{@tab*1}

    \n#{@tab*2}#{@txt}\n#{@tab*1}

    \n} << "\n" end def para paragraph @@ -261,4 +275,3 @@ GSUB end end __END__ - diff --git a/lib/sisu/v0/shared_structure.rb b/lib/sisu/v0/shared_structure.rb index cdfe9bf3..47b8ff0d 100644 --- a/lib/sisu/v0/shared_structure.rb +++ b/lib/sisu/v0/shared_structure.rb @@ -70,6 +70,7 @@ module SiSU_Structure @format,@ocn='ordinary','ordinary' #@format,@ocn=nil,nil @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @id_block="#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" end def lev_segname_para_ocn if @para =~/^#{Mx[:lv_o]}\d:.+?#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ @@ -94,7 +95,7 @@ module SiSU_Structure if @para !~/#{Mx[:id_o]}~(\d+);(?:[ohu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$|^$/ #added 2002w06 @text=@para[/(.+?)/m,1] end - if @para[/^#{Mx[:lv_o]}(\d):\S*?#{Mx[:lv_c]}\s+(.+)/m] + if @para[/^#{Mx[:lv_o]}(\d):\S*?#{Mx[:lv_c]}\s*(.+)/m] @format,@text=$1,$2 end end @@ -104,14 +105,16 @@ module SiSU_Structure def html_seg lev_segname_para_ocn @seg_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] - SiSU_HTML_Format::Format_seg.new(@md,@format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_HTML_Format::Format_seg.new(@md,txt_obj) end self end def html_scroll lev_segname_para_ocn @scroll_lev_para_ocn=if @para[/.+#{Mx[:id_o]}~\d+;(?:[ohmu]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/] - SiSU_HTML_Format::Format_scroll.new(@md,@format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_HTML_Format::Format_scroll.new(@md,txt_obj) end self end @@ -119,18 +122,24 @@ module SiSU_Structure require "#{SiSU_lib}/shared_xml" lev_segname_para_ocn @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - SiSU_XML_format::Format_scroll.new(@md,@format,@text,"x#@ocn") + txt_obj={:txt =>@text,:format =>@format,:ocn =>"x#@ocn"} + SiSU_XML_format::Format_scroll.new(@md,txt_obj) else - SiSU_XML_format::Format_scroll.new(@md,@format,@text,"#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") + id_block="#{Mx[:id_o]}~0;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_XML_format::Format_scroll.new(@md,txt_obj) end self end def odt lev_segname_para_ocn @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - SiSU_ODF_format::Format_text_object.new(format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_ODF_format::Format_text_object.new(@md,txt_obj) else - SiSU_ODF_format::Format_text_object.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") + id_block="#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_ODF_format::Format_text_object.new(@md,txt_obj) end self @@ -139,9 +148,25 @@ module SiSU_Structure lev_segname_para_ocn #format=@format.dup @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - Format::Format_text_object.new(@format,@text,@ocn) + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_Plaintext_format::Format_text_object.new(@md,txt_obj) else - Format::Format_text_object.new(@format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}") + id_block="#{Mx[:id_o]}~\d+;[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_Plaintext_format::Format_text_object.new(@md,txt_obj) + end + self + end + def manpage #check + lev_segname_para_ocn + #format=@format.dup + @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ + txt_obj={:txt =>@text,:format =>@format,:ocn =>@ocn} + SiSU_Manpage_format::Format_text_object.new(@md,txt_obj) + else + id_block="#{Mx[:id_o]}~\d+;[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}" + txt_obj={:txt =>@text,:format =>@format,:id_block =>id_block} + SiSU_Manpage_format::Format_text_object.new(@md,txt_obj) end self end diff --git a/lib/sisu/v0/shared_txt.rb b/lib/sisu/v0/shared_txt.rb index 41d6d815..198b8ce8 100644 --- a/lib/sisu/v0/shared_txt.rb +++ b/lib/sisu/v0/shared_txt.rb @@ -222,50 +222,4 @@ module SiSU_text_utils end end end -module SiSU_text_parts_flatfile - class Split_text_object - @@dl=nil - attr_reader :format,:text,:ocn,:lev_para_ocn - def initialize(md,para) - @md,@para=md,para - @format,@ocn='ordinary','ordinary' - @@dl ||=SiSU_Env::Info_env.new.digest.length - end - def lev_segname_para_ocn - if @para =~/^(?:#{Mx[:lv_o]}[1-9]:\S*?#{Mx[:lv_c]}|<:.+?>).+?#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}.*/ - if /^(#{Mx[:lv_o]}([1-6]):(\S+?)#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @format,segname,@text,@ocn=$1,$2,$3,$4 - @format="#@format~#{segname}" # - elsif /^(#{Mx[:lv_o]}([1-6]):#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @format,@text,@ocn=$1,$2,$3 - elsif /<:(.+?)>\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @format,@text,@ocn=$1,$2,$3 - elsif /^(#{Mx[:lv_o]}([1-6]):(\S+?)#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(0);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @@alt_id_count+=1 - @format,segname,@text,@ocn=$1,$2,$3,"x#{@@alt_id_count}" - @format="#@format~#{segname}" # - elsif /^(#{Mx[:lv_o]}([1-6]):#{Mx[:lv_c]})\s*(\S.+?)#{Mx[:id_o]}~(0);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @@alt_id_count+=1 - @format,@text,@ocn=$1,$2,"x#{@@alt_id_count}" - end - else - if /(.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}/m.match(@para) - @text,@ocn=$1,$2 - end - if @para !~/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}[0-9a-f]{#{@@dl}}:[0-9a-f]{#{@@dl}}#{Mx[:id_c]}|^$/ #added 2002w06 - @text=/(.+?)/m.match(@para)[1] - end - if /^(#{Mx[:lv_o]}([1-9]):\S*?#{Mx[:lv_c]})\s*(.+)/m.match(@para) - @format,@text=$1,$2 - end - end - @lev_para_ocn=if @para =~/.+<~\d+>/ #hmmm, watch - Format::ParaSiSU.new(@md,@format,@text,@ocn) - else Format::ParaSiSU.new(@md,@format,@text,'<~0>') - end - self - end - end -end __END__ - diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index adcba123..3edf67e4 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -65,7 +65,7 @@ module SiSU_TexInfo include SiSU_Viz #include Stamp ... needed removed arbitrarily 2005w05/1 (warnings about undefined flags) require "#{SiSU_lib}/texinfo_format" - include TexInfoFormat + include SiSU_Texinfo_format @tex_file=[] @@tex_backslash="\\\\" @@tabular="{tabular}" @@ -82,7 +82,6 @@ module SiSU_TexInfo @opt=opt @env=SiSU_Env::Info_env.new(@opt.fns) @st={ 'tex'=>{} } - @tex=TexInfoFormat::Texinfo.new @vz=SiSU_Env::Get_init.instance.skin end def directories @@ -129,7 +128,7 @@ module SiSU_TexInfo end class Texinfo_make include SiSU_Param - include TexInfoFormat + include SiSU_Texinfo_format @@tex_1='(?:.+?)+~' #?? debug @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" @@ -138,7 +137,7 @@ module SiSU_TexInfo @data,@md=data,md #fns @env=SiSU_Env::Info_env.new(@md.fns) @st={ 'tex'=>{} } - #@tex=TexInfoFormat::Texinfo.new + #@tex=SiSU_Texinfo_format::Texinfo.new @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern end @@ -165,7 +164,8 @@ module SiSU_TexInfo end para.gsub!(/<:p[bn]>/,'') para.gsub!(/(^|#{Mx[:gl_c]}|\s)\{(.+?)\}((?:https?|file):\/\/\S+)/,'\1(\2 [linked to:] \3)') - do_mono=TexInfoFormat::Texinfo.new(para,@md) + txt_obj={:txt =>para} + do_mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) @tex_file << do_mono.spec_char end data=@tex_file.delete_if {|x| x =~ /^0(?:\\)+~/m} @@ -244,7 +244,8 @@ module SiSU_TexInfo @@tableheader=0 data.each do |para| if para =~ /#{Mx[:tc_p]}|#{Mx[:gr_o]}T/ui - do_mono=TexInfoFormat::Texinfo.new(para,@md) + txt_obj={:txt =>para} + do_mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) para=do_mono.longtable # using longtable latex package end @tex_file << para @@ -256,8 +257,10 @@ module SiSU_TexInfo @row_break='\\\\\\' @break_page="#@row_break\n#@row_break \n" md={} - @tex_file << TexInfoFormat::Texinfo.new('',@md).head - mono=TexInfoFormat::Texinfo.new(@md.title,@md) + txt_obj={:txt =>''} + @tex_file << SiSU_Texinfo_format::Texinfo.new(@md,txt_obj).head + txt_obj={:txt =>@md.title} + mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) @tex_file << mono.topnode texinfo_menu=[] n_menu,n_submenu=0,0 @@ -265,10 +268,12 @@ module SiSU_TexInfo data.each do |para| para.gsub!(/\s*<:name#example>\s*/,' ') if para =~ /^#{Mx[:lv_o]}[1-3]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ - toc=TexInfoFormat::Texinfo.new($1,@md) + txt_obj={:txt =>$1} + toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) texinfo_menu << toc.menu elsif para =~ /^#{Mx[:lv_o]}[4-6]:\S*?#{Mx[:lv_c]}\s*(.+?)\s*$/ - toc=TexInfoFormat::Texinfo.new($1,@md) + txt_obj={:txt =>$1} + toc=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) texinfo_menu << toc.menu case para when /^#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.+?)\s*$/ @@ -297,7 +302,8 @@ module SiSU_TexInfo n_menu,n_submenu=0,0 @@do_submenu,@@do_subsubmenu=1,1 data.each do |para| - mono=TexInfoFormat::Texinfo.new(para,@md) + txt_obj={:txt =>para} + mono=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) case para when /^#{Mx[:lv_o]}1:/; mono.level1 when /^#{Mx[:lv_o]}2:/; mono.level2 @@ -310,14 +316,16 @@ module SiSU_TexInfo n_submenu+=1 @@do_subsubmenu=1 if @@do_submenu==1 - menu=TexInfoFormat::Texinfo.new(@submenu[n_menu],@md) + txt_obj={:txt =>@submenu[n_menu]} + menu=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) para="#{menu.submenu}#{mono.level5}" @@do_submenu=0 else mono.level5 end when /^#{Mx[:lv_o]}6:/; if @@do_submenu==1 - menu=TexInfoFormat::Texinfo.new(@subsubmenu[n_menu],@md) + txt_obj={:txt =>@submenu[n_menu]} + menu=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) para="#{menu.subsubmenu}#{mono.level6}" @@do_subsubmenu=0 else @@ -391,7 +399,7 @@ module SiSU_TexInfo if para =~/#{Mx[:id_o]}\\~(\d+);\w\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/ \ and para !~ /#{Mx[:br_eof]}/ parablock,paranum=/(.+?)#{Mx[:id_o]}\\~(\d+);\w\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}/im.match(para)[1,2] - do_duo=TexInfoFormat::DuoTex.new(parablock,paranum) ###is BUG + do_duo=SiSU_Texinfo_format::DuoTex.new(parablock,paranum) ###is BUG para=do_duo.paraNum if parablock end @tex_file << para @@ -400,7 +408,8 @@ module SiSU_TexInfo end def tail data=@data - tex=TexInfoFormat::Texinfo.new('',@md) + txt_obj={:txt =>''} + tex=SiSU_Texinfo_format::Texinfo.new(@md,txt_obj) data << tex.dublincore data << tex.tail end @@ -428,4 +437,3 @@ module SiSU_TexInfo end end __END__ - diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index b627b616..cdfa6a75 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -58,7 +58,7 @@ ** Description: texinfo formatting template =end -module TexInfoFormat +module SiSU_Texinfo_format @@table_pg_break_counter=1 require "#{SiSU_lib}/param" include SiSU_Param @@ -69,9 +69,19 @@ module TexInfoFormat @@tabular="{tabular}" @@tex_pattern_margin_number="\\\\marginpar.+?\s+" @@dp=nil - def initialize(data=nil,md=nil,three=nil) - @para=@one=data - @md=md + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || 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 @vz=SiSU_Env::Get_init.instance.skin @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern end @@ -79,12 +89,12 @@ module TexInfoFormat t=Time.now year=t.year filename=%{#{@md.fns}}[/(.+?)\.\w\w\d\d$/,1] - title=Texinfo.new(@md.title).spec_char + title=spec_char_string(@md.title) title=title.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") title.gsub!(/\$/,"\\$") title.gsub!(/[,]\s*/,' - ') if @md.subtitle - subtitle=Texinfo.new(@md.subtitle).spec_char + subtitle=spec_char_string(@md.subtitle) subtitle=subtitle.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") subtitle.gsub!(/\$/,"\\$") subtitle.gsub!(/[,]\s*/,' - ') @@ -150,42 +160,42 @@ WOK "#{head}#{titlepage}" end def topnode - @one=Texinfo.new(@one).spec_char - @one=@one.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") - @one.gsub!(/\$/,"\\$") - @one.gsub!(/[,]\s*/,' - ') + txt=spec_char_string(@txt) + txt=txt.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") + txt.gsub!(/\$/,"\\$") + txt.gsub!(/[,]\s*/,' - ') "@c %% 4\n" + "@ifnottex\n" + "@node Top\n" + - "@top #@one\n\n" + + "@top #{txt}\n\n" + "@insertcopying\n" + "@end ifnottex\n\n" + "@menu\n" end def dublincore - title=Texinfo.new(@md.title).spec_char if @md.title - subtitle=Texinfo.new(@md.subtitle).spec_char if @md.subtitle + title=spec_char_string(@md.title) if @md.title + subtitle=spec_char_string(@md.subtitle) if @md.subtitle dc_title="#{title} - #{subtitle}" - dc_creator=Texinfo.new(@md.dc_creator).spec_char if @md.dc_creator - dc_subject=Texinfo.new(@md.dc_subject).spec_char if @md.dc_subject - dc_description=Texinfo.new(@md.dc_description).spec_char if @md.dc_description - dc_publisher=Texinfo.new(@md.dc_publisher).spec_char if @md.dc_publisher - dc_contributor=Texinfo.new(@md.dc_contributor).spec_char if @md.dc_contributor - dc_date=Texinfo.new(@md.dc_date).spec_char if @md.dc_date - dc_date_created=Texinfo.new(@md.dc_date_created).spec_char if @md.dc_date_created - dc_date_issued=Texinfo.new(@md.dc_date_issued).spec_char if @md.dc_date_issued - dc_date_available=Texinfo.new(@md.dc_date_available).spec_char if @md.dc_date_available - dc_date_valid=Texinfo.new(@md.dc_date_valid).spec_char if @md.dc_date_valid - dc_date_modified=Texinfo.new(@md.dc_date_modified).spec_char if @md.dc_date_modified - dc_type=Texinfo.new(@md.dc_type).spec_char if @md.dc_type - dc_format=Texinfo.new(@md.dc_format).spec_char if @md.dc_format - dc_identifier=Texinfo.new(@md.dc_identifier).spec_char if @md.dc_identifier - dc_source=Texinfo.new(@md.dc_source).spec_char if @md.dc_source - dc_language=Texinfo.new(@md.dc_language[:name]).spec_char if @md.dc_language[:name] - #language_original=Texinfo.new(@md.language_original[:name]).spec_char if @md.language_original[:name] - dc_relation=Texinfo.new(@md.dc_relation).spec_char if @md.dc_relation - dc_coverage=Texinfo.new(@md.dc_coverage).spec_char if @md.dc_coverage - dc_rights=Texinfo.new(@md.dc_rights).spec_char if @md.dc_rights + dc_creator=spec_char_string(@md.dc_creator) if @md.dc_creator + dc_subject=spec_char_string(@md.dc_subject) if @md.dc_subject + dc_description=spec_char_string(@md.dc_description) if @md.dc_description + dc_publisher=spec_char_string(@md.dc_publisher) if @md.dc_publisher + dc_contributor=spec_char_string(@md.dc_contributor) if @md.dc_contributor + dc_date=spec_char_string(@md.dc_date) if @md.dc_date + dc_date_created=spec_char_string(@md.dc_date_created) if @md.dc_date_created + dc_date_issued=spec_char_string(@md.dc_date_issued) if @md.dc_date_issued + dc_date_available=spec_char_string(@md.dc_date_available) if @md.dc_date_available + dc_date_valid=spec_char_string(@md.dc_date_valid) if @md.dc_date_valid + dc_date_modified=spec_char_string(@md.dc_date_modified) if @md.dc_date_modified + dc_type=spec_char_string(@md.dc_type) if @md.dc_type + dc_format=spec_char_string(@md.dc_format) if @md.dc_format + dc_identifier=spec_char_string(@md.dc_identifier) if @md.dc_identifier + dc_source=spec_char_string(@md.dc_source) if @md.dc_source + dc_language=spec_char_string(@md.dc_language[:name]) if @md.dc_language[:name] + #language_original=spec_char_string(@md.language_original[:name]) if @md.language_original[:name] + dc_relation=spec_char_string(@md.dc_relation) if @md.dc_relation + dc_coverage=spec_char_string(@md.dc_coverage) if @md.dc_coverage + dc_rights=spec_char_string(@md.dc_rights) if @md.dc_rights dc_title="Title: #{dc_title}\n\n" if dc_title dc_creator="Creator: #{dc_creator}\n\n" if dc_creator dc_subject="Subject: #{dc_subject}\n\n" if dc_subject @@ -244,140 +254,144 @@ WOK para end def menu - para=clean(@para) + para=clean(@txt) para=para.gsub(/@footnote\{.+?\}\s+/,'') "* #{para}::" end def level1 - @para.gsub!(/#{Mx[:lv_o]}1:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}1:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level2 - @para.gsub!(/#{Mx[:lv_o]}2:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}2:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level3 - @para.gsub!(/#{Mx[:lv_o]}3:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}3:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,"\\1 \\3\n\\2") #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,'\1 \3 \2') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level4 - @para.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level5 - @para.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def level6 - @para.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') - para=clean(@para) + @txt.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') + para=clean(@txt) nd=para.gsub(/@footnote\{.+?\}\s+/,'') para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" - @para.gsub!(/.+/,"#{para}") + @txt.gsub!(/.+/,"#{para}") end def submenu - @para=@para.join("\n") - @para.gsub!(/[5]\\+~\S+/,'') - para=clean(@para) + @txt=@txt.join("\n") + @txt.gsub!(/[5]\\+~\S+/,'') + para=clean(@txt) para="@menu\n#{para}\n@end menu\n\n" - @para.gsub!(/.+/m,"#{para}") + @txt.gsub!(/.+/m,"#{para}") end def subsubmenu - @para=@para.join("\n") - @para.gsub!(/[6]\\+~\S+/,'') - para=clean(@para) + @txt=@txt.join("\n") + @txt.gsub!(/[6]\\+~\S+/,'') + para=clean(@txt) para="@menu\n#{para}\n@end menu\n\n" - @para.gsub!(/.+/m,"#{para}") + @txt.gsub!(/.+/m,"#{para}") end def indent1 - @para.gsub!(/<:i1>(.*)/,'\1') + @txt.gsub!(/<:i1>(.*)/,'\1') end def indent2 - @para.gsub!(/<:i2>(.*)/,'\1') + @txt.gsub!(/<:i2>(.*)/,'\1') + end + def spec_char_string(txt) # special characters + txt_obj={:txt =>txt} + SiSU_Texinfo_format::Texinfo.new(@md,txt_obj).spec_char end def spec_char # special characters - @para.gsub!(/#{Mx[:br_eof]}/i,'') - @para.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') - @para.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); @para.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') - @para.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); @para.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') - @para.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') - @para.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') - @para.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') - @para.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') - @para.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') - @para.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') - @para.gsub!(/&atild;<\/font><\/sup>/,' ') - @para.gsub!(/\\/,'\\backslash ') - @para.gsub!(/<:pb>/,'\\newpage') - @para.gsub!(/\\backslash copyright/,'\\copyright ') - @para.gsub!(/\^/,'\\wedge ') - @para.gsub!(/(\$)/,"\\$") - @para.gsub!(/\~/,'\\~') - @para.gsub!(/%/,"\\%") - #if @para !~ /^\s*<:image|\}:image\s/ - # @para.gsub!(/_/,'\_') + @txt.gsub!(/#{Mx[:br_eof]}/i,'') + @txt.gsub!(/#{Mx[:gl_o]}#169#{Mx[:gl_c]}/,'(c)') + @txt.gsub!(/#{Mx[:gl_o]}#(?:lt|060)#{Mx[:gl_c]}/,'<'); @txt.gsub!(/#{Mx[:gl_o]}(gt|#062)#{Mx[:gl_c]}/,'>') + @txt.gsub!(/#{Mx[:gl_o]}#123#{Mx[:gl_c]}/,'{'); @txt.gsub!(/#{Mx[:gl_o]}#125#{Mx[:gl_c]}/,'}') + @txt.gsub!(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + @txt.gsub!(/#{Mx[:gl_o]}#033#{Mx[:gl_c]}/,'!') + @txt.gsub!(/#{Mx[:gl_o]}#035#{Mx[:gl_c]}/,'#') + @txt.gsub!(/#{Mx[:gl_o]}#042#{Mx[:gl_c]}/,'*') + @txt.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'/') + @txt.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'_') + @txt.gsub!(/&atild;<\/font><\/sup>/,' ') + @txt.gsub!(/\\/,'\\backslash ') + @txt.gsub!(/<:pb>/,'\\newpage') + @txt.gsub!(/\\backslash copyright/,'\\copyright ') + @txt.gsub!(/\^/,'\\wedge ') + @txt.gsub!(/(\$)/,"\\$") + @txt.gsub!(/\~/,'\\~') + @txt.gsub!(/%/,"\\%") + #if @txt !~ /^\s*<:image|\}:image\s/ + # @txt.gsub!(/_/,'\_') #end - @para.gsub!(/_(https?:\/\/)/,'\1') - @para.gsub!(/§/i,'\S') - @para.gsub!(/£/i,'\pounds') - @para.gsub!(/å/i,'\aa') - @para.gsub!(/æ/i,'\ae') - @para.gsub!(/ø/i,'\o') - @para.gsub!(/Å/i,'\AA') - @para.gsub!(/Æ/i,'\AE') - @para.gsub!(/Ø/i,'\O') - @para.gsub!(//i,' ') - @para.gsub!(/<\/a>/i,' ') - @para.gsub!(/<:ee>/i,'') - @para.gsub!(//i,' ') - @para.gsub!(/(.+?)<\/b>/,'\*\1\*') - @para.gsub!(/(.+?)<\/i>/,'\/\1\/') - @para.gsub!(/(.+?)<\/u>/,'\_\1\_') - @para.gsub!(/@/i,'@@') - @para.gsub!(/\{/,'@{'); @para.gsub!(/\}/,'@}') - #@para.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @para.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') - @para.gsub!(/  /,' ') # ~ character for hardspace - @para.gsub!(/ /,' ') # ~ character for hardspace - @para.gsub!(/&(\S+?);/,' ') - @para.gsub!(/&/,'<=and>') - @para.gsub!(/(\s+&\s+)/,' and ') - @para.gsub!(/(\&)/,"\\&") - @para.gsub!(/"(.+?)"/,"`\\1'") # open & close " - @para.gsub!(/\s+"/," `") # open " - @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " - @para.gsub!(/"(\s|\.|,|:|;)/,"'\\1") # close " - @para.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1") # close " - @para.gsub!(/"(\.|,)/,"'") # close " - @para.gsub!(/\s+'/," `") # open ' - @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' - @para.gsub!(/(|<\/font>)/,'') - @para.gsub!(/\s*(\S+?)<\/sup>/,'^\1') - @para.gsub!(/(|<\/sup>)/,'') - @para + @txt.gsub!(/_(https?:\/\/)/,'\1') + @txt.gsub!(/§/i,'\S') + @txt.gsub!(/£/i,'\pounds') + @txt.gsub!(/å/i,'\aa') + @txt.gsub!(/æ/i,'\ae') + @txt.gsub!(/ø/i,'\o') + @txt.gsub!(/Å/i,'\AA') + @txt.gsub!(/Æ/i,'\AE') + @txt.gsub!(/Ø/i,'\O') + @txt.gsub!(//i,' ') + @txt.gsub!(/<\/a>/i,' ') + @txt.gsub!(/<:ee>/i,'') + @txt.gsub!(//i,' ') + @txt.gsub!(/(.+?)<\/b>/,'\*\1\*') + @txt.gsub!(/(.+?)<\/i>/,'\/\1\/') + @txt.gsub!(/(.+?)<\/u>/,'\_\1\_') + @txt.gsub!(/@/i,'@@') + @txt.gsub!(/\{/,'@{'); @txt.gsub!(/\}/,'@}') + #@txt.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @txt.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') + @txt.gsub!(/  /,' ') # ~ character for hardspace + @txt.gsub!(/ /,' ') # ~ character for hardspace + @txt.gsub!(/&(\S+?);/,' ') + @txt.gsub!(/&/,'<=and>') + @txt.gsub!(/(\s+&\s+)/,' and ') + @txt.gsub!(/(\&)/,"\\&") + @txt.gsub!(/"(.+?)"/,"`\\1'") # open & close " + @txt.gsub!(/\s+"/," `") # open " + @txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " + @txt.gsub!(/"(\s|\.|,|:|;)/,"'\\1") # close " + @txt.gsub!(/"([1-6-]\\+(?:~\S+)?|<.+?>)?\s*$/,"'\\1") # close " + @txt.gsub!(/"(\.|,)/,"'") # close " + @txt.gsub!(/\s+'/," `") # open ' + @txt.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' + @txt.gsub!(/(|<\/font>)/,'') + @txt.gsub!(/\s*(\S+?)<\/sup>/,'^\1') + @txt.gsub!(/(|<\/sup>)/,'') + @txt end def longtable @end_table="\\end{longtable}" @row_break='\\\\\\' - if @para[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] #CHECK !> closure + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] #CHECK !> closure no_of_cols,cols_width=$1,$2 - @@tableheader=1 if @para =~ /#{Mx[:gr_o]}Th/i + @@tableheader=1 if @txt =~ /#{Mx[:gr_o]}Th/i @w=cols_width.split(/;\s+/) @@number_of_cols=no_of_cols @colW=[] @@ -390,31 +404,31 @@ WOK @colW=@colW.join @@start_table="\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{longtable}[hb]#@colW\n" - @para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") end - if @para =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @para.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table") end - @para.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader==1 - if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u tablefoot=para[/\/,1] - @para.gsub!(/\/,'') - @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, + @txt.gsub!(/\/,'') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u, "{\\begin{tiny} {\\bfseries \\1}\\end{tiny}}&") - @para.gsub!(/&>\s*$/, + @txt.gsub!(/&>\s*$/, " #@row_break \\hline\\endhead #@row_break") - @para="#@para \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot + @txt="#{@txt} \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader=0 @@number_of_cols=0 end else - if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @para.gsub!(/&>\s*$/," #@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") + @txt.gsub!(/&>\s*$/," #@row_break") end end - @para + @txt end def scopedtable # some features related to headers have been incorporated in longtable @@ -423,7 +437,7 @@ WOK @end_table="\\end{tabular}" @row_break='\\\\\\\\' @break_page="#@row_break\n#@row_break \n" - if @para[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/ui] no_of_cols,cols_width=$1,$2 @w=cols_width.split(/;\s+/) @colW=[] @@ -432,59 +446,59 @@ WOK @colW << "p{#{col_w}cm}" if col_w end @@start_table="\\begin{tabular}{#@colW}\n" - @para.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#{@@start_table}") end - if @para =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @para.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") @@table_pg_break_counter=1 end - if @para =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u if @@table_pg_break_counter==28 # taken from 34 ideal for portrait to 28 which suits landscape - @para = + @txt = "\n\n#@end_table \n" + "#@break_page" + "#{@@start_table}\n" @@table_pg_break_counter=1 else - @para.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 - tablefoot=@para[/\/] - @para.gsub!(/\/,'') + tablefoot=@txt[/\/] + @txt.gsub!(/\/,'') end end - if @para =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - @para.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") - @para.gsub!(/&>\s*$/,"#@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,"\\begin{tiny}\\1\\end{tiny}&") + @txt.gsub!(/&>\s*$/,"#@row_break") end - @para + @txt end def graphics dir=SiSU_Env::Info_env.new(@md.fns) - @para.gsub!(/<::\s+(\S+?)\s+>/i, #watch + @txt.gsub!(/<::\s+(\S+?)\s+>/i, #watch "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}") end def image dir=SiSU_Env::Info_env.new(@md.fns) width="100" - width=@para[/<:image.+?width=``(\d+)''.+?>/im,1] + width=@txt[/<:image.+?width=``(\d+)''.+?>/im,1] width=width.to_i*0.4 - @para.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, + @txt.gsub!(/<:image\s+((?:https?|file|ftp)\S+)\s+(\S+)\s+.+\s+?>/i, "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\2}}") - @para.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, + @txt.gsub!(/<:image\s+(\S+)\s+.+\s+?>/i, "\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/\\1}") end def png # very messy clean up ! - work area, testing - z=@para[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! + z=@txt[/\\\{(.+?)\}(?:image|png)/,1] # match operator for z \\ fragile ! image,w,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') - @para.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"") # fragile match operator\\ fragile ! + @txt.gsub!(/\\\{\S+\.(png|jpg|gif).+?\}(image|png)/,"") # fragile match operator\\ fragile ! end def http # very messy clean up ! - work area, testing - z=@para[/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! - url=@para[/((?:https?|file|ftp):\S+)/im,1] - if @para =~/\.(png|jpg|gif)/ + z=@txt[/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\//,1] # match operator for z \\ fragile ! + url=@txt[/((?:https?|file|ftp):\S+)/im,1] + if @txt =~/\.(png|jpg|gif)/ image,w,x,y=z.scan(/\S+/) image.gsub!(/\\/,'') width=200 @@ -496,11 +510,11 @@ WOK end if image dir=SiSU_Env::Info_env.new(@md.fns) - @para.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/, # fragile match operator\\ fragile ! "\n\\href{#{url}}{\\includegraphics*[width=#{width}pt]{#{dir.path.image_source_tex}/#{image}}}#{caption}") else link=z[/(.+?)\\/im,1] - @para.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,"\n\\noindent\\href{#{url}}{#{link}}") # fragile match operator\\ fragile ! end end end diff --git a/lib/sisu/v0/texpdf.rb b/lib/sisu/v0/texpdf.rb index e4bd9c00..c5ee2092 100644 --- a/lib/sisu/v0/texpdf.rb +++ b/lib/sisu/v0/texpdf.rb @@ -382,8 +382,10 @@ module SiSU_TeX @md.papersize_array.each do |ps| @@tableheader={ ps => { :p => 0, :l => 0 }} para,para_p=@para.dup,@para.dup #visit - format_l=SiSU_TeX_Pdf::Format_text_object.new(md,para,ps) - format_p=SiSU_TeX_Pdf::Format_text_object.new(md,para_p,ps) + txt_obj={:txt =>para,:paper_size =>ps} + format_l=SiSU_TeX_Pdf::Format_text_object.new(md,txt_obj) + txt_obj={:txt =>para_p,:paper_size =>ps} + format_p=SiSU_TeX_Pdf::Format_text_object.new(md,txt_obj) @block[ps]={ :l => format_l.longtable_landscape, :p => format_p.longtable_portrait @@ -411,7 +413,8 @@ module SiSU_TeX end def markup_common(para) tex_f=nil - mono=SiSU_TeX_Pdf::Format_text_object.new(@md,para) + txt_obj={:txt =>para} + mono=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj) if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/ \ or @@flag_alt if para =~/#{Mx[:gr_o]}(?:code|alt|verse|group)#{Mx[:gr_c]}/ @@ -436,7 +439,8 @@ module SiSU_TeX elsif x =~/code/; @@flag_alt,@@flag_code=true,true elsif @@flag_alt if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/m - para=SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http + txt_obj={:txt =>para,:paper_size =>'a4'} + para=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http end @group_collect << para #<< "\n\n" end @@ -501,11 +505,13 @@ module SiSU_TeX end if para =~ /#{Mx[:lnk_c]}(?:https?|file|ftp)/ para=if para !~/\.(?:png|jpg|gif)/ - SiSU_TeX_Pdf::Format_text_object.new(@md,para,'a4').http + txt_obj={:txt =>para,:paper_size =>'a4'} + SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http else @block={} @md.papersize_array.each do |ps| - image=SiSU_TeX_Pdf::Format_text_object.new(@md,para,ps).http + txt_obj={:txt =>para,:paper_size =>ps} + image=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http @block[ps]={ :l => image, :p => image @@ -524,8 +530,10 @@ module SiSU_TeX title=@md.title.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') #no line splitting in heading neither html nor latex subtitle=@md.subtitle.gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}|#{Mx[:br_paragraph]}|\\\\/,' - ') if @md.subtitle #no line splitting in heading neither html nor latex @md.papersize_array.each do |ps| - orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,ps,'portrait',"#{home}: - #{title} #{subtitle}") - orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,ps,'landscape',"#{home}: - #{title} #{subtitle}") + txt_obj={:txt =>"#{home}: - #{title} #{subtitle}",:paper_size =>ps,:orientation =>'portrait'} + orient_portrait=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) + txt_obj={:txt =>"#{home}: - #{title} #{subtitle}",:paper_size =>ps,:orientation =>'landscape'} + orient_landscape=SiSU_TeX_Pdf::Format_head.new(@md,txt_obj) @@tex_head[ps][:p]=orient_portrait.document_head_with_orientation @@tex_head[ps][:l]=orient_landscape.document_head_with_orientation end @@ -544,8 +552,9 @@ WOK #end @copymark='' #check and remove as now is superflous x={} - x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_landscape - x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,@md.title,@md.subtitle).title_portrait + txt_obj={:title =>@md.title,:subtitle =>@md.subtitle} + x[:l]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_landscape + x[:p]=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).title_portrait @tex_file << x x=nil if @md.dc_creator @@ -680,7 +689,8 @@ WOK paranum=if ocn; para[m,2] else '' end - do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,parablock,paranum) + txt_obj={:txt =>parablock,:ocn =>paranum} + do_duo=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj) para=do_duo.para_num if parablock elsif para =~/^#{Mx[:id_o]}~\d+;(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #2005 this is added for tables, rationalise m=/#{Mx[:id_o]}~(\d+);(?:[oh]|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/m diff --git a/lib/sisu/v0/texpdf_format.rb b/lib/sisu/v0/texpdf_format.rb index f776dd5a..55a9473f 100644 --- a/lib/sisu/v0/texpdf_format.rb +++ b/lib/sisu/v0/texpdf_format.rb @@ -78,8 +78,24 @@ module SiSU_TeX_Pdf } @@sys=SiSU_Env::System_call.new @@dp=nil - def initialize(md,string,string1=nil) - @md,@string,@string1=md,string,string1 + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + @title =t_o[:title] || nil + @subtitle =t_o[:subtitle] || nil + @ps =t_o[:paper_size] || nil + @ocn =t_o[:ocn] || nil + @words =t_o[:words] || 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 defined? @md.image \ and @md.image =~/center/ @center_begin,@center_end='\begin{center}','\end{center}' @@ -90,12 +106,11 @@ module SiSU_TeX_Pdf @tx=SiSU_Env::Get_init.instance.tex @url_brace=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine - @ps=string1 if string1=~/(?:a4|letter|legal|book|a5|b5)/i end def longtable_landscape @end_table='\end{longtable}' @row_break='\\\\\\' - if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] no_of_cols,cols_width,ocn=$1,$2,$3 tw=case @ps when /a4/i; @tx.a4.landscape.w #European default, SiSU default @@ -106,7 +121,7 @@ module SiSU_TeX_Pdf else @tx.a4.landscape.w #default currently A4 end textwidth=(tw.to_i/2) - 24 - @@tableheader[@ps][:l]=1 if @string =~/#{Mx[:gr_o]}Th/ + @@tableheader[@ps][:l]=1 if @txt =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) @@number_of_cols=no_of_cols ||=@@number_of_cols #@@number_of_cols=0 unless @@number_of_cols.to_i > 0 @@ -122,36 +137,36 @@ module SiSU_TeX_Pdf @colW=@colW.join @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,@start_table) end - if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end - @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader[@ps][:l] == 1 - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u - tablefoot=@string[/\/,1] - @string.gsub!(/\/,'') - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') - @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") - @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u + tablefoot=@txt[/\/,1] + @txt.gsub!(/\/,'') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') + @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") + @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader[@ps][:l]=0 #@@tableheader[@ps][:l],@@number_of_cols=0,0 end else - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') - @string.gsub!(/&\s*$/," #@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u,'\1&') + @txt.gsub!(/&\s*$/," #@row_break") end end - @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string - else @string + @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt + else @txt end end def longtable_portrait @end_table='\end{longtable}' @row_break='\\\\\\' - if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:tc_p]}\\~(\d+;\w\d+;\w\d+)#{Mx[:gr_c]}/u] no_of_cols,cols_width,ocn=$1,$2,$3 tw=case @ps when /a4/i; @tx.a4.portrait.w #European default, SiSU default @@ -162,7 +177,7 @@ module SiSU_TeX_Pdf else @tx.a4.portrait.w #default currently A4 end textwidth=tw.to_i - 20 - @@tableheader[@ps][:p]=1 if @string =~/#{Mx[:gr_o]}Th/ + @@tableheader[@ps][:p]=1 if @txt =~/#{Mx[:gr_o]}Th/ w=cols_width.split(/;\s*/) @@number_of_cols=no_of_cols ||=@@number_of_cols @colW=[] @@ -178,30 +193,30 @@ module SiSU_TeX_Pdf @colW=@colW.join @start_table="#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}\n\\setlength{\\LTleft}{0pt}\n\\setlength{\\LTright}{\\fill}\n" + "\\begin{tiny}\n\\begin{longtable}#@colW\n" - @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:tc_p]}\\~\d+;\w\d+;\w\d+#{Mx[:gr_c]}/u,"#@start_table") end - if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/," #@end_table\n\\end{tiny}") end - @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') if @@tableheader[@ps][:p] == 1 - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u - tablefoot=@string[/\/,1] - @string.gsub!(/\/,'') - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') - @string.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") - @string="#@string \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|!)/u + tablefoot=@txt[/\/,1] + @txt.gsub!(/\/,'') + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\bfseries \1&') + @txt.gsub!(/&\s*$/," #@row_break \\hline\\endhead #@row_break") + @txt="#@txt \\multicolumn{#{@@number_of_cols}}{l}{\\tiny #{tablefoot}} \\\\ \\hline\n\\endfoot\n\\hline\n" if tablefoot @@tableheader[@ps][:p]=0 #@@tableheader[@ps][:p],@@number_of_cols=0,0 end else - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') - @string.gsub!(/&\s*$/," #@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_c]})/u,'\1&') + @txt.gsub!(/&\s*$/," #@row_break") end end - @string=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @string - else @string + @txt=if ocn; "#{Mx[:id_o]}~#{ocn}#{Mx[:id_c]}" + @txt + else @txt end end def scopedtable @@ -210,7 +225,7 @@ module SiSU_TeX_Pdf @end_table="\\end{tabular}" @row_break='\\\\\\\\' @break_page="#@row_break\n#@row_break \n" - if @string[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] + if @txt[/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c(\d+);(.+?)#{Mx[:gr_c]}/u] no_of_cols,cols_width=$1,$2 @w=cols_width.split(/;\s*/) @colW=[] @@ -219,28 +234,28 @@ module SiSU_TeX_Pdf @colW << "p{#{col_w}cm}" if col_w end @start_table="\\begin{tabular}{#@colW}\n" - @string.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") + @txt.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}\s+c\d+?;.+#{Mx[:gr_c]}/u,"#@start_table}") end - if @string =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ - @string.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") + if @txt =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ + @txt.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/,"#@end_table") @@table_pg_break_counter=1 end - if @string =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u + if @txt =~/#{Mx[:tc_o]}#{Mx[:tc_p]}/u if @@table_pg_break_counter == 28 # taken from 34 ideal for portrait to 28 which suits landscape - @string="\n\n#@end_table \n#@break_page#@start_table\n" + @txt="\n\n#@end_table \n#@break_page#@start_table\n" @@table_pg_break_counter=1 else - @string.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') + @txt.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}/u,'') @@table_pg_break_counter+=1 - tablefoot=@string[/\/,1] - @string.gsub!(/\/,'') + tablefoot=@txt[/\/,1] + @txt.gsub!(/\/,'') end end - if @string =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u - @string.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") - @string.gsub!(/&\s*$/,"#@row_break") + if @txt =~/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u + @txt.gsub!(/#{Mx[:tc_p]}\d+?#{Mx[:tc_p]}(.+?)(?:#{Mx[:tc_p]}|#{Mx[:tc_p]})/u,"\\1&") + @txt.gsub!(/&\s*$/,"#@row_break") end - @string + @txt end def heading_major(para,lev) #\emph{ title=@md.title @@ -264,90 +279,90 @@ module SiSU_TeX_Pdf para end def level1 - heading_major(@string,1) + heading_major(@txt,1) end def level2 - heading_major(@string,2) + heading_major(@txt,2) end def level3 - heading_major(@string,3) + heading_major(@txt,3) end def level4 - @string.strip! if @string - @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') - cont_ln=@string.dup + @txt.strip! if @txt + @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') + cont_ln=@txt.dup cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{@@tex_backslash*2}/,"#{@@tex_backslash*4}") # added w42 cont_ln.gsub!(/#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 title=@md.title - @string.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') - if @string =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ + @txt.gsub!(/#{@md.lv4}\s+(#{@md.lv4})/m,'\1') + if @txt =~/#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|<:4-endnotes>/ # watch exclusion removes endnotes marker from pdf 2003w03 - @string.gsub!(/.+/m,'') + @txt.gsub!(/.+/m,'') end - if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! + if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - if @string !~/#{Mx[:lv_o]}4:/ - @string.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} + if @txt !~/#{Mx[:lv_o]}4:/ + @txt.gsub!(/(#{@md.lv4}.*)\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") else - @string.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} + @txt.gsub!(/^\s*#{Mx[:lv_o]}4:\S+?#{Mx[:lv_c]}\s*(.*)?\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsection}{#{cont_ln}} \\markright{#{title}}") end - @string.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1') + @txt.gsub!(/#{@md.lv4}\s*(.marginpar)/m,'\1') end def level5 - # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@string*, same for next section 2002w46 - @string.strip! if @string - @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') - cont_ln=@string.dup + # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\@txt*, same for next section 2002w46 + @txt.strip! if @txt + @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') + cont_ln=@txt.dup cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\\&/,' and ') #revisit: tmp bugfix 200507, substitutes & with 'and' in toc, needed e.g. for AT&T, see ffa - @string.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') - if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! + @txt.gsub!(/#{@md.lv5}\s+(#{@md.lv5})/m,'\1') + if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - if @string !~/#{Mx[:lv_o]}5:/ - @string.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} + if @txt !~/#{Mx[:lv_o]}5:/ + @txt.gsub!(/(#{@md.lv5}.*?)\n?$/m,"\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") else - @string.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, + @txt.gsub!(/^\s*#{Mx[:lv_o]}5:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, "\\subsubsection*{\\1} \\addcontentsline{toc}{subsubsection}{#{cont_ln} \\\\ }") end - @string.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1') + @txt.gsub!(/#{@md.lv5}\s*(.marginpar)/m,'\1') end def level6 - # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@string*, same for previous section 2002w46 - @string.strip! if @string - @string.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') - cont_ln=@string.dup + # there is a problem here with creation of headers does not do what you would want it to header starts with a * and is not in bold work on \\sub@txt*, same for previous section 2002w46 + @txt.strip! if @txt + @txt.gsub!(/(?:\\begin\{bfseries\}|\\begin\{itshape\})(.+?)(?:\\end\{bfseries\}|\\end\{itshape\})/m,'\1') + cont_ln=@txt.dup cont_ln.gsub!(@@tex_pattern_margin_number,'') cont_ln.gsub!(/#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*/,'') cont_ln.gsub!(/\\footnote\[\d+\]\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 cont_ln.gsub!(/\\Footnote[A]\{[*+]+\d*\}\{%.+?\\end\{scriptsize\}\s*\}/m,'') #arbitrary bugfix, revisit should not be necessary, eg. wta.1994 2004w22 - @string.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') - if @string =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! + @txt.gsub!(/#{@md.lv6}\s+(#{@md.lv6})/m,'\1') + if @txt =~/\\footnote/ #and para =~/^[1-6]#{@@tilde}/ # removing footnotes from headings! cont_ln.gsub!(/\s*\\footnote\[\d+\]\{%\n .+? \}\s*/,' ') cont_ln.gsub!(/\s*\\Footnote[A]\{[*+]+\d*\}\{%\n .+? \}\s*/,' ') end - @string.gsub!(/(#{@md.lv6}.*)\n?$/m, - "\\subsubsection*{\\1}") if (@string !~/#{Mx[:lv_o]}6:/) - @string.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, + @txt.gsub!(/(#{@md.lv6}.*)\n?$/m, + "\\subsubsection*{\\1}") if (@txt !~/#{Mx[:lv_o]}6:/) + @txt.gsub!(/^\s*#{Mx[:lv_o]}6:\S*?#{Mx[:lv_c]}\s*(.*)?\n?$/m, '\subsubsection*{\1}') - @string.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') + @txt.gsub!(/#{@md.lv6}\s*(.marginpar)/m,'\1') #end BUGWATCH end def indent(lev) @@ -362,25 +377,25 @@ para when /8/; '70mm' when /9/; '80mm' end - @string.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, + @txt.gsub!(/#{Mx[:pa_o]}:i#{lev}#{Mx[:pa_c]}\s*(.*)/m, "\\begin{ParagraphIndent}{#{indent}}\\1 \\end{ParagraphIndent}}") end def symbol_graphic dir=SiSU_Env::Info_env.new(@md.fns) - image='c_' + /<:=\s*(\S+?)\s*>/m.match(@string).captures.join + '.png' #watch + image='c_' + /<:=\s*(\S+?)\s*>/m.match(@txt).captures.join + '.png' #watch if FileTest.file?("#{dir.path.image_source_tex}/#{image}") - @string.gsub!(/<:=\s*(\S+?)\s*>/, + @txt.gsub!(/<:=\s*(\S+?)\s*>/, "\\includegraphics*[width=11pt]{#{dir.path.image_source_tex}/c_\\1.png}") else tell=SiSU_Screen::Ansi.new(@md.cmd,"ERROR - image:",%{"#{image}" missing},"search path: #{dir.path.image_source_tex}") tell.error2 unless @md.cmd =~/q/ - @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/,'') # fragile match operator\\ fragile ! end end def image dir=SiSU_Env::Info_env.new(@md.fns) - image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@string).captures + image,m=/#{Mx[:lnk_o]}\s*(\S+)\s+.+?width=``(\d+)''.+?#{Mx[:lnk_c]}/m.match(@txt).captures width=m[1] || '100' width=width.to_i*0.4 image_source=if @md.fns =~/\.(?:ssm\.)?sst$/ \ @@ -397,17 +412,17 @@ para nil end if image_source - @string.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/, + @txt.gsub!(/#{Mx[:lnk_o]}\s*((?:https?|file|ftp):\/\/\S+)\s+(\S+).+?#{Mx[:lnk_c]}/, @center_begin + "\\href{\\1}{\\includegraphics*[width=#{width}pt]{#{image_source}/\\2}}" + @center_end ) - @string.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/, + @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/, @center_begin + "\\includegraphics*[width=#{width}pt]{#{image_source}/\\1}" + @center_end ) - else @string.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}') + else @txt.gsub!(/#{Mx[:lnk_o]}\s*(\S+)\s+.+?#{Mx[:lnk_c]}/,'\1}') end end def png #fc missing image check dir=SiSU_Env::Info_env.new(@md.fns) # messy clean up - z=@string[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @string =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile ! + z=@txt[/#{Mx[:lnk_o]}(\S.+?)#{Mx[:lnk_c]}(?:image|png)/,1].strip if @txt =~ /#{Mx[:lnk_o]}\S.+?#{Mx[:lnk_c]}(?:image|png)/ # match operator for z \\ fragile ! if z #debug 2004w14 image=z[/(\S+?\.(?:png|jpg|gif)\b)/m] image.gsub!(/\\/,'') @@ -438,18 +453,18 @@ para nil end if image_source - @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile ! + @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/, # fragile match operator\\ fragile ! "#@center_begin\n\\includegraphics*[width=#{width}pt]{#{image_source}/#{image}}#{caption}#@center_end") - else @string.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'') + else @txt.gsub!(/#{Mx[:lnk_o]}\S+\.(png|jpg|gif).+?#{Mx[:lnk_c]}(image|png)/,'') end end def http_word_mode #(orientation='') # clean up ! - work area, testing dir=SiSU_Env::Info_env.new(@md.fns) - @words=[] + @w=[] @url_generic_rgx=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+/ - @string.each do |word| - @words << if word=~@url_generic_rgx + @words.each do |word| + @w << if word=~@url_generic_rgx if word =~/#{Mx[:lnk_o]}(?:.+?)#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?(?:[;.,]?(?:\s|$)|(?:\s|$))/ regx_url=%r/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)(?:[;.,]?(?:\s|$)|(?:\s|$))/ punctuate=/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?([;.,]?(?:\s|$))/.match(word).captures.join @@ -521,20 +536,21 @@ para else word end end - @words=@words.join - @words + @txt=@w.join + @txt end def http - wm=@string.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) - @string=SiSU_TeX_Pdf::Format_text_object.new(@md,wm,@ps).http_word_mode #GET PAPER SIZE AND USE IT + wm=@txt.dup.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\S+|image)|\w+\s*|./m) + txt_obj={:words =>wm,:paper_size =>@ps} + @txt=SiSU_TeX_Pdf::Format_text_object.new(@md,txt_obj).http_word_mode #GET PAPER SIZE AND USE IT end def title - @string=SiSU_TeX_Pdf::Special_characters.new(@md,@string).special_characters_safe - if @string1 - @string1=SiSU_TeX_Pdf::Special_characters.new(@md,@string1).special_characters_safe - @string1.gsub!(/\$/,"\\$") - "\n\\title{#@string#{@@tex_backslash*2} \\textbf{\\normalsize #@string1}\\normalsize}" - else "\n\\title{#@string}" + @txt=SiSU_TeX_Pdf::Special_characters.new(@md,@title).special_characters_safe + if @subtitle + @subtitle=SiSU_TeX_Pdf::Special_characters.new(@md,@subtitle).special_characters_safe + @subtitle.gsub!(/\$/,"\\$") + "\n\\title{#@title#{@@tex_backslash*2} \\textbf{\\normalsize #@subtitle}\\normalsize}" + else "\n\\title{#@txt}" end end def title_landscape @@ -547,33 +563,49 @@ para paranumber_display=if @md.markup.inspect =~/no_ocn/ \ or @md.mod.inspect =~/--no-ocn/ '' - else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@string1\\end{tiny}}}" #ocn object citation numbering + else "\\begin{tiny}~\\end{tiny}{\\marginpar{\\begin{tiny}#@ocn\\end{tiny}}}" #ocn object citation numbering end - if @string !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ - @string.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect + if @txt !~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}|<:.+?>|#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6})/ + @txt.gsub!(/^\s*(.+)/m,"#{paranumber_display}\\1\n") #watch - in 1-6 is suspect else - if (@string =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect - @string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect - #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect - #@string.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect - @string.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? - #@string.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? + if (@txt =~/^(?:#{Mx[:lv_o]}[1-6a-z-]:|#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})/) #watch - in 1-6 is suspect + @txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #watch - in 1-6 is suspect + #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\begin{bfseries}\\2 \\end{bfseries}\n") #watch - in 1-6 is suspect + #@txt.gsub!(/^(#{Mx[:lv_o]}[1-6a-z-]:\S*?#{Mx[:lv_c]})\s*(.+)/m,"\\1 #{paranumber_display} \\emph{\\2}\n") #watch - in 1-6 is suspect + @txt.gsub!(/^(#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]})\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? + #@txt.gsub!(/^(<:.+?>)\s*(.+)/m,"\\1 #{paranumber_display}\\2\n") #WHAT? else - @string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") - #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") - #@string.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") + @txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\1\n") + #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display} \\begin{bfseries}\\1 \\end{bfseries}\n") + #@txt.gsub!(/((#{@md.lv1}|#{@md.lv2}|#{@md.lv3}|#{@md.lv4}|#{@md.lv5}|#{@md.lv6}).+)$/,"\\2 #{paranumber_display}\\emph{\\1}\n") end end - @string + @txt end end class Format_head - def initialize(md,ps,layout=nil,string1=nil) - @md,@ps,@layout,@string1=md,ps,layout,string1 + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] || nil + #@title =t_o[:title] || nil + @subtitle =t_o[:subtitle] || nil + @ps =t_o[:paper_size] || nil + @ocn =t_o[:ocn] || nil + @layout=t_o[:orientation] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + p t_o.class + p caller + end + @tx=SiSU_Env::Get_init.instance.tex @url_brace=SiSU_Viz::Skin.new.url_decoration @tex2pdf=@@tex3pdf ||=SiSU_Env::System_call.new.tex2pdf_engine - @ps=@string if @string=~/(?:a4|letter|legal|book|a5|b5)/i + @ps=@txt if @txt=~/(?:a4|letter|legal|book|a5|b5)/i end def language @lang=if @md.dc_language[:code] @@ -786,7 +818,7 @@ WOK \\usepackage{thumbpdf} \\usepackage[#{@tex2pdf}, #{color.strip} - pdftitle={#@string1}, + pdftitle={#{@txt}}, % pdftitle={Untitled}, pdfauthor={LM-sisu-scribe}, pdfsubject={law}, @@ -820,7 +852,7 @@ WOK \\definecolor{myblue}{rgb}{0,0,0.5} \\definecolor{mywhite}{rgb}{1,1,1} WOK - elsif @string =~/dvi/ + elsif @txt =~/dvi/ <') #unless @string=~/<:code>/ # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>') # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>') # \ SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX @@ -1095,7 +1127,7 @@ WOK end def xetex_special_characters_1(string) # ~ ^ $ & % _ { } #LaTeX special characters - KEEP list #p @@utf_8.list - #string=Iconv.conv('ISO-8859-1', 'UTF-8', @string) + #string=Iconv.conv('ISO-8859-1', 'UTF-8', @txt) word=string.scan(/\S+|\n/) #unless line =~/^(?:0~\S|%+\s)/ para_array=[] string=if word @@ -1138,7 +1170,7 @@ WOK string.gsub!(/#{Mx[:gl_o]}#045#{Mx[:gl_c]}/,'-') # - SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#043#{Mx[:gl_c]}/,'+') # + SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#044#{Mx[:gl_c]}/,',') # + SiSU special character also LaTeX - string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @string=~/<:code>/ # / SiSU special character also LaTeX + string.gsub!(/#{Mx[:gl_o]}#038#{Mx[:gl_c]}/,'<=amp>') #unless @txt=~/<:code>/ # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#047#{Mx[:gl_c]}/,'<=slash>') # / SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#092#{Mx[:gl_c]}/,'<=backslash>') # \ SiSU special character also LaTeX string.gsub!(/#{Mx[:gl_o]}#095#{Mx[:gl_c]}/,'<=underscore>') # _ SiSU special character also LaTeX @@ -1275,33 +1307,33 @@ WOK string end def special_characters #special characters - some substitutions are sequence sensitive, rearrange with care. - string=@string + string=@txt case @tex2pdf when /pdf/ string=pdftex_special_characters_1(string) unless string.nil? - string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@string) + string=special_characters_unsafe_1(string) unless string.nil? #pdftex_special_characters_unsafe_1(@txt) string=pdftex_special_characters_2(string) unless string.nil? string=pdftex_special_characters_3(string) unless string.nil? when /xe/ string=xetex_special_characters_1(string) unless string.nil? - string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@string) + string=special_characters_unsafe_1(string) unless string.nil? #xetex_special_characters_unsafe_1(@txt) string=xetex_special_characters_2(string) unless string.nil? #issues with xetex string=xetex_special_characters_3(string) unless string.nil? end - @string=string + @txt=string end def special_characters_safe #special characters - some substitutions are sequence sensitive, rearrange with care. - string=@string + string=@txt case @tex2pdf when /pdf/ - string=pdftex_special_characters_1(@string) unless string.nil? - string=pdftex_special_characters_2(@string) unless string.nil? - #special_characters_3(@string) + string=pdftex_special_characters_1(@txt) unless string.nil? + string=pdftex_special_characters_2(@txt) unless string.nil? + #special_characters_3(@txt) when /xe/ - string=xetex_special_characters_1(@string) unless string.nil? - string=xetex_special_characters_2(@string) unless string.nil? # remove this to start with, causes issues + string=xetex_special_characters_1(@txt) unless string.nil? + string=xetex_special_characters_2(@txt) unless string.nil? # remove this to start with, causes issues end - @string=string + @txt=string end end class Use_TeX diff --git a/lib/sisu/v0/xhtml.rb b/lib/sisu/v0/xhtml.rb index 593d26c4..95da5d2d 100644 --- a/lib/sisu/v0/xhtml.rb +++ b/lib/sisu/v0/xhtml.rb @@ -289,7 +289,8 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + txt_obj={:txt =>@sto.text} + format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_structure(para,$1,@sto.ocn,$2) @@ -342,26 +343,29 @@ WOK and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ elsif para =~/(MetaData)/ \ and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'
    MetaData') + txt_obj={:txt =>'
    MetaData'} + format_scroll=Format_scroll.new(@md,txt_obj) para=format_scroll.bold_para elsif para =~/(Owner Details)/ \ and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_scroll=Format_scroll.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_scroll=Format_scroll.new(@md,txt_obj) @@xml[:owner_details]=format_scroll.bold_para para='' - elsif para =~/(.*)<:#>(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum - end - if para =~// \ - and para =~/^(-\{{2}~\d+|)/ # -endnote - para='' + #elsif para =~/(.*)<:#>(.*)/ + # one,two=$1,$2 + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end + #if para =~// \ + #and para =~/^(-\{{2}~\d+|)/ # -endnote + # para='' + #end para=case para when /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ if para =~/.*<:#>.*$/ - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end else para @@ -369,11 +373,6 @@ WOK if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml.rb b/lib/sisu/v0/xml.rb index 2531a962..1fc6d221 100644 --- a/lib/sisu/v0/xml.rb +++ b/lib/sisu/v0/xml.rb @@ -313,7 +313,8 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + txt_obj={:txt =>@sto.text} + format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_structure(para,$1,@sto.ocn,$2) @@ -362,17 +363,20 @@ WOK and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ elsif para =~/(MetaData)/ \ and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'
    MetaData') + txt_obj={:txt =>'
    MetaData'} + format_scroll=Format_scroll.new(@md,txt_obj) para=format_scroll.bold_para elsif para =~/(Owner Details)/ \ and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_scroll=Format_scroll.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_scroll=Format_scroll.new(@md,txt_obj) @@xml[:owner_details]=format_scroll.bold_para para='' - elsif para =~/(.*)(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum + #elsif para =~/(.*)(.*)/ + # one,two=$1,$2 + # #txt_obj={:txt =>@sto.txt} + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end if para =~// \ and para =~/^(-\{{2}~\d+|)/ # -endnote @@ -380,18 +384,14 @@ WOK end if para =~/.*<:#>.*$/ #investigate removal para=if para =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para diff --git a/lib/sisu/v0/xml_dom.rb b/lib/sisu/v0/xml_dom.rb index 38ba0a87..b2bc0de7 100644 --- a/lib/sisu/v0/xml_dom.rb +++ b/lib/sisu/v0/xml_dom.rb @@ -371,7 +371,8 @@ WOK unless @rcdc m=/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[1-9]|ordinary/ + txt_obj={:txt =>@sto.text} + format_scroll=SiSU_XML_format::Format_scroll.new(@md,txt_obj) if @sto.format =~/i[1-9]|ordinary/ case @sto.format when /^(1):(\S*)/ xml_markup(para) @@ -438,17 +439,19 @@ WOK #para=format_scroll.boldPara elsif para =~/(MetaData)/ \ and para =~/#{Mx[:id_o]}~\d+;[m]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'
    MetaData') + txt_obj={:txt =>'
    MetaData'} + format_scroll=Format_scroll.new(@md,txt_obj) para=format_scroll.bold_para elsif para =~/(Owner Details)/ \ and para !~/#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ - format_scroll=Format_scroll.new(@md,'
    Owner Details') + txt_obj={:txt =>'
    Owner Details'} + format_scroll=Format_scroll.new(@md,txt_obj) @@xml[:owner_details]=format_scroll.bold_para para='' - elsif para =~/(.*)<:#>(.*)/ - one,two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum + #elsif para =~/(.*)<:#>(.*)/ + # one,two=$1,$2 + # format_text=Format_text_object.new(one,two) + # para=format_text.seg_no_paranum end if para =~// \ and para =~/^(-\{{2}~\d+|)/ # -endnote @@ -456,18 +459,14 @@ WOK end if para =~/.*<:#>.*$/ para=if para =~ /#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/ - format_text=Format_text_object.new(para,'') + txt_obj={:txt =>para} + format_text=Format_text_object.new(@md,txt_obj) format_text.scr_inden_ocn_e_no_paranum end end if para !~/#{@vz.margin_txt_0}|#{@vz.margin_txt_1}|#{@vz.margin_txt_2}/ # i don't get the condition for no paranum end - if para =~/<:center>/ - one,two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one,two) - para=format_text.center - end else # end para.gsub!(/#{Mx[:pa_o]}:\S+#{Mx[:pa_c]}/,'') if para 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