# html-to-tweets

> [![npm version](https://img.shields.io/npm/v/html-to-tweets.svg)](https://npm.im/html-to-tweets) [![CircleCI](https://img.shields.io/circleci/project/github/mjm/html-to-tweets/master.svg)](https://circleci.com/gh/mjm/html-to-tweets) ![ISC License](https:/

Latest version **2.0.0** (published 2019-08-04) · ISC license · 0 weekly downloads

## Install

```sh
npm install html-to-tweets
pnpm add html-to-tweets
yarn add html-to-tweets
bun add html-to-tweets
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2019-08-04 |
| First published | 2019-05-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 91.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt Moriarity |
| Maintainers | mmoriarity |

## Links

- npm: https://www.npmjs.com/package/html-to-tweets
- Repository: https://github.com/mjm/html-to-tweets
- Homepage: https://github.com/mjm/html-to-tweets#readme
- Issues: https://github.com/mjm/html-to-tweets/issues
- npm.io page: https://npm.io/package/html-to-tweets

## Dependencies (4)

- [htmlparser2](https://npm.io/package/htmlparser2.md) ^3.10.1
- [twitter-text](https://npm.io/package/twitter-text.md) ^3.0.0
- [@types/htmlparser2](https://npm.io/package/@types/htmlparser2.md) ^3.10.0
- [@types/twitter-text](https://npm.io/package/@types/twitter-text.md) ^2.0.0

## Recent versions

- 2.0.0 (latest) — 2019-08-04
- 1.3.0 — 2019-05-19
- 1.2.0 — 2019-05-19
- 1.1.0 — 2019-05-09
- 1.0.0 — 2019-05-09
- 0.2.0 — 2019-05-08
- 0.1.0 — 2019-05-07

## README

# html-to-tweets

[![npm version](https://img.shields.io/npm/v/html-to-tweets.svg)](https://npm.im/html-to-tweets)
[![CircleCI](https://img.shields.io/circleci/project/github/mjm/html-to-tweets/master.svg)](https://circleci.com/gh/mjm/html-to-tweets)
![ISC License](https://img.shields.io/npm/l/html-to-tweets.svg)

A simple, opinionated translator from HTML microblog post to tweets for posting on Twitter.

## Installation

```
npm install html-to-tweets
```

## Usage

```javascript
const { translate } = require("html-to-tweets")

// Posts with titles and URLs turn into small link posts
const titledPost = {
  title: "My Blog Post",
  url: "https://example.com/my-blog-post/",
  html: "<p>If only I had something to say...</p>",
}
translate(titledPost)
// => [ { body: 'My Blog Post https://example.com/my-blog-post/', mediaURLs: [] } ]

// Untitled posts get their content reformatted for Twitter
const untitledPost = {
  title: "", // title can also be omitted
  url: "https://example.com/another-post/",
  html: `
<p>This post was <em>translated for Twitter</em> by
<a href="https://github.com/mjm/html-to-tweets">html-to-tweets</a>.
</p>
`,
}
translate(untitledPost)
// => [ { body: 'This post was translated for Twitter by html-to-tweets https://github.com/mjm/html-to-tweets', mediaURLs: [] } ]
```

---
_Source: https://npm.io/package/html-to-tweets · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
