twitter/twitter-text-java — pull request #37 by keitaf (2012-06-06 21:01:55+00:00)
Title: Add new options to Autolink

This will add the following options to Autolink.

* symbolTag: a tag to apply around symbol (#,@,$) in hashtag/username/list/cashtag links.
* textWithSymbolTag: a tag to apply around text part in hashtag/username/list/cashtag links.
* urlTarget: the value of target attribute in URL links
* linkAttributeModifier: modifies attributes of a link based on the entity.
* linkTextModifier: modifies text of a link based on the entity.

Examples:
````
linker.setSymbolTag("s"); linker.autoLink("#hash") => "#hash"

linker.setTextWithSymbolTag("b"); linker.autoLink("#hash") => "#hash"

linker.setLinkAttributeModifier(new LinkAttributeModifier() {
@Override public void modify(Entity entity, Map attributes) {
if (entity.type == Type.HASHTAG) attributes.put("custom-attr", "some_value");
});
linker.autoLink("#hash") => "#hash"
linker.setLinkTextModifier(new LinkTextModifier() {
@Override public CharSequence modify(Entity entity, CharSequence text) {
return entity.type == Type.HASHTAG ? "prefix"+text : text;
});
autoLink("#hash") => "prefix#text"
````

This will also change urlClass option, which is currently applied to all links but will only be applied to URL links.