How to use the twitter-text.autoLink function in twitter-text

To help you get started, we’ve selected a few twitter-text examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bvaughn / tweets / src / components / Tweet.js View on Github external
reduced.push(
            <a href="{`https://twitter.com/${mention.screenName}`}">
              @{mention.screenName}
            </a>
          );
          reduced.push(' ');
          return reduced;
        }, []);
      }
    }

    if (!isScrolling) {
      text = t.autoLink(text, AUTO_LINK_OPTIONS);
    }

    // Upscale user profile images; for some reason the API sends blurry low-res pictures.
    let profileImageSource = tweet.user.profile_image_url_https;
    if (profileImageSource.indexOf('_normal.') &gt;= 0) {
      profileImageSource = profileImageSource.replace('_normal.', '_bigger.');
    }

    return (
      <div>
        {retweeter &amp;&amp;
          <div>
            <i aria-hidden="true"></i></div></div>
github DefinitelyTyped / DefinitelyTyped / types / twitter-text / twitter-text-tests.ts View on Github external
if (isHashtagEntity(e)) {
        console.log("hashtag: ", e.hashtag);
    } else if (isUrlEntity(e)) {
        console.log("url: ", e.url);
    } else if (isMentionEntity(e)) {
        console.log("screenName: ", e.screenName);
    } else if (isCashtagEntity(e)) {
        console.log("cashtag: ", e.cashtag);
    } else {
        console.error("Unreachable");
    }
    console.log(`indices: (${e.indices[0]}, ${e.indices[1]})`);
}

let result: string;
result = twitter.autoLink(text);
result = twitter.autoLinkUsernamesOrLists(text);
result = twitter.autoLinkHashtags(text);
result = twitter.autoLinkCashtags(text);
result = twitter.autoLinkUrlsCustom(text, {targetBlank: true, suppressNoFollow: true});

const len: number = twitter.getTweetLength(text);

const linked: string = twitter.autoLink("link @user, and expand url... http://t.co/0JG5Mcq", {
    urlEntities: [
        {
            url: "http://t.co/0JG5Mcq",
            display_url: "blog.twitter.com/2011/05/twitte…",
            expanded_url: "http://blog.twitter.com/2011/05/twitter-for-mac-update.html",
            indices: [
                30,
                48
github DefinitelyTyped / DefinitelyTyped / types / twitter-text / twitter-text-tests.ts View on Github external
} else {
        console.error("Unreachable");
    }
    console.log(`indices: (${e.indices[0]}, ${e.indices[1]})`);
}

let result: string;
result = twitter.autoLink(text);
result = twitter.autoLinkUsernamesOrLists(text);
result = twitter.autoLinkHashtags(text);
result = twitter.autoLinkCashtags(text);
result = twitter.autoLinkUrlsCustom(text, {targetBlank: true, suppressNoFollow: true});

const len: number = twitter.getTweetLength(text);

const linked: string = twitter.autoLink("link @user, and expand url... http://t.co/0JG5Mcq", {
    urlEntities: [
        {
            url: "http://t.co/0JG5Mcq",
            display_url: "blog.twitter.com/2011/05/twitte…",
            expanded_url: "http://blog.twitter.com/2011/05/twitter-for-mac-update.html",
            indices: [
                30,
                48
            ]
        }
    ]});

const usernames: string[] = twitter.extractMentions("Mentioning @twitter and @jack");
github DefinitelyTyped / DefinitelyTyped / twitter-text / twitter-text-tests.ts View on Github external
} else {
        console.error("Unreachable");
    }
    console.log(`indices: (${e.indices[0]}, ${e.indices[1]})`);
}

let result: string;
result = twitter.autoLink(text);
result = twitter.autoLinkUsernamesOrLists(text);
result = twitter.autoLinkHashtags(text);
result = twitter.autoLinkCashtags(text);
result = twitter.autoLinkUrlsCustom(text);

const len: number = twitter.getTweetLength(text);

const linked: string = twitter.autoLink("link @user, and expand url... http://t.co/0JG5Mcq", {
    urlEntities: [
        {
            url: "http://t.co/0JG5Mcq",
            display_url: "blog.twitter.com/2011/05/twitte…",
            expanded_url: "http://blog.twitter.com/2011/05/twitter-for-mac-update.html",
            indices: [
                30,
                48
            ]
        }
    ]});

const usernames: string[] = twitter.extractMentions("Mentioning @twitter and @jack");
github gr2m / twitter-together / lib / pull-request / create-check-run.js View on Github external
.map(tweet => {
          const text = autoLink(tweet.text).replace(/(^|\n)/g, "$1> ");

          if (tweet.valid) {
            return `### ✅ Valid

${text}`;
          }

          return `### ❌ Invalid

${text}

The above tweet is ${tweet.weightedLength - 280} characters too long`;
        })
        .join("\n\n---\n\n")
github kossnocorp / chirrapp / src / app / UI / Editor / Thread / Tweet / index.jsx View on Github external
function highlight(tweet) {
  return autoLink(htmlEscape(tweet), {
    targetBlank: true
  })
}
github abraham / twitter-user / src / twitter-user.ts View on Github external
private get linkedText() {
    return unsafeHTML(autoLink(this._user.description, this.autoLinkOptions));
  }
github meritt / twtcst / lib / beautify / auto_link.js View on Github external
return function(tweet) {
    if (auto === true) {
      tweet.text = twitter.autoLink(tweet.text, {
        target: '_blank'
      });
    } else {
      tweet.text = twitter.autoLinkUrlsCustom(tweet.text, {
        target: '_blank'
      });
    }

    return tweet;
  };
};