An mdast utility to inject some markdown into some other markdown, keeping heading structure intact.
npm install mdast-util-inject
Inject some markdown into some other markdown at a desired heading. Heading levels in the source markdown are adjusted to match the target document based on the target heading's level. targetAst is modified in place
targetHeadingTextstring The heading to look for in the target ast
targetAstobject The target markdown document, as an mdast
toInjectAstobject The source markdown to be injected into the target, also as an mdast.
var mdast = var inject = var target = mdastvar newStuff = mdast console// outputs:// # A document//// ## Section1//// ### Some other document//// with some content//// ## Section2//// Blargh
Returns boolean whether the specified section was found and content inserted