diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-01-23 21:42:25 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-01-23 21:42:27 -0500 |
commit | 21f5e220b738add01c19c2b15a76f2d240b2c0d5 (patch) | |
tree | 287dac6e47cab1da0d0567e9dc79683bc8d757b0 /lib/sisu/v3dv/shared_html_lite.rb | |
parent | v3dv: call most methods by full name (include associated module & class names) (diff) |
v3dv: replace use of most ruby exclamation (!) method actionssisu_3.1.12
Diffstat (limited to 'lib/sisu/v3dv/shared_html_lite.rb')
-rw-r--r-- | lib/sisu/v3dv/shared_html_lite.rb | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/lib/sisu/v3dv/shared_html_lite.rb b/lib/sisu/v3dv/shared_html_lite.rb index 5fd0a408..94413c69 100644 --- a/lib/sisu/v3dv/shared_html_lite.rb +++ b/lib/sisu/v3dv/shared_html_lite.rb @@ -109,16 +109,16 @@ module SiSU_FormatShared %{<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_FormatShared 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 @@ -140,32 +140,32 @@ module SiSU_FormatShared 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,'~') + 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_FormatShared 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 |