From fec639c59a032977b87ff49920e74ae08d485f04 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 26 May 2010 13:18:31 -0400 Subject: output formats internal document (and relative) linking as possible --- lib/sisu/v2/shared_html_lite.rb | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'lib/sisu/v2/shared_html_lite.rb') 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=%{#{link}} 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 -- cgit v1.2.3