aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v0/html_tune.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2007-09-03 21:46:47 +0100
committerRalph Amissah <ralph@amissah.com>2007-09-03 21:46:47 +0100
commit2cd558f67f44cca787013c02b665533b97c90f0e (patch)
treeb3b596e2d094014b897dabd1c93e91623b1663d0 /lib/sisu/v0/html_tune.rb
parentsisu-0.57.0 md5s (diff)
sisu-0.58 work towards making it possible to describe sisu and sisu markup within sisu
Diffstat (limited to 'lib/sisu/v0/html_tune.rb')
-rw-r--r--lib/sisu/v0/html_tune.rb104
1 files changed, 54 insertions, 50 deletions
diff --git a/lib/sisu/v0/html_tune.rb b/lib/sisu/v0/html_tune.rb
index 7f91641e..7c829831 100644
--- a/lib/sisu/v0/html_tune.rb
+++ b/lib/sisu/v0/html_tune.rb
@@ -289,49 +289,51 @@ module SiSU_Tune
para.gsub!(/<:p[bn]>/,'')
para.gsub!(/<(p|br)>/,'<\1 />')
para.gsub!(/<:br>/,'<br />')
- if para =~/<::\s+/ #watch
- para.gsub!(/<::\s+(\S+?)\s+!>/,
- %{<img src="#{@env.url.images}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0">})
- end
- if para =~/<:image\s+/
- para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/,
- %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0"></a>})
- para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/,
- %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" naturalsizeflag="0" align="bottom" border="0"></a>})
- para.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/,
- %{<img src="#{@env.url.images_local}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0">})
- para.gsub!(/<:image\s+(\S+)\s+>/,
- %{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">})
- end
- if para =~/\{.+?\}((?:http|ftp)\S+|image)/
- @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/)
- word_mode=urls(@word_mode)
- words=word_mode.join(' ')
- para.gsub!(/.+/,words)
- end
- if (para !~/^0~/)
- para.gsub!(/\\copyright/i,%{<sup>&copy;</sup>})
- if (para !~/\<:ad\s+\.\.\//)
- para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/,
- %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n})
- else
- para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/,
- %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n})
+ unless para =~/^<:code>/
+ if para =~/<::\s+/ #watch
+ para.gsub!(/<::\s+(\S+?)\s+!>/,
+ %{<img src="#{@env.url.images}/c_\\1.png" alt="\\1" width="14" height="14" align="bottom" border="0">})
+ end
+ if para =~/<:image\s+/
+ para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+>/,
+ %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" \\3 \\4 naturalsizeflag="0" align="bottom" border="0"></a>})
+ para.gsub!(/<:image\s+(http\S+)\s+(\S+)\s+>/,
+ %{<a href="\\1"><img src="#{@env.url.images_local}/\\2" naturalsizeflag="0" align="bottom" border="0"></a>})
+ para.gsub!(/<:image\s+(\S+)\s+(\S+)\s+(\S+)\s+>/,
+ %{<img src="#{@env.url.images_local}/\\1" \\2 \\3 naturalsizeflag="0" align="bottom" border="0">})
+ para.gsub!(/<:image\s+(\S+)\s+>/,
+ %{<img src="#{@env.url.images_local}/\\1" naturalsizeflag="0" align="bottom" border="0">})
end
- para.gsub!(/!pick/, %{<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_choice}" alt="stellar">})
- para.gsub!(/!new/, %{&nbsp;<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">})
- para.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>')
- para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to&nbsp;{&nbsp;\1&nbsp;}</a> ')
- if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/)
- para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'&lt;<a href="mailto:\1">\1</a>&gt;\2')
+ if para =~/\{.+?\}((?:http|ftp)\S+|image)/
+ @word_mode=para.scan(/\{.+?\}(?:(?:https?|ftp)\S+|image)|\S+/)
+ word_mode=urls(@word_mode)
+ words=word_mode.join(' ')
+ para.gsub!(/.+/,words)
end
- para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration
- para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url
- para.gsub!(/(^|\s)((?:https?|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+<)/)
- para.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>')
+ if (para !~/^0~|^<:code>/)
+ para.gsub!(/\\copyright/i,%{<sup>&copy;</sup>})
+ if (para !~/\<:ad\s+\.\.\//)
+ para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*!\>/,
+ %{\n<center><a href="http:\/\/\\1" target="external"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n})
+ else
+ para.gsub!(/\<:ad\s+(\S+)?\s+(\S+\.png)\s+(.+)?\;\s+(.+)?\;\s*\>/,
+ %{\n<center><a href="\\1" target="_top"><img src="#{@env.url.images_local}/\\2" alt="\\3"></a></center>\n})
+ end
+ para.gsub!(/!pick/, %{<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_choice}" alt="stellar">})
+ para.gsub!(/!new/, %{&nbsp;<img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">})
+ para.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>')
+ para.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to&nbsp;{&nbsp;\1&nbsp;}</a> ')
+ if (para =~/\b\S+\@\S+?\.\S+/ and para !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/)
+ para.gsub!(/\b(\S+\@\S+?\.\S+)(\s)/,'&lt;<a href="mailto:\1">\1</a>&gt;\2')
+ end
+ para.gsub!(/\b[_\\]((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'<a href="\1" target="_top">\1</a>\2') #http ftp matches escaped, no decoration
+ para.gsub!(/((?:^|\s)[}])((?:https?|ftp):\/\/\S+?\.[^'"><\s]+?)([;.,]?(?:\s|$))/,'\1<a href="\2" target="_top">\2</a>\3') #special case \{ e.g. \}http://url
+ para.gsub!(/(^|\s)((?:https?|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+<)/)
+ para.gsub!(/(\.\.\/\S+)/,'<a href="\1">\1</a>')
+ end
+ para.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/})
end
- para.gsub!(/<a href="\.\.\//,%{<a href="#{@vz.url_site}/})
end
@tuned_file << para
end
@@ -340,17 +342,19 @@ module SiSU_Tune
data=@data
@tuned_file=[]
data.each do |para|
- para.gsub!(/(~[{])(\d+) (.+?) <#@dp>([}]~)/,
- '&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
- '\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched)
- para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/,
- '&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
- '\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched)
- para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/,
- '&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
- '\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2</sup></a> \3 \4') #endnote- note- (careful may have switched)
- @tuned_file << para
+ unless para =~/^<:code>/
+ para.gsub!(/(~[{])(\d+) (.+?) <#@dp>([}]~)/,
+ '&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
+ '\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched)
+ para.gsub!(/(~\[)([*+]\d+) (.+?) <#@dp>(\]~)/,
+ '&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
+ '\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2.</sup></a> \3 \4') #endnote- note- (careful may have switched)
+ para.gsub!(/(~\{)([*+]+) (.+?) <#@dp>(\}~)/,
+ '&nbsp;<a name="-\2" href="#_\2">&nbsp;<sup>\2</sup>&nbsp;</a> ' + #note- endnote-
+ '\1\2 <a name="_\2" href="#-\2">&nbsp;<sup>\2</sup></a> \3 \4') #endnote- note- (careful may have switched)
end
+ @tuned_file << para
+ end
end
def output
data=@data