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

https://github.com/lovasoa/html2unicode

Node module for transforming HTML into unicode
https://github.com/lovasoa/html2unicode

Last synced: 10 months ago
JSON representation

Node module for transforming HTML into unicode

Awesome Lists containing this project

README

          

# html2unicode

Converts html strings into unicode strings that use
special unicode characters to simulate rich text.

It turns `Hello, world!` into `Hello, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!`.

## Try it from your browser

You can [try this library online](https://npm.runkit.com/html2unicode).

## Examples

| html | html2unicode(html) |
|------|--------------------|
|`Hello` | ๐—›๐—ฒ๐—น๐—น๐—ผ|
|`Hello, world!` | ๐—›๐—ฒ๐—น๐—น๐—ผ, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!|
|`hello` | ๐˜ฉ๐˜ฆ๐˜ญ๐˜ญ๐˜ฐ|
|`normal italics bolditalics` | normal ๐˜ช๐˜ต๐˜ข๐˜ญ๐˜ช๐˜ค๐˜ด ๐™—๐™ค๐™ก๐™™๐™ž๐™ฉ๐™–๐™ก๐™ž๐™˜๐™จ|
|`0123456789` | ๐Ÿฌ๐Ÿญ๐Ÿฎ๐Ÿฏ๐Ÿฐ๐Ÿฑ๐Ÿฒ๐Ÿณ๐Ÿด๐Ÿต|
|`

Hello, world!
` | ๐™ท๐šŽ๐š•๐š•๐š˜, ๐š ๐š˜๐š›๐š•๐š!|
|`Hello, world!` | ๐™ท๐šŽ๐š•๐š•๐š˜, ๐š ๐š˜๐š›๐š•๐š!|
|`Hello, world!` | ๐™ท๐šŽ๐š•๐š•๐š˜, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!|
|`007` | ๐Ÿถ๐Ÿถ๐Ÿฝ|
|`hello` | ๐“ฑ๐“ฎ๐“ต๐“ต๐“ธ|
|`x2` | xโ‚‚|
|`x(n+1)` | xโฝโฟโบยนโพ |

## API

See [the full documentation](api.md).

### Using ES6

```js
const html2unicode = require("html2unicode");

async function test() {
const htmlStr = "Hello, world!";
const result = await html2unicode.html2unicode(htmlStr);
console.log(result);
}

test() // This will display "๐—›๐—ฒ๐—น๐—น๐—ผ, ๐™ฌ๐™ค๐™ง๐™ก๐™™!";
```

### Using old-style promise chaining

```js
var html2unicode = require("html2unicode");

var htmlStr = "Hello, world!";

html2unicode
.html2unicode(htmlStr)
.then(function(str) {
console.log(str);
// This will display "๐—›๐—ฒ๐—น๐—น๐—ผ, ๐™ฌ๐™ค๐™ง๐™ก๐™™!";
});
```

## CLI

This package offers a command-line interface.

```bash
$ npx html2unicode 'bold'
๐—ฏ๐—ผ๐—น๐—ฑ
```