Socket
Socket
Sign inDemoInstall

tweet-html

Package Overview
Dependencies
5
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tweet-html

reparse tweets returned by twitter API to HTML


Version published
Weekly downloads
2
decreased by-89.47%
Maintainers
1
Install size
47.8 kB
Created
Weekly downloads
 

Readme

Source

NPM version Build Status Dependency Status Dev Dependency Status

reparse tweets returned by twitter API to HTML

Installation

Install with npm:

$ 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:

{
  "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:

<a href="https://twitter.com/stratton/status/413684211087048704" target="_blank" class="date">
  '3 days ago'
</a>
<div class="text">Look for the East Byrneside boarder cross course this weekend!</div>
<iframe src="https://vine.co/v/h0UBzVLzA5O/embed/simple" class="video vine"></iframe>

Check tests for more examples.

License

MIT

Keywords

FAQs

Last updated on 17 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc