Convert HTML into Markdown with JavaScript.
Note this is currently a work-in-progress to replace https://github.com/domchristie/to-markdown. It is pre-release software. API changes are likely.
npm:
npm install turndown
Browser:
<script src="https://unpkg.com/turndown/dist/turndown.js"></script>
// For Node.js
var TurndownService = require('turndown')
var turndownService = new TurndownService()
var markdown = turndownService.turndown('<h1>Hello world!</h1>')
Options can be passed in to the constructor on instantiation.
Option | Valid values | Default |
---|---|---|
headingStyle |
setext or atx |
setext |
hr |
Any Thematic break | * * * |
bulletListMarker |
- , + , or * |
* |
codeBlockStyle |
indented or fenced |
indented |
fence |
``` or ~~~ |
``` |
emDelimiter |
_ or * |
_ |
strongDelimiter |
** or __ |
** |
linkStyle |
inlined or referenced |
inlined |
linkReferenceStyle |
full , collapsed , or shortcut |
full |
turndown is copyright © 2017+ Dom Christie and released under the MIT license.