https://github.com/jbenner-radham/node-md-writer
A utility module for writing Markdown.
https://github.com/jbenner-radham/node-md-writer
commonmark markdown md
Last synced: 8 months ago
JSON representation
A utility module for writing Markdown.
- Host: GitHub
- URL: https://github.com/jbenner-radham/node-md-writer
- Owner: jbenner-radham
- License: mit
- Created: 2017-09-29T21:22:22.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2022-12-29T22:10:03.000Z (almost 3 years ago)
- Last Synced: 2024-04-24T15:13:45.055Z (over 1 year ago)
- Topics: commonmark, markdown, md
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
md-writer
=========
[![CI Status][CI BADGE]][CI PAGE]
A utility module for writing [Markdown][MARKDOWN] adhering to the [CommonMark][COMMONMARK] spec.
Install
-------
```sh
yarn add md-writer # Or alternatively: `npm install md-writer`
```
Usage
-----
```js
import {
codeSpan,
fencedCodeBlock,
fencedJsCodeBlock,
fencedShCodeBlock,
fencedTsCodeBlock,
h1,
h2,
h3,
h4,
h5,
h6
} from 'md-writer';
codeSpan('Hello world!');
// > `Hello world!`
fencedCodeBlock('5 + 5');
// > ```
// > 5 + 5
// > ```
fencedCodeBlock(`print('Hello world!')`, 'python');
// > ```python
// > print('Hello world!')
// > ```
fencedJsCodeBlock('console.log("Hello world!");');
// > ```js
// > console.log("Hello world!");
// > ```
fencedShCodeBlock(`print 'Hello world!'`);
// > ```sh
// > print 'Hello world!'
// > ```
fencedTsCodeBlock('console.log("Hello world!");');
// > ```ts
// > console.log("Hello world!");
// > ```
h1('Header One');
// > Header One
// > ==========
h2('Header Two');
// > Header Two
// > ----------
h3('Header Three');
// > ### Header Three
h4('Header Four');
// > #### Header Four
h5('Header Five');
// > ##### Header Five
h6('Header Six');
// > ###### Header Six
```
**NOTE**: This is a pure ESM package. See [here](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) for details.
Testing
-------
```sh
yarn test # Or alternatively: `npm test`
```
Reference
---------
- [CommonMark Spec](http://spec.commonmark.org/)
License
-------
The MIT License (Expat). See the [license file](LICENSE) for details.
[CI BADGE]: https://github.com/jbenner-radham/node-md-writer/actions/workflows/ci.yaml/badge.svg
[CI PAGE]: https://github.com/jbenner-radham/node-md-writer/actions/workflows/ci.yaml
[COMMONMARK]: http://commonmark.org/
[MARKDOWN]: https://daringfireball.net/projects/markdown/