How to use the turndown/lib/turndown.cjs.js function in turndown

To help you get started, we’ve selected a few turndown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zulip / zulip / static / js / copy_and_paste.js View on Github external
exports.paste_handler_converter = function (paste_html) {
    const turndownService = new TurndownService();
    turndownService.addRule('headings', {
        filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
        replacement: function (content) {
            return content;
        },
    });
    turndownService.addRule('emphasis', {
        filter: ['em', 'i'],
        replacement: function (content) {
            return '*' + content + '*';
        },
    });
    // Checks for raw links without custom text or title.
    turndownService.addRule('links', {
        filter: function (node) {
            return node.nodeName === "A" &&

turndown

A library that converts HTML to Markdown

MIT
Latest version published 6 months ago

Package Health Score

80 / 100
Full package analysis