# anchor-markdown-header

> Generates an anchor for a markdown header.

Latest version **0.8.4** (published 2026-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install anchor-markdown-header
pnpm add anchor-markdown-header
yarn add anchor-markdown-header
bun add anchor-markdown-header
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; high maintenance score.

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

## Facts

| | |
|---|---|
| Version | 0.8.4 |
| Published | 2026-04-26 |
| First published | 2013-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 32.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 29 |
| Author | Thorsten Lorenz |
| Maintainers | thlorenz, andrewsouthpaw |
| Keywords | markdown, anchor, link, regex, github, readme |

## Links

- npm: https://www.npmjs.com/package/anchor-markdown-header
- Repository: https://github.com/thlorenz/anchor-markdown-header
- Homepage: https://github.com/thlorenz/anchor-markdown-header#readme
- Issues: https://github.com/thlorenz/anchor-markdown-header/issues
- npm.io page: https://npm.io/package/anchor-markdown-header

## Dependencies (2)

- [emoji-regex](https://npm.io/package/emoji-regex.md) ~10.6.0
- [remove-markdown](https://npm.io/package/remove-markdown.md) ^0.6.2

## 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

- 0.8.4 (latest) — 2026-04-26
- 0.8.0 (backfill) — 2026-02-04
- 0.8.3 — 2026-03-30
- 0.8.2 — 2026-02-09
- 0.8.1 — 2026-02-04
- 0.7.0 — 2022-12-07
- 0.6.0 — 2022-09-21
- 0.5.7 — 2017-02-20
- 0.5.6 — 2016-10-24
- 0.5.5 — 2016-06-06
- 0.5.4 — 2015-07-01
- 0.5.3 — 2015-04-07
- 0.5.2 — 2015-04-07
- 0.5.1 — 2015-01-13
- 0.5.0 — 2015-01-12
- … 15 more at https://npm.io/package/anchor-markdown-header/versions

## README

# anchor-markdown-header [![Node.js CI](https://github.com/thlorenz/anchor-markdown-header/actions/workflows/node.js.yml/badge.svg)](https://github.com/thlorenz/anchor-markdown-header/actions/workflows/node.js.yml)

Generates an anchor for a markdown header.

## Example

```js
var anchor = require('anchor-markdown-header');

anchor('"playerJoined" (player)'); 
// --> ["playerJoined" (player)](#playerjoined-player)

anchor('fs.rename(oldPath, newPath, [callback])', 'nodejs.org', 'fs') 
// --> [fs.rename(oldPath, newPath, [callback])](#fs_fs_rename_oldpath_newpath_callback)

// github.com mode is default
anchor('"playerJoined" (player)') === anchor('"playerJoined" (player)', 'github.com'); 
// --> true
```

## API

`anchor(header[, mode] [, repetition] [, href])`

```js
/**
 * @name anchorMarkdownHeader
 * @function
 * @param header      {String} The header to be anchored.
 * @param mode        {String} The anchor mode (github.com|nodejs.org|bitbucket.org|ghost.org|gitlab.com).
 * @param repetition  {Number} The nth occurrence of this header text, starting with 0. Not required for the 0th instance.
 * @param href        {String} The href to be used in the anchor.
 * @return            {String} The header anchor that is compatible with the given mode.
 */
```

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