diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:07:29 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-03-19 22:07:33 -0400 |
commit | 6811ac91f21a434fc7d967c11e1b20f33918c6ea (patch) | |
tree | 30f39674ca96a79f8a604a9f02d571f24320e221 /lib/sisu/v3/shared_html_lite.rb | |
parent | v3: 3.2.0 version & changelog "opened" (diff) |
v3: 3.2 branch is main (v3dv --> v3); dev (v3dv) branch directories removed
* v3dv (3.2) "merged" into v3 (previously 3.1) (& removed)
* conf/sisu/v3dv --> conf/sisu/v3
* data/sisu/v3dv --> data/sisu/v3
* lib/sisu/v3dv --> lib/sisu/v3
* bin/sisu* (v3dv references changed to v3)
* (--dev modifier (superfluous for the time being) runs main v3 branch)
Diffstat (limited to 'lib/sisu/v3/shared_html_lite.rb')
-rw-r--r-- | lib/sisu/v3/shared_html_lite.rb | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/lib/sisu/v3/shared_html_lite.rb b/lib/sisu/v3/shared_html_lite.rb index 85b1b40e..27a228eb 100644 --- a/lib/sisu/v3/shared_html_lite.rb +++ b/lib/sisu/v3/shared_html_lite.rb @@ -57,7 +57,7 @@ xml/xhtml/html formatting =end -module SiSU_Format_Shared +module SiSU_FormatShared require_relative 'defaults' # defaults.rb include SiSU_Viz class CSS_Format @@ -68,7 +68,7 @@ module SiSU_Format_Shared @md,@t_o=md,t_o @txt=@t_o.obj @id=@ocn=@t_o.ocn if defined? @t_o.ocn - @lv=@t_o.lv.to_s if @t_o.is=='heading' + @lv=@t_o.lv.to_s if @t_o.is==:heading if @md.fns != @@fns @@fns,@@hname=@md.fns,'' end @@ -80,13 +80,13 @@ module SiSU_Format_Shared @tab="\t" @brace_url=SiSU_Viz::Skin.new.url_decoration @@tablehead,@@tablefoot=[],[] - @vz=SiSU_Env::Get_init.instance.skin - @env=SiSU_Env::Info_env.new(@md.fns) + @vz=SiSU_Env::GetInit.instance.skin + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" end def urls(data) @words=[] - map_nametags=SiSU_Particulars::Combined_singleton.instance.get_map_nametags(@md).nametags_map + map_nametags=SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map data.each do |word| @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/ @@ -109,16 +109,16 @@ module SiSU_Format_Shared %{<a href="#{u}">[#{png}]</a>#{caption}} else %{[#{png}] #{caption}} end - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else u=case u when /^https?:\/\// u when /^:/ - u.gsub!(/^:/,'') + u=u.gsub(/^:/,'') "#{@env.url.root}/#{u}" when /^\.\.\// # can remove - u.gsub!(/^\.\.\//,'') + u=u.gsub(/^\.\.\//,'') "#{@env.url.root}/#{u}" else "#{@env.url.root}/#{@md.fnb}/#{map_nametags[u][:segname]}#{Sfx[:html]}##{u}" @@ -127,8 +127,8 @@ module SiSU_Format_Shared png=m.scan(/\S+/)[0].strip link=link.strip ins=%{<a href="#{u}">#{link}</a>} - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins) - word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) + word=word.gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,ins). + gsub(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/,ins) word end word @@ -139,33 +139,33 @@ module SiSU_Format_Shared @words=@words.join(' ') end def markup_generic(s) - s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') - s=s.gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') - s=s.gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') - s=s.gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"') - s=s.gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+') - s=s.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-') - s=s.gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>') - s=s.gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>') - s=s.gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>') # tt, kbd - s=s.gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') + s=s.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>'). + gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>'). + gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>'). + gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'"\1"'). + gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'+{\1}+'). + gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strke_c]}/,'-{\1}-'). + gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'<sup>\1</sup>'). + gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'<sub>\1</sub>'). + gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'<tt>\1</tt>'). # tt, kbd + gsub(/#{Mx[:gl_o]}#(?:126|152)#{Mx[:gl_c]}/i,'~') end def markup_object(t_o) s=t_o.obj - if t_o.is !='code' + s=if t_o.is !=:code s=markup_generic(s) if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)/ wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}|image)|\S+/) words=urls(wm) - s.gsub!(/.+/m,words) + s=s.gsub(/.+/m,words) end - s.gsub!(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - s.gsub!(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - s.gsub!(/#{Mx[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration - s.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>') #special case \{ e.g. \}http://url - s.gsub!(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}<a href="\\2" target="_top">\\2</a>#{@brace_url.xml_close}\\3}) #http ftp matches with decoration + s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:url_o]}[_\\](\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>'). #special case \{ e.g. \}http://url + gsub(/(^|#{Mx[:gl_c]}|\s)#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{\\1#{@brace_url.xml_open}<a href="\\2" target="_top">\\2</a>#{@brace_url.xml_close}\\3}) #http ftp matches with decoration else - s.gsub!(/</m,'<'); s.gsub!(/>/m,'>') + s.gsub(/</m,'<'); s.gsub!(/>/m,'>') end s end @@ -176,11 +176,11 @@ module SiSU_Format_Shared words=urls(wm) s=s.gsub(/.+/m,words) end - s=s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;') - s=s.gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;') - s=s.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - s=s.gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>') #special case \{ e.g. \}http://url - s=s.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration + s=s.gsub(/#{Mx[:gl_o]}(#[0-9]{3})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:gl_o]}#([a-z]{2,4})#{Mx[:gl_c]}/u,'&\1;'). + gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>\2'). #http ftp matches escaped, no decoration + gsub(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,'\1<a href="\2" target="_top">\2</a>'). #special case \{ e.g. \}http://url + gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration end def paragraph %{<p class="h#{@lv}" type="substantive" header="#{@hname}">#{@txt}</p>\n} # << "\n" @@ -252,39 +252,39 @@ GSUB @txt.split(/\n/).each do |parablock| m=parablock[/<!f(.+?)!>/,1] @@tablefoot << m if m - parablock.gsub!(/<!f.+?!>/,'') + parablock=parablock.gsub(/<!f.+?!>/,'') @@tablehead=1 if parablock =~/#{Mx[:gr_o]}Th#{Mx[:tc_p]}/u - parablock.gsub!(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/, - %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}) + parablock=parablock.gsub(/#{Mx[:gr_o]}Th?#{Mx[:tc_p]}.+?#{Mx[:tc_p]}~(\d+)#{Mx[:gr_c]}/, + %{<table summary="normal text css" width="100%" border="0" bgcolor="white" cellpadding="2" align="center">}) if parablock =~/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/ tablefoot=[] @@tablefoot.each {|x| tablefoot << %{<p align="center"><font size=2><i>#{x}</i></font></p>\n}} @@tablefoot=[] - parablock.gsub!(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/, + parablock=parablock.gsub(/#{Mx[:gr_o]}TZ#{Mx[:gr_c]}/, %{#{@vz.table_close}\n}) # + end if @@tablehead==1 if parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u - parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{\n<tr>} + - %{\n<td width="\\1%" valign="top">} + - %{#{para_table}<b>}) - parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{</b></td><td width="\\1%" valign="top">} + - %{#{para_table}<b>}) - parablock.gsub!(/#{Mx[:tc_c]}/, '</b></td></tr>') + parablock=parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n<tr>} + + %{\n<td width="\\1%" valign="top">} + + %{#{para_table}<b>}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{</b></td><td width="\\1%" valign="top">} + + %{#{para_table}<b>}). + gsub(/#{Mx[:tc_c]}/, '</b></td></tr>') @@tablehead=0 end parablock else - parablock.gsub!(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{\n<tr>} + - %{\n<td width="\\1%" valign="top">} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, - %{</td><td width="\\1%" valign="top">} + - %{#{para_table}}) - parablock.gsub!(/#{Mx[:tc_c]}/, '</td></tr>') + parablock=parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{\n<tr>} + + %{\n<td width="\\1%" valign="top">} + + %{#{para_table}}). + gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, + %{</td><td width="\\1%" valign="top">} + + %{#{para_table}}). + gsub(/#{Mx[:tc_c]}/, '</td></tr>') parablock end @new_content << parablock @@ -292,7 +292,7 @@ GSUB @new_content.join end end - 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 + class CSS_FormatGeneric #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" @attrib=attrib |