Skip to content

Commit 9537bdf

Browse files
kaushlakersLee Adams
authored andcommitted
Initial commit for twitter-text 3.0.0 (#265)
* Initial commit for twitter-text 3.0.0 * remove js from travis test * package version change
1 parent 4b8fc4a commit 9537bdf

282 files changed

Lines changed: 7458 additions & 825 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ matrix:
77
- env: TWITTER_TEXT_DIR=rb
88
rvm: 2.4.2
99
- env: TWITTER_TEXT_DIR=java
10-
- env: TWITTER_TEXT_DIR=js
1110
- env: TWITTER_TEXT_DIR=objc
1211
script: "./.travis.sh"

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[![Build Status](https://img.shields.io/travis/twitter/twitter-text/master.svg)](https://travis-ci.org/twitter/twitter-text) [![Maven Central](https://img.shields.io/maven-central/v/com.twitter.twittertext/twitter-text.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.twitter.twittertext%22%20AND%20a%3A%22twitter-text%22) [![Gem](https://img.shields.io/gem/v/twitter-text.svg)](https://rubygems.org/gems/twitter-text) [![npm](https://img.shields.io/npm/v/twitter-text.svg)](https://www.npmjs.com/package/twitter-text) [![CocoaPods](https://img.shields.io/cocoapods/v/twitter-text.svg)](http://cocoapods.org/?q=twitter-text) [![Bower](https://img.shields.io/bower/v/twitter-text.svg)](http://bower.io/search/?q=twitter-text)
2-
31
twitter-text
42
============
53

config/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The configuration format is a JSON string. The JSON can have the following prope
1313
* `maxWeightedTweetLength` (required, integer, min value 0)
1414
* `scale` (required, integer, min value 1)
1515
* `defaultWeight` (required, integer, min value 0)
16+
* `emojiParsingEnabled` (optional, boolean)
1617
* `transformedURLLength` (integer, min value 0)
1718
* `ranges` (array of range items)
1819

@@ -48,6 +49,13 @@ The Tweet length is the (`weighted length` / `scale`).
4849
The default weight applied to all code points. This is overridden in
4950
one or more range items.
5051

52+
### emojiParsingEnabled
53+
54+
When set to true, the weighted Tweet length considers all emoji as a
55+
single code point (with a default weight of 200), including longer
56+
grapheme clusters combined by zero-width joiners. When set to false,
57+
Tweet length is calculated by weighing individual Unicode code points.
58+
5159
### transformedURLLength
5260

5361
The length counted for URLs against the total weight of the Tweet. In

config/v3.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"version": 3,
3+
"maxWeightedTweetLength": 280,
4+
"scale": 100,
5+
"defaultWeight": 200,
6+
"emojiParsingEnabled": true,
7+
"transformedURLLength": 23,
8+
"ranges": [
9+
{
10+
"start": 0,
11+
"end": 4351,
12+
"weight": 100
13+
},
14+
{
15+
"start": 8192,
16+
"end": 8205,
17+
"weight": 100
18+
},
19+
{
20+
"start": 8208,
21+
"end": 8223,
22+
"weight": 100
23+
},
24+
{
25+
"start": 8242,
26+
"end": 8247,
27+
"weight": 100
28+
}
29+
]
30+
}

conformance/Rakefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ package com.twitter.twittertext;
3939
import java.util.Arrays;
4040
import java.util.List;
4141
42-
public class TldLists {
42+
public final class TldLists {
43+
private TldLists() {
44+
}
45+
4346
public static final List<String> GTLDS = Arrays.asList(
4447
#{yml["generic"].map {|el| " \"#{el}\""}.join(",\n")}
4548
);

conformance/extract.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,44 @@ tests:
664664
- url: "http://foobar.پاکستان/"
665665
indices: [42, 64]
666666

667+
urls_with_directional_markers:
668+
- description: "Extract URLs from RTL text"
669+
text: "\U00002066\U0000202Atest abcdef.com پاکستان http://twitter.com/\U0000202C\U00002069"
670+
expected:
671+
- url: "abcdef.com"
672+
indices: [7, 17]
673+
- url: "http://twitter.com/"
674+
indices: [26, 45]
675+
676+
- description: "Extract URLs from RTL text with embedded directional marks"
677+
text: "This is a test \U00002066\U0000202Atwitter.com\U0000202C\U00002069 \U00002066\U0000202Ahttp://foobar.پاکستان/\U0000202C\U00002069⁩ قطر فلسطين عمان"
678+
expected:
679+
- url: "twitter.com"
680+
indices: [17, 28]
681+
- url: "http://foobar.پاکستان/"
682+
indices: [33, 55]
683+
684+
tco_urls_with_params:
685+
- description: "Extract valid URL with params: https://t.co/UqIyJAJTfo?amp=1"
686+
text: "text https://t.co/UqIyJAJTfo?amp=1"
687+
expected: ["https://t.co/UqIyJAJTfo?amp=1"]
688+
689+
- description: "Extract valid URL with params: https://t.co/UqIyJAJTfo?type=js"
690+
text: "text https://t.co/UqIyJAJTfo?type=js"
691+
expected: ["https://t.co/UqIyJAJTfo?type=js"]
692+
693+
- description: "Extract valid URL with params: https://t.co/UqIyJAJTfo?ssr=true"
694+
text: "text https://t.co/UqIyJAJTfo?ssr=true"
695+
expected: ["https://t.co/UqIyJAJTfo?ssr=true"]
696+
697+
- description: "Extract a valid URL with params: https://t.co/asdfdf?a=b#123"
698+
text: "text https://t.co/asdfdf?a=b#123"
699+
expected: ["https://t.co/asdfdf?a=b#123"]
700+
701+
- description: "Extract a valid URL with params: https://t.co/sadfasdf?a=b&c=d"
702+
text: "text https://t.co/sadfasdf?a=b&c=d"
703+
expected: ["https://t.co/sadfasdf?a=b&c=d"]
704+
667705
hashtags:
668706
- description: "Extract hashtag after emoji without variant selector (uFE0E or uFE0F)"
669707
text: "a ✌#hashtag here"

conformance/tld_lib.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ generic:
343343
- 新闻
344344
- 政府
345345
- 政务
346+
- 招聘
346347
- 手表
347348
- 手机
348349
- 我爱你
@@ -598,6 +599,7 @@ generic:
598599
- srl
599600
- spreadbetting
600601
- spot
602+
- sport
601603
- spiegel
602604
- space
603605
- soy
@@ -942,6 +944,7 @@ generic:
942944
- locker
943945
- loans
944946
- loan
947+
- llc
945948
- lixil
946949
- living
947950
- live
@@ -1047,6 +1050,7 @@ generic:
10471050
- info
10481051
- infiniti
10491052
- industries
1053+
- inc
10501054
- immobilien
10511055
- immo
10521056
- imdb
@@ -1364,6 +1368,7 @@ generic:
13641368
- cheap
13651369
- chat
13661370
- chase
1371+
- charity
13671372
- channel
13681373
- chanel
13691374
- cfd

0 commit comments

Comments
 (0)