Node.js: convertire il codice HTML in Markdown

Node.js: convertire il codice HTML in Markdown

In Node.js possiamo convertire il codice HTML in Markdown.

Possiamo usare il modulo NPM turndown:


'use strict';

const TurndownService = require('turndown');

const HTMLToMd = htmlStr => {
    const turndownService = new TurndownService();
    return turndownService.turndown(htmlStr);
};

Il modulo ha varie opzioni di configurazione che possiamo passare come oggetto al costruttore della classe.

Torna su