0.0.2 • Published 2 years ago

@yandeu/parse-markdown v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Parse Markdown

npm i @yandeu/parse-markdown

Three simple steps

1) Input

---
test: true
list:
  - one
  - two
---

# hello

This is a paragraph.

2) Code

import fs from 'fs/promises'
import { parseMarkdown } from '@yandeu/parse-markdown'

const main = async () => {
  const data = await fs.readFile('test.md', { encoding: 'utf-8' })
  const md = await parseMarkdown(data) // Promise<{ markdown: string; yaml: {}; }>
  console.log(md)
}
main()

3) Output

{
  "markdown": "<h1>hello</h1>\n<p>This is a paragraph.</p>",
  "yaml": { "test": true, "list": ["one", "two"] }
}

Need more? Make a pull request!