@rqbazan/md-to-html
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @rqbazan/md-to-html

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

6.59 kB

Total Files

5

Last publish

Collaborators

  • rqbazan