diff options
author | Ralph Amissah <ralph@amissah.com> | 2011-03-10 08:43:44 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2011-03-10 08:43:57 -0500 |
commit | 755acef8c7673081e9fb946d789d394afaee68ee (patch) | |
tree | 961e24d40e555b1ab5b0472f8e06029fd3a563eb /lib | |
parent | v2, v3: texpdf, url (regex) pattern match fix (diff) |
v2, v3: dal_syntax + downstream output, email regex revised
* revised pattern match for email address, (removes occasional interference
with urls having embedded email addresses) (dal_syntax and affected
downstream output modules)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v2/dal_syntax.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v2/epub_tune.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v2/html_tune.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v2/odf.rb | 10 | ||||
-rw-r--r-- | lib/sisu/v2/shared_xml.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v2/texpdf_format.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v3/dal_syntax.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v3/epub_tune.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v3/html_tune.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v3/odf.rb | 12 | ||||
-rw-r--r-- | lib/sisu/v3/shared_xml.rb | 2 | ||||
-rw-r--r-- | lib/sisu/v3/texpdf_format.rb | 2 |
12 files changed, 30 insertions, 34 deletions
diff --git a/lib/sisu/v2/dal_syntax.rb b/lib/sisu/v2/dal_syntax.rb index 47c7f8d0..55556371 100644 --- a/lib/sisu/v2/dal_syntax.rb +++ b/lib/sisu/v2/dal_syntax.rb @@ -7,7 +7,7 @@ * Author: Ralph Amissah - * Copyright: (C) 1997 - 2010, Ralph Amissah, All Rights Reserved. + * Copyright: (C) 1997 - 2011, Ralph Amissah, All Rights Reserved. * License: GPL 3 or later: @@ -327,7 +327,7 @@ module SiSU_Syntax else dob.obj.gsub!(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') end end - dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup + dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu') #adjustment 2005w30 dob.obj.gsub!(/<!(\S+)!>/,'<:\1>') #escaped special character dob.obj.gsub!(/ /,"#{Mx[:nbsp]}") #escaped special character @@ -398,6 +398,7 @@ module SiSU_Syntax "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3") #any remaining linked text or image dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image + dob.obj.gsub!(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}") dob.obj.gsub!(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4") #any remaining linked text or image dob.obj.gsub!(/\{\s*(.+?)\s*\}#(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, @@ -409,7 +410,6 @@ module SiSU_Syntax elsif dob.is=='table' dob=fontface(dob) elsif dob.is =='code' -#p dob.obj dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ') dob.obj.gsub!(/([<>])/,'_\1') dob.obj.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy diff --git a/lib/sisu/v2/epub_tune.rb b/lib/sisu/v2/epub_tune.rb index 10583936..9c9223a0 100644 --- a/lib/sisu/v2/epub_tune.rb +++ b/lib/sisu/v2/epub_tune.rb @@ -7,7 +7,7 @@ * Author: Ralph Amissah - * Copyright: (C) 1997 - 2010, Ralph Amissah, All Rights Reserved. + * Copyright: (C) 1997 - 2011, Ralph Amissah, All Rights Reserved. * License: GPL 3 or later: @@ -349,11 +349,8 @@ module SiSU_EPUB_Tune dob.obj.gsub!(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{@vz.icon_new}" alt="new" />}) dob.obj.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') dob.obj.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - if dob.obj =~/\b\S+\@\S+?\.\S+/ \ - and dob.obj !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/ - dob.obj.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<<a href="mailto:\1">\1</a>>') - end dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ diff --git a/lib/sisu/v2/html_tune.rb b/lib/sisu/v2/html_tune.rb index 9d3dce0b..99ce1b0f 100644 --- a/lib/sisu/v2/html_tune.rb +++ b/lib/sisu/v2/html_tune.rb @@ -7,7 +7,7 @@ * Author: Ralph Amissah - * Copyright: (C) 1997 - 2010, Ralph Amissah, All Rights Reserved. + * Copyright: (C) 1997 - 2011, Ralph Amissah, All Rights Reserved. * License: GPL 3 or later: @@ -321,11 +321,8 @@ module SiSU_HTML_Tune dob.obj.gsub!(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}) dob.obj.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') dob.obj.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - if dob.obj =~/\b\S+\@\S+?\.\S+/ \ - and dob.obj !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/ - dob.obj.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<<a href="mailto:\1">\1</a>>') - end dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ diff --git a/lib/sisu/v2/odf.rb b/lib/sisu/v2/odf.rb index 2e2a88b4..b6ec4c1b 100644 --- a/lib/sisu/v2/odf.rb +++ b/lib/sisu/v2/odf.rb @@ -7,7 +7,7 @@ * Author: Ralph Amissah - * Copyright: (C) 1997 - 2010, Ralph Amissah, All Rights Reserved. + * Copyright: (C) 1997 - 2011, Ralph Amissah, All Rights Reserved. * License: GPL 3 or later: @@ -291,10 +291,10 @@ module SiSU_ODF def normal(dob) #P1 - P3 dob.obj.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 + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) if dob.obj !~/https?:\/\// # improve upon, document crash where url contains '@' symbol dob.obj= if dob.is=='para' and dob.indent.to_s =~/[0-9]/ # and t_o.bullet_==true %{<text:p text:style-name="P1#{dob.indent}">#{dob.obj}</text:p>} else %{<text:p text:style-name="P1">#{dob.obj}</text:p>} @@ -372,10 +372,10 @@ module SiSU_ODF parray=[] dob.obj.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 + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) if dob.obj !~/https?:\/\// # improve upon, document crash where url contains '@' symbol dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) parablock.gsub!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') diff --git a/lib/sisu/v2/shared_xml.rb b/lib/sisu/v2/shared_xml.rb index 2fcab17e..e82f51bf 100644 --- a/lib/sisu/v2/shared_xml.rb +++ b/lib/sisu/v2/shared_xml.rb @@ -398,6 +398,8 @@ module SiSU_XML_munge if dob.of=='group' dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') end + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}") dob.obj.gsub!(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}") dob.obj.gsub!(/ |#{Mx[:nbsp]}/m,' ') diff --git a/lib/sisu/v2/texpdf_format.rb b/lib/sisu/v2/texpdf_format.rb index 19e53d3b..dbf0d095 100644 --- a/lib/sisu/v2/texpdf_format.rb +++ b/lib/sisu/v2/texpdf_format.rb @@ -65,6 +65,8 @@ module SiSU_TeX_Pdf @brace_url=SiSU_Viz::Skin.new.url_decoration end def bare_urls + @dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + "#{@brace_url.tex_open}\\1</a>#{@brace_url.tex_close}") @dob.tmp.gsub!(/(^|[^\\])_/m,'\1\_') #watch may not work @dob.tmp.gsub!(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") diff --git a/lib/sisu/v3/dal_syntax.rb b/lib/sisu/v3/dal_syntax.rb index 2de931f6..61253561 100644 --- a/lib/sisu/v3/dal_syntax.rb +++ b/lib/sisu/v3/dal_syntax.rb @@ -333,7 +333,7 @@ module SiSU_Syntax end end end - dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup + dob.obj.gsub!(/<(https?:\/\/\S+?)>/,'< \1 >') #catch problem markup dob.obj.gsub!(/<:=(\S+?)>/,'{ c_\1.png 14x14 }http://www.jus.uio.no/sisu') #adjustment 2005w30 dob.obj.gsub!(/<!(\S+)!>/,'<:\1>') #escaped special character dob.obj.gsub!(/ /,"#{Mx[:nbsp]}") #escaped special character @@ -404,6 +404,7 @@ module SiSU_Syntax "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3") #any remaining linked text or image dob.obj.gsub!(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #any remaining linked text or image + dob.obj.gsub!(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}") dob.obj.gsub!(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4") #any remaining linked text or image dob.obj.gsub!(/\{\s*(.+?)\s*\}#(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, @@ -415,7 +416,6 @@ module SiSU_Syntax elsif dob.is=='table' dob=fontface(dob) elsif dob.is =='code' -#p dob.obj dob.obj.gsub!(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: ') dob.obj.gsub!(/([<>])/,'_\1') dob.obj.gsub!(/_<:(\S+?)_>/,'<:\1>') #convert <:\S+> back, clumsy diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index 746a112e..19453fc8 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -347,11 +347,8 @@ module SiSU_EPUB_Tune dob.obj.gsub!(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images_epub}/#{@vz.icon_new}" alt="new" />}) dob.obj.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') dob.obj.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - if dob.obj =~/\b\S+\@\S+?\.\S+/ \ - and dob.obj !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/ - dob.obj.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<<a href="mailto:\1">\1</a>>') - end dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/..\/\S+/ \ and dob.obj !~/(\"..\/\S+?\"|>\s*..\/\S+<)/ diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index 18b4576b..5bbcdf6c 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -319,11 +319,8 @@ module SiSU_HTML_Tune dob.obj.gsub!(/!new/,%{ <img border="0" height="15" width="15" src="#{@env.url.images}/#{@vz.icon_new}" alt="new">}) dob.obj.gsub!(/<:h(.{1,7}?)>/,'<a href="#h\1">\1</a>') dob.obj.gsub!(/<:to(\d{1,7}?)>/,'<a href="#to\1">to { \1 }</a> ') - if dob.obj =~/\b\S+\@\S+?\.\S+/ \ - and dob.obj !~/(\"\S+\@\S+?\.\S+\"|>\S+\@\S+?\.\S+?<)/ - dob.obj.gsub!(/([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,'<<a href="mailto:\1">\1</a>>') - end dob.obj.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,'<a href="\1" target="_top">\1</a>') #http ftp matches escaped, no decoration + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="mailto:\\1">\\1</a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,%{#{@brace_url.xml_open}<a href="\\1" target="_top">\\1</a>#{@brace_url.xml_close}}) #http ftp matches with decoration if dob.obj =~/#{Xx[:html_relative2]}\/\S+/ \ and dob.obj !~/(\"#{Xx[:html_relative2]}\/\S+?\"|>\s*#{Xx[:html_relative2]}\/\S+<)/ diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 204f0e50..c14a6c91 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -294,10 +294,10 @@ module SiSU_ODF def normal(dob,p_num='') #P1 - P3 dob.obj.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 + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) if dob.obj !~/https?:\/\// # improve upon, document crash where url contains '@' symbol dob.obj= if dob.is=='para' and dob.indent.to_s =~/[0-9]/ # and t_o.bullet_==true %{<text:p text:style-name="P1#{dob.indent}">#{dob.obj}#{p_num}</text:p>} else %{<text:p text:style-name="P1">#{dob.obj}#{p_num}</text:p>} @@ -377,10 +377,10 @@ module SiSU_ODF parray=[] dob.obj.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 + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) if dob.obj !~/https?:\/\// # improve upon, document crash where url contains '@' symbol dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) parablock.gsub!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') @@ -400,10 +400,10 @@ module SiSU_ODF parray=[] dob.obj.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 + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{@brace_url.xml_close}}) #http ftp matches with decoration - dob.obj.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, - %{#{@brace_url.xml_open}<text:a xlink:type="simple" xlink:href="mailto:\\1">\\1</text:a>#{@brace_url.xml_close}}) if dob.obj !~/https?:\/\// # improve upon, document crash where url contains '@' symbol dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each do |parablock| parablock=group_clean(parablock) parablock.gsub!(/<text:a xlink:type="simple" xlink:href="(.+?)">/m,'<text:a xlink:type="simple" xlink:href="\1">') diff --git a/lib/sisu/v3/shared_xml.rb b/lib/sisu/v3/shared_xml.rb index 06b89395..daf59a4c 100644 --- a/lib/sisu/v3/shared_xml.rb +++ b/lib/sisu/v3/shared_xml.rb @@ -398,6 +398,8 @@ module SiSU_XML_munge if dob.of=='block' dob.obj.gsub!(/#{Mx[:gl_bullet]}/,'● ') end + dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + %{#{@brace_url.xml_open}\\1#{@brace_url.xml_close}}) dob.obj.gsub!(/#{Dx[:url_o]}/,"#{Dx[:url_o_xml]}") dob.obj.gsub!(/#{Dx[:url_c]}/,"#{Dx[:url_c_xml]}") dob.obj.gsub!(/ |#{Mx[:nbsp]}/m,' ') diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index 114c3cb6..a91095e8 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -65,6 +65,8 @@ module SiSU_TeX_Pdf @brace_url=SiSU_Viz::Skin.new.url_decoration end def bare_urls + @dob.obj.gsub!(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/, + "#{@brace_url.tex_open}\\1</a>#{@brace_url.tex_close}") @dob.tmp.gsub!(/(^|[^\\])_/m,'\1\_') #watch may not work @dob.tmp.gsub!(/(^|[^#{Mx[:lnk_c]}])#{Mx[:url_o]}_?(?:\\?_)?(\S+?)#{Mx[:url_c]}/m, "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}") |