2.7.0 • Published 5 years ago

html-to-formatted-text v2.7.0

Weekly downloads
1,546
License
MIT
Repository
github
Last release
5 years ago

html-to-formatted-text

Tests Coverage MIT License version downloads semantic-release

What

Converts HTML to formatted plain text.

From:

"<p>Some text.</p><p>More text.</p><div>Even more text.</div>"

To:

Some text.

More text.

Even more text.

Usage

Node

Installation

npm install --save html-to-formatted-text
const htmlToFormattedText = require("html-to-formatted-text");
htmlToFormattedText("<p>foo</p><p>bar</p>"); // Output: "foo\nbar"

ES6

// ES6
import htmlToFormattedText from "html-to-formatted-text";
htmlToFormattedText("<p>foo</p><p>bar</p>"); // Output: "foo\nbar"

Vanilla JS / UMD

<!-- latest version -->
<script src="https://unpkg.com/html-to-formatted-text/dist/index.umd.min.js"></script>
<!-- or for a specific version -->
<script src="https://unpkg.com/html-to-formatted-text@X.Y.Z/dist/index.umd.min.js"></script>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    window.htmlToFormattedText('<p>foo</p><p>bar</p>') // Output: "foo\nbar"
  });
</script>

Why

You might have HTML that you want to display as text.

One use case might be that a user adds HTML via an online editor TinyMCE and you want to display this as plain text somewhere else.

Contributing

  • Create an issue on Github
  • Fork project
  • Make changes then use npm run commit to make commits
  • Create a pull request
2.7.0

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

6 years ago

2.5.0

6 years ago

2.4.0

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago