Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Add new options to Autolink #37

Merged
merged 6 commits into from
Jun 14, 2012
Merged

Add new options to Autolink #37

merged 6 commits into from
Jun 14, 2012

Conversation

keitaf
Copy link

@keitaf keitaf commented Jun 6, 2012

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") => "<a...><s>#</s>hash</a>"

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

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

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

psychs added a commit that referenced this pull request Jun 14, 2012
@psychs psychs merged commit 6102cb2 into master Jun 14, 2012
@caniszczyk caniszczyk deleted the autolink_more_options branch July 8, 2014 14:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants