twitter/twitter-text-java — pull request #20 by keitaf (2012-01-30 21:42:28+00:00)
Title: Refactor twitter-text to allow punctuation characters before URL.

Currently twitter-text doesn't allow punctuation characters like " or . before URL. But if we change Regex to allow those characters before URL Autolink.autoLink() will break because it'll auto-link the URLs added by autoLinkHashtags/UsernamesAndLists(). To solve it, this modifies Autolink to use Extractor to extract all entities first, then use them to auto-link the text.

This also includes performance improvement (which doubles the speed of Autolink/Extractor on my laptop) as well as other minor refactoring.

Here is the list of changes in this branch:

* Add new method Extractor.extractEntitiesWithIndices(), which extracts all entities (hashtag, mention, URLs) from a given String.
* Modify Autolink.autoLink*() to use Extractor to extract entities instead of applying Regex.
* Allow punctuation characters like '"', '.' or '!' before URL.
* Consolidate AUTO_LINK_USERNAMES* and EXTRACT_MENTIONS into VALID_MENTION_OR_LIST
* Improve performance of Extractor.extract*() by scanning the text before applying complex regex patterns.
* Add an option in Extractor to enable/disable extracting URLs without protocol.
* Modify Extractor.Entity by changing 'type' from String to Entity.Type enum and making 'start' and 'end' from Integer to int.
* Remove com.twitter.regex.Spaces, and move Spaces.UNICODE_SPACES to com.twitter.Regex.
* Change jyaml's scope to 'test'
* Remove commons-lang dependency and use the same escapeHTML() as in twitter-text-rb/js