New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mdtt

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdtt

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

latest
npmnpm
Version
1.2.1
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

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>

FAQs

Package last updated on 20 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts