twitter-lang
A formal grammar defining tweet text.
This is a work in progress βΒ it is not ready for use.
Conformance Tests
This package aims to conform to the twitter-text conformance tests
Results: 191/196 (97%)
Example
import { parse } from 'twitter-lang';
parse('Hello @world, I love #hashtags and $twtr! https://twitter.com');
// ->
{
text: 'Hello @world, I love #hashtags and $twtr! https://twitter.com',
entities: {
hashtags: [
{ text: 'hashtags', indices: [21, 30] }
],
symbols: [
{ text: 'twtr', indices: [35, 40] }
],
urls: [
{ url: 'https://twitter.com', indices: [42, 61] }
],
user_mentions: [
{ screen_name: 'world', indices: [6, 12] }
]
}
};