# mdast-util-inject

> Inject some markdown into some other markdown, keeping heading structure intact.

Latest version **1.1.0** (published 2015-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install mdast-util-inject
pnpm add mdast-util-inject
yarn add mdast-util-inject
bun add mdast-util-inject
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-12-14 |
| First published | 2015-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Anand Thakker |
| Maintainers | anandthakker |
| Keywords | mdast |

## Links

- npm: https://www.npmjs.com/package/mdast-util-inject
- Repository: https://github.com/anandthakker/mdast-util-inject
- Homepage: https://github.com/anandthakker/mdast-util-inject#readme
- Issues: https://github.com/anandthakker/mdast-util-inject/issues
- npm.io page: https://npm.io/package/mdast-util-inject

## Dependencies (1)

- [mdast-util-to-string](https://npm.io/package/mdast-util-to-string.md) ^1.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2015-12-14
- 1.0.0 — 2015-12-13

## README

[![Circle CI](https://circleci.com/gh/anandthakker/mdast-util-inject.svg?style=svg)](https://circleci.com/gh/anandthakker/mdast-util-inject)
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

An [mdast](https://github.com/wooorm/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**

```javascript
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

---
_Source: https://npm.io/package/mdast-util-inject · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
