@@ -111,20 +111,20 module Redmine | |||||
111 | (?=<|\s|$) |
|
111 | (?=<|\s|$) | |
112 | }x unless const_defined?(:AUTO_LINK_RE) |
|
112 | }x unless const_defined?(:AUTO_LINK_RE) | |
113 |
|
113 | |||
114 |
# Destructively re |
|
114 | # Destructively replaces urls into clickable links | |
115 | def auto_link!(text) |
|
115 | def auto_link!(text) | |
116 | text.gsub!(AUTO_LINK_RE) do |
|
116 | text.gsub!(AUTO_LINK_RE) do | |
117 | all, leading, proto, url, post = $&, $1, $2, $3, $6 |
|
117 | all, leading, proto, url, post = $&, $1, $2, $3, $6 | |
118 | if leading =~ /<a\s/i || leading =~ /![<>=]?/ |
|
118 | if leading =~ /<a\s/i || leading =~ /![<>=]?/ | |
119 |
# don't replace URL |
|
119 | # don't replace URLs that are already linked | |
120 |
# and URL |
|
120 | # and URLs prefixed with ! !> !< != (textile images) | |
121 | all |
|
121 | all | |
122 | else |
|
122 | else | |
123 | # Idea below : an URL with unbalanced parethesis and |
|
123 | # Idea below : an URL with unbalanced parenthesis and | |
124 | # ending by ')' is put into external parenthesis |
|
124 | # ending by ')' is put into external parenthesis | |
125 | if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) ) |
|
125 | if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) ) | |
126 | url=url[0..-2] # discard closing parenth from url |
|
126 | url=url[0..-2] # discard closing parenthesis from url | |
127 | post = ")"+post # add closing parenth to post |
|
127 | post = ")"+post # add closing parenthesis to post | |
128 | end |
|
128 | end | |
129 | content = proto + url |
|
129 | content = proto + url | |
130 | href = "#{proto=="www."?"http://www.":proto}#{url}" |
|
130 | href = "#{proto=="www."?"http://www.":proto}#{url}" | |
@@ -133,7 +133,7 module Redmine | |||||
133 | end |
|
133 | end | |
134 | end |
|
134 | end | |
135 |
|
135 | |||
136 |
# Destructively re |
|
136 | # Destructively replaces email addresses into clickable links | |
137 | def auto_mailto!(text) |
|
137 | def auto_mailto!(text) | |
138 | text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do |
|
138 | text.gsub!(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do | |
139 | mail = $1 |
|
139 | mail = $1 |
General Comments 0
You need to be logged in to leave comments.
Login now