# transform-markdown-links

> Transform the links in a Markdown file

Latest version **2.1.0** (published 2023-02-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install transform-markdown-links
pnpm add transform-markdown-links
yarn add transform-markdown-links
bun add transform-markdown-links
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2023-02-14 |
| First published | 2016-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 0 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Geoff Kimball |
| Maintainers | gakimball |
| Keywords | markdown, links, replace, transform |

## Links

- npm: https://www.npmjs.com/package/transform-markdown-links
- Repository: https://github.com/gakimball/transform-markdown-links
- Homepage: https://github.com/gakimball/transform-markdown-links#readme
- Issues: https://github.com/gakimball/transform-markdown-links/issues
- npm.io page: https://npm.io/package/transform-markdown-links

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2023-02-14
- 2.0.0 — 2017-03-19
- 1.1.0 — 2017-03-19
- 1.0.1 — 2017-02-13
- 1.0.0 — 2016-10-02

## README

# transform-markdown-links

[![Tests](https://github.com/gakimball/transform-markdown-links/actions/workflows/test.yml/badge.svg)](https://github.com/gakimball/transform-markdown-links/actions/workflows/test.yml)
[![npm](https://img.shields.io/npm/v/transform-markdown-links.svg?maxAge=2592000)](https://www.npmjs.com/package/transform-markdown-links)

> Transform the links in a Markdown file

Transforms the URLs of links in a Markdown file using a transform function.

## Installation

```bash
npm install transform-markdown-links
```

## Usage

```js
import transformLinks from 'transform-markdown-links';

const input = 'This [link](page.md) will be transformed.';

transformLinks(input, (link, text) => link + '?hooray');
// => 'This [link](page.md?hooray) will be transformed.'
```

## API

### transformLinks(input, transform)

Transform the links in a Markdown string using a transform function. Returns a String of Markdown with transformed links.

- **input** (String): Markdown input.
- **transform** (Function): Callback to transform each link. Should return a string to change the link's URL, or `undefined` to leave it as-is. Gets these parameters:
  - **link** (String): URL of the link.
  - **text** (String): text of the link.

## Local Development

```bash
git clone https://github.com/gakimball/transform-markdown-links
cd transform-markdown-links
npm install
npm test
```

## License

MIT &copy; [Geoff Kimball](http://geoffkimball.com)

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