1.0.2 ā€¢ Published 3 years ago

@rqbazan/md-to-html v1.0.2

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

md-to-html

unified processor to parse and serialize Markdown to HTML. Powered by my favorite plugins.

npm version

Install

> yarn add @rqbazan/md-to-html

Usage

Say we have the following file, doc.md

---
title: This personal site
date: 2020-12-25
author: Santiago Q. Bazan
---

# Sample note :tada:

Here's a quick _sample note_

And our script, index.js, looks as follows:

import path from 'path'
import fs from 'fs'
import mdToHtml from '@rqbazan/md-to-html'

function main() {
  const pathfile = path.join(__dirname, 'doc.md')
  const doc = fs.readFileSync(pathfile)
  const vfile = mdToHtml.processSync(doc)

  console.log(vfile.data) // yaml metadata
  console.log(vfile.toString()) // html
}

main()

Now, running node index.js yields:

Ī» node index.js
{
  title: 'This personal site',
  date: '2020-12-25',
  author: 'Santiago Q. Bazan'
}
<h1>Sample note <img class="emoji" draggable="false" alt="šŸŽ‰" src="https://twemoji.maxcdn.com/v/13.0.1/72x72/1f389.png" title="šŸŽ‰"/></h1>
<p>Here's a quick <em>sample note</em></p>

Here is the generated HTML:

<h1>
  Sample note
  <img
    class="emoji"
    draggable="false"
    alt="šŸŽ‰"
    src="https://twemoji.maxcdn.com/v/13.0.1/72x72/1f389.png"
    title="šŸŽ‰"
  />
</h1>
<p>Here's a quick <em>sample note</em></p>

Plugins

License

MIT Ā© Ricardo Q. Bazan