Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/anchor-markdown-header
Generates an anchor for a markdown header.
https://github.com/thlorenz/anchor-markdown-header
Last synced: 5 days ago
JSON representation
Generates an anchor for a markdown header.
- Host: GitHub
- URL: https://github.com/thlorenz/anchor-markdown-header
- Owner: thlorenz
- License: mit
- Created: 2013-02-07T13:13:28.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-03-22T00:15:54.000Z (almost 2 years ago)
- Last Synced: 2024-12-08T16:11:47.625Z (14 days ago)
- Language: JavaScript
- Size: 224 KB
- Stars: 27
- Watchers: 7
- Forks: 22
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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] [, moduleName] [, repetition)`
```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 moduleName {String} The name of the module of the given header (required only for 'nodejs.org' mode).
* @return {String} The header anchor that is compatible with the given mode.
*/
```