mdast-util-inject
Inject some markdown into some other markdown, keeping heading structure intact.
Last updated 9 years ago by anandthakker .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install mdast-util-inject 
SYNC missed versions from official npm registry.

Circle CI js-standard-style

An mdast utility to inject some markdown into some other markdown, keeping heading structure intact.

Install

npm install mdast-util-inject

Usage

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

Parameters

  • targetHeadingText string The heading to look for in the target ast
  • targetAst object The target markdown document, as an mdast
  • toInjectAst object The source markdown to be injected into the target, also as an mdast.

Examples

var mdast = require('mdast')
var inject = require('mdast-util-inject')

var target = mdast.parse('# A document\n## Section1\nBlah\n## Section2\nBlargh')
var newStuff = mdast.parse('# Some other document\nwith some content')
inject('Section1', target, newStuff)

console.log(mdast.stringify(target))
// outputs:
// # A document
//
// ## Section1
//
// ### Some other document
//
// with some content
//
// ## Section2
//
// Blargh

Returns boolean whether the specified section was found and content inserted

Current Tags

  • 1.1.0                                ...           latest (9 years ago)

2 Versions

  • 1.1.0                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 4
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (9)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE