@alexbosworth/html2unicode

1.1.5 • Public • Published

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

html html2unicode(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>'
𝗯𝗼𝗹𝗱

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.5
    92
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.5
    92
  • 1.1.4
    0

Package Sidebar

Install

npm i @alexbosworth/html2unicode

Weekly Downloads

92

Version

1.1.5

License

ISC

Unpacked Size

13.2 kB

Total Files

9

Last publish

Collaborators

  • alexbosworth