# rehype-postfix-footnote-anchors

Latest version **2.0.3** (published 2024-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install rehype-postfix-footnote-anchors
pnpm add rehype-postfix-footnote-anchors
yarn add rehype-postfix-footnote-anchors
bun add rehype-postfix-footnote-anchors
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.3 |
| Published | 2024-04-27 |
| First published | 2018-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 237 |
| Author | Victor Felder |
| Maintainers | situphen, talone |
| Keywords | rehype, footnotes |

## Links

- npm: https://www.npmjs.com/package/rehype-postfix-footnote-anchors
- Repository: https://github.com/zestedesavoir/zmarkdown.git#master
- Homepage: https://github.com/zestedesavoir/zmarkdown/tree/master#readme
- Issues: https://github.com/zestedesavoir/zmarkdown/issues
- npm.io page: https://npm.io/package/rehype-postfix-footnote-anchors

## Dependencies (1)

- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^2.0.3

## Recent versions

- 2.0.3 (latest) — 2024-04-27
- 2.0.2 — 2024-04-20
- 2.0.1 — 2021-02-14
- 2.0.0 — 2020-02-03
- 1.0.8 — 2019-08-29
- 1.0.7 — 2019-07-27
- 1.0.6 — 2019-04-14
- 1.0.5 — 2019-02-04
- 1.0.4 — 2018-11-23
- 1.0.3 — 2018-10-04
- 1.0.2 — 2018-08-09
- 1.0.1 — 2018-07-22

## README

# rehype-postfix-footnote-anchors [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status]


This [rehype][rehype] plugin appends a custom postfix to footnotes, or changes the anchors/IDs to/from footnotes.

When you render several pieces of Markdown to HTML in a same webpage you might want to make sure that footnotes will not conflict between each piece of rendered HTML.

For instance:

*
    ```md
    foo[^foo]

    [^foo]: Footnote :)
    ```
*
    ```md
    bar[^foo]

    [^foo]: Conflict?
    ```

Rendering both of these will have the note next to `bar` link to `Footnote :)` instead of `Conflict?`, and `Conflict?` will have a link to go back to `foo` instead of `bar`.

This plugin plays well with [remark-numbered-footnotes](https://www.npmjs.com/package/remark-numbered-footnotes). Using `remark-numbered-footnotes` increases the risks of conflicts, hence the interest of postfixing footnote anchors.

## Installation

[npm][npm]:

```bash
npm install rehype-postfix-footnote-anchors
```

## Usage

Dependencies:

```javascript
const unified = require('unified')
const remarkParse = require('remark-parse')
const rehypePostfixFoonotes = require('rehype-postfix-footnote-anchors')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')

```

Usage:

```javascript
unified()
  .use(reParse, {footnotes: true})
  .use(remark2rehype)
  .use(rehypePostfixFoonotes, postfix)
  .use(stringify)
```

## Configuration

In the above **Usage** example, postfix can be one of two things:

* a string: `postfix = '-my-postfix'`

    `postfix` will be appended to the existing footnotes identifiers

* a function: `postfix = (identifier: string): string => 'foo' + identifier + 'bar'`

    `postfix` will be called with the footnote identifier and should return a string

## License

[MIT][license] © [Zeste de Savoir][zds]

<!-- Definitions -->

[build-badge]: https://img.shields.io/travis/zestedesavoir/zmarkdown.svg

[build-status]: https://travis-ci.org/zestedesavoir/zmarkdown

[coverage-badge]: https://img.shields.io/coveralls/zestedesavoir/zmarkdown.svg

[coverage-status]: https://coveralls.io/github/zestedesavoir/zmarkdown

[license]: https://github.com/zestedesavoir/zmarkdown/blob/master/packages/rehype-postfix-footnote-anchors/LICENSE-MIT

[zds]: https://zestedesavoir.com

[npm]: https://www.npmjs.com/package/rehype-postfix-footnote-anchors

[rehype]: https://github.com/rehypejs/rehype

---
_Source: https://npm.io/package/rehype-postfix-footnote-anchors · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
