# markdown-it-replace-link

> markdown-it plugin for replacing links (image & text) in the markdown document.

Latest version **1.2.2** (published 2024-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install markdown-it-replace-link
pnpm add markdown-it-replace-link
yarn add markdown-it-replace-link
bun add markdown-it-replace-link
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2024-11-20 |
| First published | 2015-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 56 |
| Author | Martin Heidegger |
| Maintainers | leichtgewicht |
| Keywords | markdown, markdown-it, markdown-it-plugin |

## Links

- npm: https://www.npmjs.com/package/markdown-it-replace-link
- Repository: https://github.com/martinheidegger/markdown-it-replace-link
- Issues: https://github.com/martinheidegger/markdown-it-replace-link/issues
- npm.io page: https://npm.io/package/markdown-it-replace-link

## 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.2.2 (latest) — 2024-11-20
- 1.2.1 — 2024-01-05
- 1.2.0 — 2023-01-25
- 1.1.0 — 2020-06-09
- 1.0.1 — 2017-02-15
- 1.0.0 — 2015-05-13

## README

# markdown-it-replace-link

> markdown-it plugin for replacing links (image & text) in the markdown document.

## Usage

#### Enable plugin

```js
var md = require('markdown-it')({
    html: true,
    linkify: true
})
.use(require('markdown-it-replace-link'), {
    processHTML: true, // defaults to false for backwards compatibility
    replaceLink: function (link, env, token, htmlToken) {
        return link + "?c=" + Date.now();
    }
})
```

#### Example

```md
[Hello](test)
```

and use this

```js
var md = require('markdown-it')({
    replaceLink: function (link, env, token, htmlToken) {
        return "http://me.com/" + link;
    }
}).use(require('markdown-it-replace-link'));
```


This will result in the link prefixed with the `http://me.com/` like:

```html
<p><a href="http://me.com/test">Hello</a></p>
```

Both images and html links will be processed.

If using this in a browser, the script will create a variable 
`window.markdownitReplaceLink` that can be passed to `.use()`.

### Testing

To run the tests use:
```bash
npm run test
```

### License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/markdown-it-replace-link · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
