Last active
October 18, 2022 15:03
-
-
Save brkalow/bbe4b78a0456c849f4c6737fb9d7183a to your computer and use it in GitHub Desktop.
HTML to Markdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script src="https://unpkg.com/turndown/dist/turndown.js"></script> | |
| <script src="https://unpkg.com/turndown-plugin-gfm/dist/turndown-plugin-gfm.js"></script> | |
| </head> | |
| <body> | |
| <h1>Convert HTML to MD</h1> | |
| <textarea id="text"> </textarea> | |
| <button id="convert">Convert to MD (copies to clipboard)</button> | |
| <script type="text/javascript"> | |
| const gfm = turndownPluginGfm.gfm | |
| const turndownService = new TurndownService() | |
| turndownService.use(gfm) | |
| function convertToMd() { | |
| const markdown = turndownService.turndown( | |
| document.getElementById('text').value | |
| ) | |
| navigator.clipboard.writeText(markdown) | |
| } | |
| document.getElementById('convert').addEventListener('click', convertToMd) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment