https://github.com/posthtml/posthtml-md2html
Render markdown inside html elements.
https://github.com/posthtml/posthtml-md2html
Last synced: 10 months ago
JSON representation
Render markdown inside html elements.
- Host: GitHub
- URL: https://github.com/posthtml/posthtml-md2html
- Owner: posthtml
- License: mit
- Created: 2020-03-20T06:59:17.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T08:41:14.000Z (almost 4 years ago)
- Last Synced: 2024-10-29T21:06:06.623Z (over 1 year ago)
- Language: JavaScript
- Size: 1.1 MB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: contributing.md
- License: license
Awesome Lists containing this project
README
# posthtml-md2html 
[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Build][build]][build-badge]
[![Coverage][cover]][cover-badge]
[![Standard Code Style][style]][style-url]
[![Chat][chat]][chat-badge]
[posthtml-md2html] is a markdown plugin for [PostHTML] that lets you use markdown within HTML elements in an easy and intuitive way.
Main features:
- Works on any tag with a `md` or `markdown` property
- Knows when to write inline or block-level content
- Will replace element if tag is `` or ``
- Will treat `pre` tag with `md` or `markdown` property as `` tag
Before:
``` html
# Heading with *italics*
**Bold** paragraph
| Head | row |
|------|-----|
| Data | row |
> # Title
>
> This is blockquote paragraph
```
After:
``` html
Heading with italics
Bold paragraph
Head
row
Data
row
Title
This is blockquote paragraph
```
## Install
```bash
npm i -S posthtml posthtml-md2html
```
> **Note:** This project is compatible with node v10+
## Usage
``` js
const fs = require('fs');
const posthtml = require('posthtml');
const posthtmlPlugin = require('posthtml-md2html');
posthtml()
.use(posthtmlPlugin({ /* options */ }))
.process(html/*, options */)
.then(result => fs.writeFileSync('./after.html', result.html));
```
## Options
All options are passed to [marked](https://github.com/markedjs/marked) directly
### Contributing
See [PostHTML Guidelines](https://github.com/posthtml/posthtml/tree/master/docs) and [contribution guide](CONTRIBUTING.md).
[npm]: https://img.shields.io/npm/v/posthtml-md2html.svg
[npm-url]: https://npmjs.com/package/posthtml-md2html
[deps]: https://david-dm.org/posthtml/posthtml-md2html.svg
[deps-url]: https://david-dm.org/posthtml/posthtml-md2html
[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/
[build]: https://travis-ci.org/posthtml/posthtml-md2html.svg?branch=master
[build-badge]: https://travis-ci.org/posthtml/posthtml-md2html?branch=master
[cover]: https://coveralls.io/repos/posthtml/posthtml-md2html/badge.svg?branch=master
[cover-badge]: https://coveralls.io/r/posthtml/posthtml-md2html?branch=master
[chat]: https://badges.gitter.im/posthtml/posthtml.svg
[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"