src/anchorSlugger.js
function slugger (header, mode) {
  mode = mode || 'marked'
  let replace

  switch (mode) {
    case MODE.MARKED:
      replace = getMarkedId
      break
    case MODE.MARKDOWNIT:
      return getMarkDownItAnchorId(header)
    case MODE.GITHUB:
      replace = getGithubId
      break
    case MODE.GITLAB:
      replace = getGitlabId
      break
    case MODE.PANDOC:
      replace = getPandocId
      break
    case MODE.BITBUCKET:
      replace = getBitbucketId
      break
    case MODE.GHOST:
      replace = getGhostId
      break
    default:
      throw new Error('Unknown mode: ' + mode)
  }

  const href = replace(asciiOnlyToLowerCase(header.trim()))

  return encodeURI(href)
}
function slugger (header, mode) {
  mode = mode || 'marked'
  let replace

  switch (mode) {
    case MODE.MARKED:
      replace = getMarkedId
      break
    case MODE.MARKDOWNIT:
      return getMarkDownItAnchorId(header)
    case MODE.GITHUB:
      replace = getGithubId
      break
    case MODE.GITLAB:
      replace = getGitlabId
      break
    case MODE.PANDOC:
      replace = getPandocId
      break
    case MODE.BITBUCKET:
      replace = getBitbucketId
      break
    case MODE.GHOST:
      replace = getGhostId
      break
    default:
      throw new Error('Unknown mode: ' + mode)
  }

  const href = replace(asciiOnlyToLowerCase(header.trim()))

  return encodeURI(href)
}
function slugger ( header , mode ) { mode = mode || 'marked' let replace switch ( mode ) { case MODE . MARKED : replace = getMarkedId break case MODE . MARKDOWNIT : return getMarkDownItAnchorId ( header ) case MODE . GITHUB : replace = getGithubId break case MODE . GITLAB : replace = getGitlabId break case MODE . PANDOC : replace = getPandocId break case MODE . BITBUCKET : replace = getBitbucketId break case MODE . GHOST : replace = getGhostId break default : throw new Error ( 'Unknown mode: ' + mode ) } const href = replace ( asciiOnlyToLowerCase ( header . trim ( ) ) ) return encodeURI ( href ) }
Generates an anchor for the given header and mode.

@param header      {String} The header to be anchored.
@param mode        {String} The anchor mode (github.com|nodejs.org|bitbucket.org|ghost.org|gitlab.com).
@return            {String} The header anchor that is compatible with the given mode.
Generates an anchor for the given header and mode .