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/shared_html_lite.rb | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) (limited to 'lib/sisu/v0/shared_html_lite.rb') diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 93e77db7..3c0e9ce1 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -50,6 +50,7 @@ module SiSU_Format_Shared require "#{SiSU_lib}/defaults" include SiSU_Viz class CSS_Format + require "#{SiSU_lib}/defaults" def initialize(content=nil,id=nil,ocnd='',ocns='',lv='',hname=nil) content.gsub!(/<:i[12]>/,'') @content=content @@ -58,14 +59,78 @@ module SiSU_Format_Shared @lv=@notenumber=lv.to_s @hname=hname.to_s @tab="\t" + @url_brace=SiSU_Viz::Skin.new.url_decoration # lots introduced to do html tables in db @@tablehead,@@tablefoot=[],[] @vz=SiSU_Env::Get_init.instance.skin 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$/ + %{[#{png}]#{caption}} + else %{[#{png}] #{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 markup(para) + if para =~/\{.+?\}((?:http|ftp)\S+|image)/ + @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/) + word_mode=urls(para) + words=word_mode.join(' ') + para.gsub!(/.+/,words) + end + if (para !~/(\"\w+:\/\/\S+?\"|>\s*\w+:\/\/\w+?\S*<)/) #url markup http etc. + if para=~/\w+:\/\/\S+?\.\S+?[.,] / + para.gsub!(/(\w+:\/\/\S+?\.\S+?)([.,] )/,%{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}\\2}) #full stops ! have been a bother + else + para.gsub!(/(\w+:\/\/\S+?\.\S+)/,%{#{@url_brace.xml_open}\\1#{@url_brace.xml_close}}) + 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#{@url_brace.xml_open}\\2#{@url_brace.xml_close}\\3}) #full stops ! have been a bother + else + para.gsub!(/([ ^])((?:https?|ftp):\/\/\S+)/,%{\\1#{@url_brace.xml_open}\\2#{@url_brace.xml_close}}) + end + end + para + end def paragraph %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" end def endnote + @content=markup(@content) < #{@tab*2}#@notenumber. #@content @@ -88,12 +153,15 @@ GSUB %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} end def norm + @content=markup(@content) %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} end def indent1 + @content=markup(@content) %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} end def indent2 + @content=markup(@content) %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} end def para_table -- cgit v1.2.3