<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta charset="utf-8" /> <title>HTML to Markdown</title> <script src="https://ss.netnr.com/turndown@7.2.0/lib/turndown.browser.umd.js"></script> </head> <body> <textarea></textarea> <div><button>HTML to Markdown</button></div> </body> </html>
textarea { width: 97vw; height: 62vh; }
let turndownService = new TurndownService({ headingStyle: "atx", hr: "---", bulletListMarker: "-", codeBlockStyle: "fenced", fence: "```", emDelimiter: "-", strongDelimiter: "**", linkStyle: "inlined", linkReferenceStyle: "full", preformattedCode: false }); let domTxt = document.querySelector('textarea'); let domBtn = document.querySelector('button'); domBtn.addEventListener("click", function () { var markdown = turndownService.turndown(domTxt.value); console.debug(markdown); domTxt.value = markdown; });