md-node-inject
v2.0.0
Published
Markdown AST injection utility
Downloads
11,763
Readme
Markdown AST injection utility
Install
This package is ESM only : Node 14+ is needed to use it and it must be imported instead of required.
npm install md-node-inject
Usage
import ast from 'markdown-to-ast';
import toMarkdown from 'ast-to-markdown';
import inject from 'md-node-inject';
const mdContent = `
# Sample
Description
# API
# License
MIT
`;
const mdApiContent = `
## method()
Method description
`;
const mdContentAst = ast.parse(mdContent);
const mdApiContentAst = ast.parse(mdApiContent);
const injectionSection = 'API';
const mergedContentAst = inject(injectionSection, mdContentAst, mdApiContentAst);
const mergedContent = toMarkdown(mergedContentAst);
console.log(mergedContent);
Output:
# Sample
Description
# API
## method()
Method description
# License
MIT
Development Setup
At the top-level of your project run:
direnv allow
The next time your launch your terminal and enter the top-level of your project,
direnv
will check for changes.
License
Under the MIT license. See LICENSE file for more details.