src/anchorSlugger.js
function getBitbucketId (text) {
  text = 'markdown-header-' + text
    .toLowerCase()
    .replace(/\\(.)/g, (_m, c) => c.charCodeAt(0)) // add escaped chars with their charcode
    .normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
    .replace(/[^\w\s-]/g, '')
    .replace(/\s+/g, '-')     // whitespace
    .replace(/-+/g, '-')      // duplicated hyphen
    .replace(/^-+|-+$/g, '')  // heading/ tailing hyphen
  return text
}
function getBitbucketId (text) {
  text = 'markdown-header-' + text
    .toLowerCase()
    .replace(/\\(.)/g, (_m, c) => c.charCodeAt(0)) // add escaped chars with their charcode
    .normalize('NFKD').replace(/[\u0300-\u036f]/g, '')
    .replace(/[^\w\s-]/g, '')
    .replace(/\s+/g, '-')     // whitespace
    .replace(/-+/g, '-')      // duplicated hyphen
    .replace(/^-+|-+$/g, '')  // heading/ tailing hyphen
  return text
}
function getBitbucketId ( text ) { text = 'markdown-header-' + text . toLowerCase ( ) . replace ( / \\(.) / g , ( _m , c ) => c . charCodeAt ( 0 ) ) // add escaped chars with their charcode . normalize ( 'NFKD' ) . replace ( / [\u0300-\u036f] / g , '' ) . replace ( / [^\w\s-] / g , '' ) . replace ( / \s+ / g , '-' ) // whitespace . replace ( / -+ / g , '-' ) // duplicated hyphen . replace ( / ^-+|-+$ / g , '' ) // heading/ tailing hyphen return text }
getBitbucketId - anchors used at bitbucket.org
@private
@see: https://github.com/Python-Markdown/markdown/blob/master/markdown/extensions/toc.py#L25
There seams to be some "magic" preprocessor which could not be handled here.
@see: https://github.com/Python-Markdown/markdown/issues/222
If no repetition, or if the repetition is 0 then ignore. Otherwise append '_' and the number.
https://groups.google.com/d/msg/bitbucket-users/XnEWbbzs5wU/Fat0UdIecZkJ
getBitbucketId - anchors used at bitbucket . org