Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parts of js/README.md are wrong #323

Open
arizonagroovejet opened this issue Jun 6, 2020 · 2 comments
Open

Parts of js/README.md are wrong #323

arizonagroovejet opened this issue Jun 6, 2020 · 2 comments
Assignees
Labels
documentation Issues in the documentation javascript

Comments

@arizonagroovejet
Copy link

Until earlier today when I found myself wanting to understand how Twitter calculates the length of a potential tweet and needed to do some tests, I'd never done anything with Node.js. But I'm pretty certain that parts of https://github.com/twitter/twitter-text/blob/master/js/README.md are wrong.

I was confused by

The twttr.txt namespace is exported, making it available as such:

because the following code is

var twitter = require('twitter-text')
twitter.autoLink(twitter.htmlEscape('#hello < @world >'))

so where does twttr.txt come from? But the rest of the example code uses twttr.txt so I thought I guess it's correct and it's just my lack of understanding of how this stuff works. So I assembled the following, copy/pasted from the example code

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

And it didn't work.

somethingTest.js:3
console.log(twttr.txt.parseTweet(tweet));
            ^

ReferenceError: twttr is not defined

So I changed line 3 to

console.log(twitter.parseTweet(tweet));

and that worked.

The "Tweet Parsing" section describes the fields validDisplayRangeStart and validDisplayRangeEnd neither of which appear in the example output that follows. The order of fields in the example output

  {
    weightedLength: 20,
    permillage: 71,
    valid: true,
    displayRangeEnd: 19,
    displayRangeStart: 0,
    validRangeEnd: 19,
    validRangeStart: 0
  }

doesn't match the order they appear in actual output

~/tweetLengthTest>node somethingTest.js 
{
  weightedLength: 20,
  valid: true,
  permillage: 71,
  validRangeStart: 0,
  validRangeEnd: 19,
  displayRangeStart: 0,
  displayRangeEnd: 19
}
~/tweetLengthTest>
@andypiper andypiper added documentation Issues in the documentation javascript labels Jun 10, 2020
@remjx
Copy link

remjx commented Jul 25, 2020

There is also a broken link in the js readme:

Details about Twitter's weighted counting scheme are available on the official developer website.

@andypiper
Copy link
Contributor

Thanks, we moved that content to https://developer.twitter.com/en/docs/basics/counting-characters - will make a note to update that for the next time we sync with GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Issues in the documentation javascript
Development

No branches or pull requests

4 participants