@technote-space/anchor-markdown-header
TypeScript icon, indicating that this package has built-in type declarations

1.1.42 • Public • Published

anchor-markdown-header

npm version CI Status codecov CodeFactor License: MIT

Generates an anchor for a markdown header.

Table of Contents

Details

Install

yarn add @technote-space/anchor-markdown-header

Example

import anchor from '@technote-space/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)

/**
 * @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.
 */

Package Sidebar

Install

npm i @technote-space/anchor-markdown-header

Weekly Downloads

5,848

Version

1.1.42

License

MIT

Unpacked Size

12.7 kB

Total Files

5

Last publish

Collaborators

  • technote