Skip to content
Browse files

Merge branch 'master' of github.com:twitter/twitter-text-rb into bett…

…er_copy
  • Loading branch information...
2 parents 8bc4ddd + e128728 commit d91a9fff88b03e8c4103710fe619654ef78d0e44 @keitaf keitaf committed Feb 10, 2012
Showing with 29 additions and 10 deletions.
  1. +11 −4 README.rdoc
  2. +2 −2 lib/autolink.rb
  3. +15 −3 lib/regex.rb
  4. +1 −1 twitter-text.gemspec
View
15 README.rdoc
@@ -55,9 +55,16 @@ numbers but cannot be solely numbers and cannot contain punctuation.
=== URLs
-Auto-linking and extraction of URLs differs from the Rails default so that it
-will work correctly in Tweets written in languages that do not include spaces
-between words.
+Asian languages like Chinese, Japanese or Korean may not use a delimiter such as
+a space to separate normal text from URLs making it difficult to identify where
+the URL ends and the text starts.
+
+For this reason twitter-text currently does not support extracting or auto-linking
+of URLs immediately followed by non-Latin characters.
+
+Example: "http://twitter.com/は素晴らしい" .
+The normal text is "は素晴らしい" and is not part of the URL even though
+it isn't space separated.
=== International
@@ -112,4 +119,4 @@ Thanks to everybody who has filed issues, provided feedback or contributed patch
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
- limitations under the License.
+ limitations under the License.
View
4 lib/autolink.rb
@@ -237,10 +237,10 @@ def auto_link_urls_custom(text, href_options = {})
BOOLEAN_ATTRIBUTES = Set.new([:disabled, :readonly, :multiple, :checked]).freeze
def html_attrs_for_options(options)
- html_attrs options.reject{|k, v| OPTIONS_NOT_ATTRIBUTES.include?(k)}
+ autolink_html_attrs options.reject{|k, v| OPTIONS_NOT_ATTRIBUTES.include?(k)}
end
- def html_attrs(options)
+ def autolink_html_attrs(options)
options.inject("") do |attrs, (key, value)|
if BOOLEAN_ATTRIBUTES.include?(key)
value = value ? key : nil
View
18 lib/regex.rb
@@ -65,7 +65,19 @@ def self.regex_range(from, to = nil) # :nodoc:
regex_range(0xc0, 0xd6),
regex_range(0xd8, 0xf6),
regex_range(0xf8, 0xff),
- regex_range(0x015f)
+ regex_range(0x0100, 0x024f),
+ regex_range(0x0253, 0x0254),
+ regex_range(0x0256, 0x0257),
+ regex_range(0x0259),
+ regex_range(0x025b),
+ regex_range(0x0263),
+ regex_range(0x0268),
+ regex_range(0x026f),
+ regex_range(0x0272),
+ regex_range(0x0289),
+ regex_range(0x028b),
+ regex_range(0x02bb),
+ regex_range(0x1e00, 0x1eff)
].join('').freeze
NON_LATIN_HASHTAG_CHARS = [
@@ -110,12 +122,12 @@ def self.regex_range(from, to = nil) # :nodoc:
REGEXEN[:at_signs] = /[@@]/
REGEXEN[:extract_mentions] = /(^|[^a-zA-Z0-9_!#\$%&*@@])#{REGEXEN[:at_signs]}([a-zA-Z0-9_]{1,20})/o
- REGEXEN[:extract_mentions_or_lists] = /(^|[^a-zA-Z0-9_])#{REGEXEN[:at_signs]}([a-zA-Z0-9_]{1,20})(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?/o
+ REGEXEN[:extract_mentions_or_lists] = /(^|[^a-zA-Z0-9_!#\$%&*@@])#{REGEXEN[:at_signs]}([a-zA-Z0-9_]{1,20})(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?/o
REGEXEN[:extract_reply] = /^(?:#{REGEXEN[:spaces]})*#{REGEXEN[:at_signs]}([a-zA-Z0-9_]{1,20})/o
# Used in Extractor and Rewriter for final filtering
REGEXEN[:end_screen_name_match] = /\A(?:#{REGEXEN[:at_signs]}|#{REGEXEN[:latin_accents]}|:\/\/)/o
- REGEXEN[:auto_link_usernames_or_lists] = /([^a-zA-Z0-9_]|^|RT:?)([@@]+)([a-zA-Z0-9_]{1,20})(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?/o
+ REGEXEN[:auto_link_usernames_or_lists] = /([^a-zA-Z0-9_!#\$%&*@@]|^|RT:?)([@@]+)([a-zA-Z0-9_]{1,20})(\/[a-zA-Z][a-zA-Z0-9_\-]{0,24})?/o
REGEXEN[:auto_link_emoticon] = /(8\-\#|8\-E|\+\-\(|\`\@|\`O|\<\|:~\(|\}:o\{|:\-\[|\>o\<|X\-\/|\[:-\]\-I\-|\/\/\/\/Ö\\\\\\\\|\(\|:\|\/\)|∑:\*\)|\( \| \))/
# URL related hash regex collection
View
2 twitter-text.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = "twitter-text"
- s.version = "1.4.15"
+ s.version = "1.4.16"
s.authors = ["Matt Sanford", "Patrick Ewing", "Ben Cherry", "Britt Selvitelle",
"Raffi Krikorian", "J.P. Cummins", "Yoshimasa Niwa", "Keita Fujii"]
s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com", "bcherry@gmail.com", "bs@brittspace.com",

0 comments on commit d91a9ff

Please sign in to comment.
Something went wrong with that request. Please try again.