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
- Host: GitHub
- URL: https://github.com/lovasoa/html2unicode
- Owner: lovasoa
- Created: 2018-09-05T16:44:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-07T17:31:29.000Z (over 4 years ago)
- Last Synced: 2025-03-16T16:03:41.922Z (10 months ago)
- Language: JavaScript
- Size: 73.2 KB
- Stars: 10
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
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'
๐ฏ๐ผ๐น๐ฑ
```