An open API service indexing awesome lists of open source software.

https://github.com/pirxpilot/tweet-html

reparse tweets returned by twitter API to HTML
https://github.com/pirxpilot/tweet-html

Last synced: about 1 year ago
JSON representation

reparse tweets returned by twitter API to HTML

Awesome Lists containing this project

README

          

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]

reparse tweets returned by twitter API to HTML

## Installation

Install with [npm](http://npmjs.org):

$ npm install tweet-html

## API

### tweet2html(tweet, username[, options])

Parse [tweet entities] contained in [tweet] object returned by one of the [Twitter API] calls.

- `tweet` - tweet object
- `username` -
- `opts` - _optional_ - at the moment only `formatDate` is supported; if not provided `created_at`
dates are formated to display _3 hours ago_ or _a year ago_

In addition to usual suspects (user mentions, hashtags, urls) it also parses and embeds vine,
instagram, youtube and vimeo links.

Given:

```json
{
"id_str": "413684211087048704",
"created_at": "Thu Dec 19 14:56:16 +0000 2013",
"text": "Look for the East Byrneside boarder cross course this weekend! https://t.co/zbGXyOjmlr",
"entities": {
"urls": [
{
"url": "https://t.co/zbGXyOjmlr",
"expanded_url": "https://vine.co/v/h0UBzVLzA5O",
"display_url": "vine.co/v/h0UBzVLzA5O",
"indices": [
63,
86
]
}
]
}
}
```

Renders:

```html

'3 days ago'

Look for the East Byrneside boarder cross course this weekend!

```

Check [tests](test/tweet-html.js) for more examples.

## License

MIT

[tweet]: https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/tweet-object
[tweet entities]: https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object
[Twitter API]: https://developer.twitter.com/en/docs/api-reference-index

[npm-image]: https://img.shields.io/npm/v/tweet-html
[npm-url]: https://npmjs.org/package/tweet-html

[build-url]: https://github.com/pirxpilot/tweet-html/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/workflow/status/pirxpilot/tweet-html/check

[deps-image]: https://img.shields.io/librariesio/release/npm/tweet-html
[deps-url]: https://libraries.io/npm/tweet-html