It converts HTML to Markdown using remark and rehype.
npm install @inkdropapp/html2markdown
Say we have the following markdown file, example.md
:
<h1>Hello, world!</h1>
And our script, example.js
, looks as follows:
import { html2Markdown } from '@inkdropapp/html2markdown'
import fs from 'fs'
const doc = fs.readFileSync('example.md')
const md = html2Markdown(doc)
console.log(md)
Now, running node example
yields:
# Hello, world!
Converts the given HTML to Markdown.
-
options.toMdast
— The options for hast-util-to-mdast -
options.stringify
— The formatting options for mdast-util-to-markdown