Skip to content

lechengyu/anchor-markdown-header

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

anchor-markdown-header build status

Generates an anchor for a markdown header.

Add A New Anchor Mode for Hexo

var anchor = require('anchor-markdown-header');
anchor('1.1. About Unicode');
// --> [1.1. About Unicode](#11-about-unicode)
anchor('1.1. About Unicode','hexo');
// --> [1.1. About Unicode](#1-1-About-Unicode)
// compare to github mode, hexo mode not to transform the string to lower case, and not join the level number together

Example

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)

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

About

Generates an anchor for a markdown header.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%