0.1.2 • Published 2 years ago
marked-escaping-tokenizer v0.1.2
marked-escaping-tokenizer
A custom tokenizer to disable custom HTML in Marked Markdown made by Scitotec GmbH.
Why?
Because we like to use markdown as a simple markup language without the preordained target HTML. The target might be a PDF or something completely different. None of these other targets support HTML.
Another reason is, that generally escaped Markdown provides a much more secure way to render markdown input by users which may not be trusted.
How to use it with Marked?
You can just create a new EscapingTokenizer
with an escaper of your choice. We recommend escape-html.
Install with your package manager:
npm install --save marked-escaping-tokenizer
npm install --save escape-html
Configure and use:
import { EscapingTokenizer } from 'marked-escaping-tokenizer'
import * as escapeHtml from 'escape-html'
import * as marked from 'marked'
// init your tokenizer
const tokenizer = new EscapingTokenizer()
tokenizer.escaper = (s) => escapeHtml(s)
// use marked as you wish
const html = marked(input, { tokenizer: tokenizer })
Publishing
npm version <major|minor|patch>
npm run build
git push <version>
git push
npm publish