From 4c11eebf5ea1ce4abaeb8dc555ec1bf2cb27947e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Jun 2007 10:16:51 +0100 Subject: sisu-0.54.0 (minor additions to syntax, indent range extended) * indent levels (1-9) added [previously two levels] done for plaintext, html, xml, odf, latex/pdf [minor syntax addition (_3 - _9), version number change] * bullet indent levels (1-9) added [previously two levels] done for plaintext, html, odf, latex/pdf [minor syntax addition (_3* - _9*), version number change] * url decoration, open close, default angle brackets * fixes, some line-breaking for plaintext (and text groups for) odf and xml * css, modifications for extended indents in html and xml [sisu -CC (for update)] * vim syntax highlighter updated to take account of extended indent range * rant installer minor changes for future ruby * conversion script in data/sisu/conf/convert/sisu_convert --- lib/sisu/v0/html_tune.rb | 98 +++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 52 deletions(-) (limited to 'lib/sisu/v0/html_tune.rb') diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb index 2d295a6c..749f5180 100644 --- a/lib/sisu/v0/html_tune.rb +++ b/lib/sisu/v0/html_tune.rb @@ -187,6 +187,7 @@ module SiSU_Tune @env=SiSU_Env::Info_env.new(@md.fns) @sys=SiSU_Env::System_call.new @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern + @env=SiSU_Env::Info_env.new(@md.fns) #@utf8=SiSU_character_encode::UTF8 #.new end def songsheet @@ -231,6 +232,45 @@ module SiSU_Tune @tuned_file << para end end + def urls(data) + @words=[] + data.each do |word| + @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ + if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/ + m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/.match(word).captures + else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures + d='' + end + case m + when /\.png|\.jpg|\.gif|c=|\d+x\d+/ + w,h=/(\d+)x(\d+)/.match(m).captures if m =~/\d+x\d+/ + w=%{width="#{w}"} if w + h=%{height="#{h}"} if h + c=m[/"(.+?)"/m,1] + caption=%{

#{c}

} if c + png=m.scan(/\S+/)[0] + image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external + else @env.url.images_local + end + ins=if u and u.strip !~/^image$/ + %{#{caption}} + else %{#{caption}} + end + word.gsub!(/\{.+?\}((?:https?|ftp)\S+|image)/,ins) + else + link=m[/(.+)/m] + png=m.scan(/\S+/)[0].strip + link=link.strip + ins=%{#{link}#{d}} + word.gsub!(/\{.+?\}(?:https?|ftp)\S+/,ins) + end + word + else word + end + word + end + @words + end def url_markup data=@data @tuned_file=[] @@ -256,7 +296,7 @@ module SiSU_Tune end if para =~/\{.+?\}((?:http|ftp)\S+|image)/ @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) - word_mode=SiSU_Tune::Tune_urls.new(@word_mode,@md).urls + word_mode=urls(@word_mode) words=word_mode.join(' ') para.gsub!(/.+/,words) end @@ -274,20 +314,20 @@ module SiSU_Tune para.gsub!(/<:h(.{1,7}?)>/,'\1') para.gsub!(/<:to(\d{1,7}?)>/,'to { \1 } ') if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/) - para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'\1\\2') + para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'<\1>\2') end if (para !~/(\"\w+:\/\/\S+?\"|>\s*\w+:\/\/\w+?\S*<)/) #url markup http etc. if para=~/\w+:\/\/\S+?\.\S+?[.,] / - para.gsub!(/(\w+:\/\/\S+?\.\S+?)([.,] )/,'\1\2') #full stops ! have been a bother + para.gsub!(/(\w+:\/\/\S+?\.\S+?)([.,] )/,'<\1>\2') #full stops ! have been a bother else - para.gsub!(/(\w+:\/\/\S+?\.\S+)/, '\1') + para.gsub!(/(\w+:\/\/\S+?\.\S+)/, '<\1>') end end if (para =~/[ ^](?:https?|ftp):\/\/\S+/) #url markup http leftovers watch carefully may accept too much 2004w46 if para=~/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/ - para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/,'\1\2\3') #full stops ! have been a bother + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+?)([\.,] )/,'\1<\2>\3') #full stops ! have been a bother else - para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+)/,'\1\2') + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+)/,'\1<\2>') end end if (para =~/..\/\S+/ and para !~/(\"..\/\S+?\"|>\s*..\/\S+<)/) @@ -326,51 +366,5 @@ module SiSU_Tune @tuned_file end end - class Tune_urls - def initialize(data,md) - @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin - @env=SiSU_Env::Info_env.new(@md.fns) - end - def urls - @words=[] - @data.each do |word| - @words << if word=~/\{(.+?)\}((?:https?|ftp)\S+|image)/ - if word =~/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/ - m,u,d=/\{(.+?)\}((?:https?|ftp)\S+|image)([.,](?:\s|$))/.match(word).captures - else m,u=/\{(.+?)\}((?:https?|ftp)\S+|image)/.match(word).captures - d='' - end - case m - when /\.png|\.jpg|\.gif|c=|\d+x\d+/ - w,h=/(\d+)x(\d+)/.match(m).captures if m =~/\d+x\d+/ - w=%{width="#{w}"} if w - h=%{height="#{h}"} if h - c=m[/"(.+?)"/m,1] - caption=%{

#{c}

} if c - png=m.scan(/\S+/)[0] - image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external - else @env.url.images_local - end - ins=if u and u.strip !~/^image$/ - %{#{caption}} - else %{#{caption}} - end - word.gsub!(/\{.+?\}((?:https?|ftp)\S+|image)/,ins) - else - link=m[/(.+)/m] - png=m.scan(/\S+/)[0].strip - link=link.strip - ins=%{#{link}#{d}} - word.gsub!(/\{.+?\}(?:https?|ftp)\S+/,ins) - end - word - else word - end - word - end - @words - end - end end __END__ -- cgit v1.2.3