@inkdropapp/html2markdown
v4.0.0
Published
Convert HTML to Markdown using remark and rehype
Downloads
342
Readme
html2markdown
It converts HTML to Markdown using remark and rehype.
install
npm install @inkdropapp/html2markdown
How to use
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!
API
html2Markdown(html, options)
Converts the given HTML to Markdown.
Options
options.toMdast
— The options for hast-util-to-mdastoptions.stringify
— The formatting options for mdast-util-to-markdown