marked-renderer-text
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

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.

Includes Typescript types.

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: new 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 as the first argument when initialising the class.

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: new RenderToText(true) });
/*

Title

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

*/

You can pass any normal marked renderer options as the second paramater (if you don't want to enable fancy mode, you should pass false as the first parameter when doing this).

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i marked-renderer-text

    Weekly Downloads

    16

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    5.09 kB

    Total Files

    4

    Last publish

    Collaborators

    • edazpotato_