Skip to content

A renderer for Marked that outputs plain text instead of html

License

Notifications You must be signed in to change notification settings

edazpotato/marked-render-to-text

Repository files navigation

marked-renderer-text

Github | NPM

A custom renderer for Marked that renders markdown to plain text. Can be useful for when you want to show a preview snippet of an article (or anything written in markdown) without any rich formatting.

Usage

npm i marked-renderer-text
const { marked } = require("marked");
const { renderToText } = require("marked-renderer-text");
const testText = `# Title\n**bold text**\n- A\n- List\n- *of*\n- ~~things~~`;
marked.use({ renderer: renderToText() });
console.log(marked(testText)); // Note that it preseves newlines - you need to remove those yourself
/*
Title
bold text
A
List
of
things

*/

Options

You can enable fancy mode by passing true to the renderToText() function.

const { marked } = require("marked");
const { renderToText } = require("marked-renderer-text");
const testText = `# Title\n**bold text**\n- A\n- List\n- *of*\n- ~~things~~`;
marked.use({ renderer: renderToText(true) });
/*

Title

BOLD TEXT
- A
- List
- *of*
- ~things~

*/

About

A renderer for Marked that outputs plain text instead of html

Resources

License

Stars

Watchers

Forks

Packages

No packages published