1.2.1 • Published 3 years ago

mdtt v1.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

MDTT

MDTT is a tagged template library for markdown. It automatically sanitizes markdown used in tagged template inputs, while still allowing nested templates.

Examples

When unsafe input is used, it's automatically sanitized.

import MDTT from 'mdtt';

const m = MDTT();

// Untrusted input from another source
const unsafe = '**world**';

console.log(m`Hello, ${unsafe}!`);
// Hello, \*\*world\*\*!

However, safe input works just fine.

// Trusted input, generated by MDTT
const safe = m`**bold** text`;

console.log(m`Ooh, ${safe}`);
// Ooh, **bold** text

Arrays are also supported.

console.log(m`Items:\n${['Item 1', 'Item 2'].map((n) => m`- ${n}\n`)}`);
// Items:
// - Item 1
// - Item 2

You can also enable HTML sanitization.

import MDTT from 'mdtt';

const m = MDTT({ sanitizeHtml: true });

// Untrusted input from another source
const unsafe = '<div>untrusted</div>';

console.log(m`<h1>Hello, ${unsafe}!</h1>`);
// <h1>Hello, &lt;div&gt;untrusted&lt;/div&gt;!</h1>
1.2.1

3 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago