diff options
author | Ralph Amissah <ralph@amissah.com> | 2008-09-16 00:36:14 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2008-09-16 00:36:14 -0400 |
commit | bc9228c42269bfb4d451ca2d2d92a6a12afb094f (patch) | |
tree | 42b666a81ef350d0ff6153a49d159b3a1c348959 /lib/sisu/v0/html_tune.rb | |
parent | Updated sisu-0.68.0 (diff) | |
parent | fixes: alphabet list (concordance, dal_idx), and file types (dal_expand_inser... (diff) |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib/sisu/v0/html_tune.rb')
-rw-r--r-- | lib/sisu/v0/html_tune.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 11976af9..99f2d7f4 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -236,7 +236,6 @@ module SiSU_Tune para.gsub!(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;') para.gsub!(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;') para.gsub!(/#{Mx[:br_line]}|#{Mx[:br_nl]}/,'<br />') - para.gsub!(/(?:\s*#{Mx[:br_page]}\s*|\s*#{Mx[:br_page_new]}\s*)+/m,'<p><hr width=90% /></p>') # else clean '' para.gsub!(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'<b>\1</b>') para.gsub!(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'<i>\1</i>') para.gsub!(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'<u>\1</u>') @@ -246,6 +245,7 @@ module SiSU_Tune para.gsub!(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>') para.gsub!(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>') para.gsub!(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,'<a name="\1"></a>') + para.gsub!(/#{Mx[:nbsp]}/,' ') para.gsub!(/<(p|br)>/,'<\1 />') para=SiSU_Tune::Clean_html.new(para).clean @tuned_file << para @@ -254,10 +254,10 @@ module SiSU_Tune def urls(data) @words=[] data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|file|ftp)\S+|image)/ - if word =~/\{.+?\}(?:(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)[;.,]?(?:\s|$)/ - m,u,d=/\{(.+?)\}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)([;.,]?(?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|file|ftp)\S+|image)/.match(word).captures + @words << if word=~/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ + if word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)[;.,]?(?:\s|$)/ + m,u,d=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?|image)([;.,]?(?:\s|$))/.match(word).captures + else m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/.match(word).captures d='' end case m @@ -276,13 +276,13 @@ module SiSU_Tune %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{caption}} else %{<img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0">#{caption}} end - word.gsub!(/\{.+?\}((?:https?|file|ftp)\S+|image)/,ins) + word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/,ins) else link=m[/(.+)/m] png=m.scan(/\S+/)[0].strip link=link.strip ins=%{<a href="#{u}">#{link}</a>#{d}} - word.gsub!(/\{.+?\}(?:https?|file|ftp)\S+/,ins) + word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:https?|file|ftp)\S+/,ins) end word else word @@ -313,8 +313,8 @@ module SiSU_Tune para.gsub!(/<:image\s+(\S+)\s+>/, %{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">}) end - if para =~/\{.+?\}((?:https?|file|ftp)\S+|image)/ - @word_mode=para.scan(/\{.+?\}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u) + if para =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}((?:https?|file|ftp)\S+|image)/ + @word_mode=para.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:(?:https?|file|ftp)\S+|image)|(?:#{Mx[:gl_o]}\S+?#{Mx[:gl_c]})+|\S+/u) words=urls(@word_mode) para.gsub!(/.+/m,words) end @@ -336,7 +336,7 @@ module SiSU_Tune para.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<<a href="mailto:\1">\1</a>>') end para.gsub!(/\b[_\\]((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration - para.gsub!(/((?:^|\s)[}])((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url + para.gsub!(/((?:^|\s)#{Mx[:lnk_c]})((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url para.gsub!(/(^|#{Mx[:gl_c]}|\s)((?:https?|file|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?=\s|$))/,%{\\1#{@url_brace.xml_open}<a href="\\2" target="_top">\\2</a>#{@url_brace.xml_close}\\3}) #http ftp matches with decoration if para =~/..\/\S+/ \ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ |