Convert HTML to Markdown
Start by installing Turndown:
yarn add turndown
Then use Turndown's simple API to convert HTML to markdown:
var TurndownService = require('turndown'); var turndownService = new TurndownService(); var markdown = turndownService.turndown(`
DavidWalsh.Name is awesome!`); /* Title ===== [DavidWalsh.Name](https://davidwalsh.name) is awesome! */
You can use the interactive Turndown demo to experiment with its capabilities. Turndown has a number of options and allows you to use filters to keep elements you believe could be at risk for improper conversion.
Most developers look for a Markdown to HTML solution so it's rate to find myself in a position to need to convert HTML to Markdown. I look forward to migrating my site's content to Markdown so that writing posts is much less stressful in the future!