https://github.com/rqbazan/md-to-html
unified processor to parse and serialize Markdown to HTML. Powered by my favorite plugins.
https://github.com/rqbazan/md-to-html
html markdown unified
Last synced: 6 months ago
JSON representation
unified processor to parse and serialize Markdown to HTML. Powered by my favorite plugins.
- Host: GitHub
- URL: https://github.com/rqbazan/md-to-html
- Owner: rqbazan
- License: mit
- Created: 2020-12-24T23:00:00.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-01T07:08:22.000Z (over 4 years ago)
- Last Synced: 2025-03-18T05:53:15.233Z (7 months ago)
- Topics: html, markdown, unified
- Language: TypeScript
- Homepage:
- Size: 166 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# md-to-html
[**unified**][unified] processor to parse and serialize Markdown to HTML.
Powered by my favorite plugins.[](https://badge.fury.io/js/%40rqbazan%2Fmd-to-html)
## Install
```sh
> yarn add @rqbazan/md-to-html
```## Usage
Say we have the following file, `doc.md`
```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:
```js
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:
```text
λ node index.js
{
title: 'This personal site',
date: '2020-12-25',
author: 'Santiago Q. Bazan'
}Sample note
![]()
Here's a quick sample note
```Here is the generated HTML:
```html
Sample note
![]()
Here's a quick sample note
```## Plugins
- [remark-parse](https://www.npmjs.org/package/remark-parse)
- [remark-frontmatter](https://www.npmjs.org/package/remark-frontmatter)
- [remark-extract-frontmatter](https://www.npmjs.org/package/remark-extract-frontmatter)
- [remark-gemoji](https://www.npmjs.org/package/remark-gemoji)
- [remark-twemoji](https://www.npmjs.org/package/remark-twemoji)
- [remark-html](https://www.npmjs.org/package/remark-html)## License
[MIT][license] © [Ricardo Q. Bazan][author]
[unified]: https://github.com/unifiedjs/unified
[author]: https://sxntixgo.codes
[license]: https://github.com/rqbazan/md-to-html/blob/main/LICENSE