diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-10-09 22:51:24 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-10-09 22:51:27 -0400 |
commit | 7010772e78d181be3a8ba304387d94b8f4825ea7 (patch) | |
tree | e698b32b5e0f2a970e585bf092585d2f5f8c0ee5 /lib/sisu/v2/shared_metadata.rb | |
parent | sha256 (2.7.4) (diff) |
odt fix cornercase breakage matching and representing " ", "&" and urls
(+changelog)
* odf, " " and "&"
(prior to this fix, odt for viral_spiral is broken in sisu-markup-samples)
* shared_metadata, " ", "&" and urls in metadata
more consistent open document text results
Diffstat (limited to 'lib/sisu/v2/shared_metadata.rb')
-rw-r--r-- | lib/sisu/v2/shared_metadata.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/sisu/v2/shared_metadata.rb b/lib/sisu/v2/shared_metadata.rb index 69a92070..e589c598 100644 --- a/lib/sisu/v2/shared_metadata.rb +++ b/lib/sisu/v2/shared_metadata.rb @@ -476,6 +476,18 @@ WOK if @inf.class==String @inf.gsub!(/</,'<'); @inf.gsub!(/>/,'>') @inf.gsub!(/<br(?: \/)?>/,'<br />') + if @inf =~/&/ + inf_array=[] + word=@inf.scan(/\S+|\n/) + word.each do |w| # _ - / # | : ! ^ ~ + w.gsub!(/ /,' ') + if w !~/&\S{2,7}?;/ + w.gsub!(/&/,'&') + end + inf_array << w + end + @inf=inf_array.join(' ') + end @inf.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration @inf.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, @@ -484,7 +496,7 @@ WOK @inf.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration else - @inf.gsub!(/(https?:\/\/\S+)/, + @inf.gsub!(/(https?:\/\/[^<>'"\s]+)/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration end @inf.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, |