twitter / twitter-text

Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.
https://developer.twitter.com/en/docs/counting-characters
Apache License 2.0
3.07k stars 510 forks source link

Example does not work... what is twttr? #375

Open LAMike310 opened 2 years ago

LAMike310 commented 2 years ago

Describe the bug Example code in the README doesn't work

To Reproduce Steps to reproduce the behavior:

  1. npm install twitter-text, import twitter from 'twitter-text', twttr.txt.parseTweet(tweet);, run the script
  2. ReferenceError: twttr is not defined

Expected behavior Example code should work to parse tweet

The fix for this is to write:

var twitter = require('twitter-text');
var tweet = "This is a test tweet";
console.log(twitter.parseTweet(tweet));