1.1.3 โ€ข Published 5 years ago

html2unicode v1.1.3

Weekly downloads
9
License
ISC
Repository
github
Last release
5 years ago

html2unicode

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

It turns Hello, <b>world</b>! into Hello, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!.

Try it from your browser

You can try this library online.

Examples

htmlhtml2unicode(html)
<b>Hello</b>๐—›๐—ฒ๐—น๐—น๐—ผ
<strong>Hello, world!</strong>๐—›๐—ฒ๐—น๐—น๐—ผ, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!
<em>hello</em>๐˜ฉ๐˜ฆ๐˜ญ๐˜ญ๐˜ฐ
normal <i>italics <b>bolditalics</b></i>normal ๐˜ช๐˜ต๐˜ข๐˜ญ๐˜ช๐˜ค๐˜ด ๐™—๐™ค๐™ก๐™™๐™ž๐™ฉ๐™–๐™ก๐™ž๐™˜๐™จ
<i><b>0123456789</b></i>๐Ÿฌ๐Ÿญ๐Ÿฎ๐Ÿฏ๐Ÿฐ๐Ÿฑ๐Ÿฒ๐Ÿณ๐Ÿด๐Ÿต
<pre>Hello, world!</pre>๐™ท๐šŽ๐š•๐š•๐š˜, ๐š ๐š˜๐š›๐š•๐š!
<code>Hello, world!</code>๐™ท๐šŽ๐š•๐š•๐š˜, ๐š ๐š˜๐š›๐š•๐š!
<code>Hello, <b>world</b>!</code>๐™ท๐šŽ๐š•๐š•๐š˜, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!
<samp>007</samp>๐Ÿถ๐Ÿถ๐Ÿฝ
<var>hello</var>๐“ฑ๐“ฎ๐“ต๐“ต๐“ธ
x<sub>2</sub>xโ‚‚
x<sup>(n+1)</sup>xโฝโฟโบยนโพ

API

See the full documentation.

Using ES6

const html2unicode = require("html2unicode");

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

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

Using old-style promise chaining

var html2unicode = require("html2unicode");

var htmlStr = "<b>Hello, <i>world</i></b>!";

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

CLI

This package offers a command-line interface.

$ npx html2unicode '<b>bold</b>'
๐—ฏ๐—ผ๐—น๐—ฑ
1.1.3

5 years ago

1.1.1

5 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago