md-writer
v1.1.0
Published
A utility module for writing Markdown adhering to the CommonMark spec.
Downloads
52
Maintainers
Readme
md-writer
A utility module for writing Markdown adhering to the CommonMark spec.
Install
yarn add md-writer # Or alternatively: `npm install md-writer`
Usage
import {
codeSpan,
fencedCodeBlock,
fencedJsCodeBlock,
fencedShCodeBlock,
fencedTsCodeBlock,
h1,
h2,
h3,
h4,
h5,
h6
} from 'md-writer';
codeSpan('<span>Hello world!</span>');
// > `<span>Hello world!</span>`
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 for details.
Testing
yarn test # Or alternatively: `npm test`
Reference
License
The MIT License (Expat). See the license file for details.