diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-05-26 13:18:31 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-05-26 13:18:31 -0400 |
commit | fec639c59a032977b87ff49920e74ae08d485f04 (patch) | |
tree | 938c32c8a74fe39177afb5255ac229c599e0186b /lib/sisu/v2/shared_html_lite.rb | |
parent | sysenv, require constants, (issue with webrick) (diff) |
output formats internal document (and relative) linking as possible
Diffstat (limited to 'lib/sisu/v2/shared_html_lite.rb')
-rw-r--r-- | lib/sisu/v2/shared_html_lite.rb | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/sisu/v2/shared_html_lite.rb b/lib/sisu/v2/shared_html_lite.rb index 6303691b..c1f53e10 100644 --- a/lib/sisu/v2/shared_html_lite.rb +++ b/lib/sisu/v2/shared_html_lite.rb @@ -62,6 +62,7 @@ module SiSU_Format_Shared include SiSU_Viz class CSS_Format require "#{SiSU_lib}/defaults" # defaults.rb + require "#{SiSU_lib}/particulars" # particulars.rb @@fns=nil def initialize(md,t_o) @md,@t_o=md,t_o @@ -85,10 +86,13 @@ module SiSU_Format_Shared end def urls(data) @words=[] + map_nametags=SiSU_Particulars::Combined_singleton.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]}|image)/ + @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]}/ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/.match(word).captures + elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ + m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/.match(word).captures elsif word =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}image/ m,u=/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}(image)/.match(word).captures end @@ -107,12 +111,27 @@ module SiSU_Format_Shared end word.gsub!(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/,ins) else + u=case u + when /^http:\/\// + u + when /^:/ + u.gsub!(/^:/,'') + "#{@env.url.root}/#{u}" + when /^\.\.\// # can remove + u.gsub!(/^\.\.\//,'') + "#{@env.url.root}/#{u}" + else + "#{@env.url.root}/#{@md.fnb}/#{map_nametags[u][:segname]}#{Sfx[:html]}##{u}" + end link=m[/(.+)/m] 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 end + word else word end word @@ -134,8 +153,8 @@ module SiSU_Format_Shared s=t_o.obj if t_o.is !='code' s=markup_generic(s) - if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\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) end @@ -152,8 +171,8 @@ module SiSU_Format_Shared end def markup_note(s) s=markup_generic(s) - if s =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - wm=s.scan(/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)|\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=s.gsub(/.+/m,words) end |