diff --git a/dist/markdownItAnchor.js b/dist/markdownItAnchor.js index 3baf27f..6390486 100644 --- a/dist/markdownItAnchor.js +++ b/dist/markdownItAnchor.js @@ -1,2 +1,2 @@ -function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e}}(t.level),s=function(n){var t=0;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(n=function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(n,void 0):void 0}}(n)))return function(){return t>=n.length?{done:!0}:{done:!1,value:n[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=n[Symbol.iterator]()).next.bind(t)}(l);!(i=s()).done;){var u=i.value;if("heading_open"===u.type&&c(Number(u.tag.substr(1)))){var d=l.indexOf(u),f=l[d+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),p=u.attrGet("id");p=null==p?b(t.slugify(f),o,!1,t.uniqueSlugStartIndex):b(p,o,!0,t.uniqueSlugStartIndex),u.attrSet("id",p),!1!==t.tabIndex&&u.attrSet("tabindex",""+t.tabIndex),"function"==typeof t.permalink?t.permalink(p,t,n,d):(t.permalink||t.renderPermalink&&t.renderPermalink!==a)&&t.renderPermalink(p,t,n,d),t.callback&&t.callback(u,{slug:p,title:f})}}})}Object.assign(f.defaults,{style:"visually-hidden",space:!0,placement:"after"}),p.permalink={__proto__:null,legacy:a,renderHref:i,renderAttrs:o,makePermalink:c,linkInsideHeader:s,ariaHidden:u,headerLink:d,linkAfterHeader:f},p.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:a,permalinkClass:u.defaults.class,permalinkSpace:u.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===u.defaults.placement,permalinkHref:u.defaults.renderHref,permalinkAttrs:u.defaults.renderAttrs},module.exports=p; +var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function r(r,a,i,l){var o;if(!e){var c="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(c):console.warn(c),e=!0}var s=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(a.permalinkClass?[["class",a.permalinkClass]]:[],[["href",a.permalinkHref(r,i)]],Object.entries(a.permalinkAttrs(r,i)))}),Object.assign(new i.Token("html_block","",0),{content:a.permalinkSymbol,meta:t}),new i.Token("link_close","a",-1)];a.permalinkSpace&&i.tokens[l+1].children[n[a.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[a.permalinkBefore]].apply(o,s)}function a(e){return"#"+e}function i(e){return{}}var l={class:"header-anchor",symbol:"#",renderHref:a,renderAttrs:i};function o(e){function n(t){return t=Object.assign({},n.defaults,t),function(n,r,a,i){return e(n,t,r,a,i)}}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}var c=o(function(e,r,a,i,l){var o,c=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(r.class?[["class",r.class]]:[],[["href",r.renderHref(e,i)]],r.ariaHidden?[["aria-hidden","true"]]:[],Object.entries(r.renderAttrs(e,i)))}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("link_close","a",-1)];r.space&&i.tokens[l+1].children[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[r.placement]].apply(o,c)});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});var s=o(c.renderPermalinkImpl);s.defaults=Object.assign({},c.defaults,{ariaHidden:!0});var d=o(function(e,n,t,r,a){var i=[Object.assign(new r.Token("link_open","a",1),{attrs:[].concat(n.class?[["class",n.class]]:[],[["href",n.renderHref(e,r)]],Object.entries(n.renderAttrs(e,r)))})].concat(r.tokens[a+1].children,[new r.Token("link_close","a",-1)]);r.tokens[a+1]=Object.assign(new r.Token("inline","",0),{children:i})}),u=o(function(e,r,a,i,l){var o;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(r.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+r.style+"`");if(!["aria-describedby","aria-labelledby"].includes(r.style)&&!r.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+r.style+"` style");if("visually-hidden"===r.style&&!r.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var c=i.tokens[l+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=[],d=[];r.class&&d.push(["class",r.class]),d.push(["href",r.renderHref(e,i)]),d.push.apply(d,Object.entries(r.renderAttrs(e,i))),"visually-hidden"===r.style?(s.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",r.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:r.assistiveText(c)}),new i.Token("span_close","span",-1)),r.space&&s[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),s[n[r.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("span_close","span",-1))):s.push(Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t})),"aria-label"===r.style?d.push(["aria-label",r.assistiveText(c)]):["aria-describedby","aria-labelledby"].includes(r.style)&&d.push([r.style,e]);var u=[Object.assign(new i.Token("link_open","a",1),{attrs:d})].concat(s,[new i.Token("link_close","a",-1)]);(o=i.tokens).splice.apply(o,[l+3,0].concat(u))});function f(e,n,t,r){var a=e,i=r;if(t&&Object.prototype.hasOwnProperty.call(n,a))throw new Error("User defined `id` attribute `"+e+"` is not unique. Please fix it in your Markdown to continue.");for(;Object.prototype.hasOwnProperty.call(n,a);)a=e+"-"+i,i+=1;return n[a]=!0,a}function b(e,n){n=Object.assign({},b.defaults,n),e.core.ruler.push("anchor",function(e){for(var t,a={},i=e.tokens,l=Array.isArray(n.level)?(t=n.level,function(e){return t.includes(e)}):function(e){return function(n){return n>=e}}(n.level),o=0;o {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (const token of tokens) {\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n const index = tokens.indexOf(token)\n\n // Aggregate the next token children text.\n const title = tokens[index + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, index)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, index)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, index)\n }\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","selection","isLevelSelected","Array","isArray","level","isLevelSelectedNumber","Number","tag","substr","index","indexOf","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"0GAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,WAGJC,EAAsB,CAC1BC,mBAAmB,YAGLC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKZ,EAAgB,CACnB,IAAMa,EAAc,sIAEG,iBAAZC,SAAwBA,SAAWA,QAAQC,YACpDD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfb,GAAiB,EAGnB,IAAMkB,EAAa,CACjBC,OAAOC,OAAO,IAAIT,EAAMU,MAAM,YAAa,IAAK,GAAI,CAClDC,gBACMZ,EAAKa,eAAiB,CAAC,CAAC,QAASb,EAAKa,iBAAmB,IAC7D,CAAC,OAAQb,EAAKc,cAAcf,EAAME,KAC/BQ,OAAOM,QAAQf,EAAKgB,eAAejB,EAAME,OAGhDQ,OAAOC,OAAO,IAAIT,EAAMU,MAAM,aAAc,GAAI,GAAI,CAAEM,QAASjB,EAAKkB,gBAAiBC,KAAMvB,IAC3F,IAAIK,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKoB,gBACPnB,EAAMoB,OAAOnB,EAAM,GAAGoB,SAAS/B,EAASS,EAAKuB,kBAAkBd,OAAOC,OAAO,IAAIT,EAAMU,MAAM,OAAQ,GAAI,GAAI,CAAEM,QAAS,UAG1HhB,EAAMoB,OAAOnB,EAAM,GAAGoB,UAAS/B,EAASS,EAAKuB,0BAAqBf,YAGpDgB,EAAYzB,GAC1B,UAAWA,WAGG0B,EAAa1B,GAC3B,MAAO,GAGT,IAAM2B,EAAiB,CACrBC,MAAO,gBACPC,OAAQ,I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,MAAAA,QD+HrCpC,OAAOC,OAAO6B,EAAgBP,SAAU,CACtCS,MAAO,kBACPL,OAAO,EACPC,UAAW,UC5Hb4B,EAAOoB,8IAEPpB,EAAOjC,SAAW,CAChByC,MAAO,EACPQ,QAtFc,SAACM,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAuFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXtD,gBAAiBsD,EACjBxE,eAAgBwE,EAAqBrD,eACrCZ,eAAgBiE,EAAqBrD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C8D,EAAqBrD,SAASK,UAC/CvB,cAAeuE,EAAqBrD,SAASR,WAC7CR,eAAgBqE,EAAqBrD,SAASP"} \ No newline at end of file +{"version":3,"file":"markdownItAnchor.js","sources":["../permalink.js","../index.js"],"sourcesContent":["let emittedWarning = false\n\nconst position = {\n false: 'push',\n true: 'unshift',\n after: 'push',\n before: 'unshift'\n}\n\nconst permalinkSymbolMeta = {\n isPermalinkSymbol: true\n}\n\nexport function legacy (slug, opts, state, idx) {\n if (!emittedWarning) {\n const warningText = 'Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file'\n\n if (typeof process === 'object' && process && process.emitWarning) {\n process.emitWarning(warningText)\n } else {\n console.warn(warningText)\n }\n\n emittedWarning = true\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.permalinkClass ? [['class', opts.permalinkClass]] : []),\n ['href', opts.permalinkHref(slug, state)],\n ...Object.entries(opts.permalinkAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_block', '', 0), { content: opts.permalinkSymbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.permalinkSpace) {\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](...linkTokens)\n}\n\nexport function renderHref (slug) {\n return `#${slug}`\n}\n\nexport function renderAttrs (slug) {\n return {}\n}\n\nconst commonDefaults = {\n class: 'header-anchor',\n symbol: '#',\n renderHref,\n renderAttrs\n}\n\nexport function makePermalink (renderPermalinkImpl) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (let idx = 0; idx < tokens.length; idx++) {\n const token = tokens[idx]\n\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // Aggregate the next token children text.\n const title = tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, idx)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, idx)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, idx)\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n idx = tokens.indexOf(token)\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","selection","isLevelSelected","Array","isArray","level","isLevelSelectedNumber","length","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","indexOf","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"AAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,WAGJC,EAAsB,CAC1BC,mBAAmB,YAGLC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKZ,EAAgB,CACnB,IAAMa,EAAc,sIAEG,iBAAZC,SAAwBA,SAAWA,QAAQC,YACpDD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfb,GAAiB,EAGnB,IAAMkB,EAAa,CACjBC,OAAOC,OAAO,IAAIT,EAAMU,MAAM,YAAa,IAAK,GAAI,CAClDC,gBACMZ,EAAKa,eAAiB,CAAC,CAAC,QAASb,EAAKa,iBAAmB,IAC7D,CAAC,OAAQb,EAAKc,cAAcf,EAAME,KAC/BQ,OAAOM,QAAQf,EAAKgB,eAAejB,EAAME,OAGhDQ,OAAOC,OAAO,IAAIT,EAAMU,MAAM,aAAc,GAAI,GAAI,CAAEM,QAASjB,EAAKkB,gBAAiBC,KAAMvB,IAC3F,IAAIK,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKoB,gBACPnB,EAAMoB,OAAOnB,EAAM,GAAGoB,SAAS/B,EAASS,EAAKuB,kBAAkBd,OAAOC,OAAO,IAAIT,EAAMU,MAAM,OAAQ,GAAI,GAAI,CAAEM,QAAS,UAG1HhB,EAAMoB,OAAOnB,EAAM,GAAGoB,UAAS/B,EAASS,EAAKuB,0BAAqBf,YAGpDgB,EAAYzB,GAC1B,UAAWA,WAGG0B,EAAa1B,GAC3B,MAAO,GAGT,IAAM2B,EAAiB,CACrBC,MAAO,gBACPC,OAAQ,IACRJ,WAAAA,EACAC,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,SAASvC,EAAO,CAAEhD,KAAAA,EAAM8C,MAAAA,QD6HrCpC,OAAOC,OAAO6B,EAAgBP,SAAU,CACtCS,MAAO,kBACPL,OAAO,EACPC,UAAW,UC1Hb4B,EAAOmB,8IAEPnB,EAAOjC,SAAW,CAChByC,MAAO,EACPO,QAxFc,SAACO,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAyFvFX,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXrD,gBAAiBqD,EACjBvE,eAAgBuE,EAAqBpD,eACrCZ,eAAgBgE,EAAqBpD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C6D,EAAqBpD,SAASK,UAC/CvB,cAAesE,EAAqBpD,SAASR,WAC7CR,eAAgBoE,EAAqBpD,SAASP"} \ No newline at end of file diff --git a/dist/markdownItAnchor.mjs b/dist/markdownItAnchor.mjs index 2c5f2f1..db5c85c 100644 --- a/dist/markdownItAnchor.mjs +++ b/dist/markdownItAnchor.mjs @@ -1,2 +1,2 @@ -function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e}}(t.level),s=function(n){var t=0;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(n=function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(n,void 0):void 0}}(n)))return function(){return t>=n.length?{done:!0}:{done:!1,value:n[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=n[Symbol.iterator]()).next.bind(t)}(l);!(i=s()).done;){var u=i.value;if("heading_open"===u.type&&c(Number(u.tag.substr(1)))){var d=l.indexOf(u),f=l[d+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),p=u.attrGet("id");p=null==p?b(t.slugify(f),o,!1,t.uniqueSlugStartIndex):b(p,o,!0,t.uniqueSlugStartIndex),u.attrSet("id",p),!1!==t.tabIndex&&u.attrSet("tabindex",""+t.tabIndex),"function"==typeof t.permalink?t.permalink(p,t,n,d):(t.permalink||t.renderPermalink&&t.renderPermalink!==a)&&t.renderPermalink(p,t,n,d),t.callback&&t.callback(u,{slug:p,title:f})}}})}Object.assign(f.defaults,{style:"visually-hidden",space:!0,placement:"after"}),p.permalink={__proto__:null,legacy:a,renderHref:i,renderAttrs:o,makePermalink:c,linkInsideHeader:s,ariaHidden:u,headerLink:d,linkAfterHeader:f},p.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:a,permalinkClass:u.defaults.class,permalinkSpace:u.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===u.defaults.placement,permalinkHref:u.defaults.renderHref,permalinkAttrs:u.defaults.renderAttrs};export default p; +var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function r(r,a,i,l){var o;if(!e){var c="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(c):console.warn(c),e=!0}var s=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(a.permalinkClass?[["class",a.permalinkClass]]:[],[["href",a.permalinkHref(r,i)]],Object.entries(a.permalinkAttrs(r,i)))}),Object.assign(new i.Token("html_block","",0),{content:a.permalinkSymbol,meta:t}),new i.Token("link_close","a",-1)];a.permalinkSpace&&i.tokens[l+1].children[n[a.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[a.permalinkBefore]].apply(o,s)}function a(e){return"#"+e}function i(e){return{}}var l={class:"header-anchor",symbol:"#",renderHref:a,renderAttrs:i};function o(e){function n(t){return t=Object.assign({},n.defaults,t),function(n,r,a,i){return e(n,t,r,a,i)}}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}var c=o(function(e,r,a,i,l){var o,c=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(r.class?[["class",r.class]]:[],[["href",r.renderHref(e,i)]],r.ariaHidden?[["aria-hidden","true"]]:[],Object.entries(r.renderAttrs(e,i)))}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("link_close","a",-1)];r.space&&i.tokens[l+1].children[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[l+1].children)[n[r.placement]].apply(o,c)});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});var s=o(c.renderPermalinkImpl);s.defaults=Object.assign({},c.defaults,{ariaHidden:!0});var d=o(function(e,n,t,r,a){var i=[Object.assign(new r.Token("link_open","a",1),{attrs:[].concat(n.class?[["class",n.class]]:[],[["href",n.renderHref(e,r)]],Object.entries(n.renderAttrs(e,r)))})].concat(r.tokens[a+1].children,[new r.Token("link_close","a",-1)]);r.tokens[a+1]=Object.assign(new r.Token("inline","",0),{children:i})}),u=o(function(e,r,a,i,l){var o;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(r.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+r.style+"`");if(!["aria-describedby","aria-labelledby"].includes(r.style)&&!r.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+r.style+"` style");if("visually-hidden"===r.style&&!r.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var c=i.tokens[l+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=[],d=[];r.class&&d.push(["class",r.class]),d.push(["href",r.renderHref(e,i)]),d.push.apply(d,Object.entries(r.renderAttrs(e,i))),"visually-hidden"===r.style?(s.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",r.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:r.assistiveText(c)}),new i.Token("span_close","span",-1)),r.space&&s[n[r.placement]](Object.assign(new i.Token("text","",0),{content:" "})),s[n[r.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t}),new i.Token("span_close","span",-1))):s.push(Object.assign(new i.Token("html_inline","",0),{content:r.symbol,meta:t})),"aria-label"===r.style?d.push(["aria-label",r.assistiveText(c)]):["aria-describedby","aria-labelledby"].includes(r.style)&&d.push([r.style,e]);var u=[Object.assign(new i.Token("link_open","a",1),{attrs:d})].concat(s,[new i.Token("link_close","a",-1)]);(o=i.tokens).splice.apply(o,[l+3,0].concat(u))});function f(e,n,t,r){var a=e,i=r;if(t&&Object.prototype.hasOwnProperty.call(n,a))throw new Error("User defined `id` attribute `"+e+"` is not unique. Please fix it in your Markdown to continue.");for(;Object.prototype.hasOwnProperty.call(n,a);)a=e+"-"+i,i+=1;return n[a]=!0,a}function b(e,n){n=Object.assign({},b.defaults,n),e.core.ruler.push("anchor",function(e){for(var t,a={},i=e.tokens,l=Array.isArray(n.level)?(t=n.level,function(e){return t.includes(e)}):function(e){return function(n){return n>=e}}(n.level),o=0;o {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (const token of tokens) {\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n const index = tokens.indexOf(token)\n\n // Aggregate the next token children text.\n const title = tokens[index + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, index)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, index)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, index)\n }\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","selection","isLevelSelected","Array","isArray","level","isLevelSelectedNumber","Number","tag","substr","index","indexOf","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"0GAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,WAGJC,EAAsB,CAC1BC,mBAAmB,YAGLC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKZ,EAAgB,CACnB,IAAMa,EAAc,sIAEG,iBAAZC,SAAwBA,SAAWA,QAAQC,YACpDD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfb,GAAiB,EAGnB,IAAMkB,EAAa,CACjBC,OAAOC,OAAO,IAAIT,EAAMU,MAAM,YAAa,IAAK,GAAI,CAClDC,gBACMZ,EAAKa,eAAiB,CAAC,CAAC,QAASb,EAAKa,iBAAmB,IAC7D,CAAC,OAAQb,EAAKc,cAAcf,EA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,EAAElC,SAAS,IAEnClB,EAAOgD,EAAMiC,QAAQ,MAGvBjF,EADU,MAARA,EACKyD,EAAWxD,EAAKiF,QAAQpC,GAAQY,GAAO,EAAOzD,EAAKkF,sBAEnD1B,EAAWzD,EAAM0D,GAAO,EAAMzD,EAAKkF,sBAG5CnC,EAAMoC,QAAQ,KAAMpF,IAEE,IAAlBC,EAAKoF,UACPrC,EAAMoC,QAAQ,cAAenF,EAAKoF,UAGN,mBAAnBpF,EAAKqF,UACdrF,EAAKqF,UAAUtF,EAAMC,EAAMC,EAAO6E,IACzB9E,EAAKqF,WAELrF,EAAK+B,iBAAmB/B,EAAK+B,kBAAoBsD,IAD1DrF,EAAK+B,gBAAgBhC,EAAMC,EAAMC,EAAO6E,GAKtC9E,EAAKsF,UACPtF,EAAKsF,SAASvC,EAAO,CAAEhD,KAAAA,EAAM8C,MAAAA,QD+HrCpC,OAAOC,OAAO6B,EAAgBP,SAAU,CACtCS,MAAO,kBACPL,OAAO,EACPC,UAAW,UC5Hb4B,EAAOoB,8IAEPpB,EAAOjC,SAAW,CAChByC,MAAO,EACPQ,QAtFc,SAACM,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAuFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXtD,gBAAiBsD,EACjBxE,eAAgBwE,EAAqBrD,eACrCZ,eAAgBiE,EAAqBrD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C8D,EAAqBrD,SAASK,UAC/CvB,cAAeuE,EAAqBrD,SAASR,WAC7CR,eAAgBqE,EAAqBrD,SAASP"} \ No newline at end of file +{"version":3,"file":"markdownItAnchor.mjs","sources":["../permalink.js","../index.js"],"sourcesContent":["let emittedWarning = false\n\nconst position = {\n false: 'push',\n true: 'unshift',\n after: 'push',\n before: 'unshift'\n}\n\nconst permalinkSymbolMeta = {\n isPermalinkSymbol: true\n}\n\nexport function legacy (slug, opts, state, idx) {\n if (!emittedWarning) {\n const warningText = 'Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file'\n\n if (typeof process === 'object' && process && process.emitWarning) {\n process.emitWarning(warningText)\n } else {\n console.warn(warningText)\n }\n\n emittedWarning = true\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.permalinkClass ? [['class', opts.permalinkClass]] : []),\n ['href', opts.permalinkHref(slug, state)],\n ...Object.entries(opts.permalinkAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_block', '', 0), { content: opts.permalinkSymbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.permalinkSpace) {\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](...linkTokens)\n}\n\nexport function renderHref (slug) {\n return `#${slug}`\n}\n\nexport function renderAttrs (slug) {\n return {}\n}\n\nconst commonDefaults = {\n class: 'header-anchor',\n symbol: '#',\n renderHref,\n renderAttrs\n}\n\nexport function makePermalink (renderPermalinkImpl) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (let idx = 0; idx < tokens.length; idx++) {\n const token = tokens[idx]\n\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // Aggregate the next token children text.\n const title = tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, idx)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, idx)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, idx)\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n idx = tokens.indexOf(token)\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","selection","isLevelSelected","Array","isArray","level","isLevelSelectedNumber","length","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","indexOf","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"AAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,WAGJC,EAAsB,CAC1BC,mBAAmB,YAGLC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKZ,EAAgB,CACnB,IAAMa,EAAc,sIAEG,iBAAZC,SAAwBA,SAAWA,QAAQC,YACpDD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfb,GAAiB,EAGnB,IAAMkB,EAAa,CACjBC,OAAOC,OAAO,IAAIT,EAAMU,MAAM,YAAa,IAAK,GAAI,CAClDC,gBACMZ,EAAKa,eAAiB,CAAC,CAAC,QAASb,EAAKa,iBAAmB,IAC7D,CAAC,OAAQb,EAAKc,cAAcf,EAAME,KAC/BQ,OAA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MD,EAAMC,EAAElC,SAAS,IAEnClB,EAAOgD,EAAMgC,QAAQ,MAGvBhF,EADU,MAARA,EACKyD,EAAWxD,EAAKgF,QAAQnC,GAAQY,GAAO,EAAOzD,EAAKiF,sBAEnDzB,EAAWzD,EAAM0D,GAAO,EAAMzD,EAAKiF,sBAG5ClC,EAAMmC,QAAQ,KAAMnF,IAEE,IAAlBC,EAAKmF,UACPpC,EAAMmC,QAAQ,cAAelF,EAAKmF,UAGN,mBAAnBnF,EAAKoF,UACdpF,EAAKoF,UAAUrF,EAAMC,EAAMC,EAAOC,IACzBF,EAAKoF,WAELpF,EAAK+B,iBAAmB/B,EAAK+B,kBAAoBqD,IAD1DpF,EAAK+B,gBAAgBhC,EAAMC,EAAMC,EAAOC,GAO1CA,EAAMmB,EAAOgE,QAAQtC,GAEjB/C,EAAKsF,UACPtF,EAAKsF,SAASvC,EAAO,CAAEhD,KAAAA,EAAM8C,MAAAA,QD6HrCpC,OAAOC,OAAO6B,EAAgBP,SAAU,CACtCS,MAAO,kBACPL,OAAO,EACPC,UAAW,UC1Hb4B,EAAOmB,8IAEPnB,EAAOjC,SAAW,CAChByC,MAAO,EACPO,QAxFc,SAACO,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAyFvFX,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXrD,gBAAiBqD,EACjBvE,eAAgBuE,EAAqBpD,eACrCZ,eAAgBgE,EAAqBpD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C6D,EAAqBpD,SAASK,UAC/CvB,cAAesE,EAAqBpD,SAASR,WAC7CR,eAAgBoE,EAAqBpD,SAASP"} \ No newline at end of file diff --git a/dist/markdownItAnchor.modern.js b/dist/markdownItAnchor.modern.js index 2108482..d77bf0b 100644 --- a/dist/markdownItAnchor.modern.js +++ b/dist/markdownItAnchor.modern.js @@ -1,2 +1,2 @@ -let e=!1;const n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function a(a,r,i,l){if(!e){const n="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(n):console.warn(n),e=!0}const o=[Object.assign(new i.Token("link_open","a",1),{attrs:[...r.permalinkClass?[["class",r.permalinkClass]]:[],["href",r.permalinkHref(a,i)],...Object.entries(r.permalinkAttrs(a,i))]}),Object.assign(new i.Token("html_block","",0),{content:r.permalinkSymbol,meta:t}),new i.Token("link_close","a",-1)];r.permalinkSpace&&i.tokens[l+1].children[n[r.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),i.tokens[l+1].children[n[r.permalinkBefore]](...o)}function r(e){return"#"+e}function i(e){return{}}const l={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:i};function o(e){function n(t){return t=Object.assign({},n.defaults,t),(n,a,r,i)=>e(n,t,a,r,i)}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}const c=o((e,a,r,i,l)=>{const o=[Object.assign(new i.Token("link_open","a",1),{attrs:[...a.class?[["class",a.class]]:[],["href",a.renderHref(e,i)],...a.ariaHidden?[["aria-hidden","true"]]:[],...Object.entries(a.renderAttrs(e,i))]}),Object.assign(new i.Token("html_inline","",0),{content:a.symbol,meta:t}),new i.Token("link_close","a",-1)];a.space&&i.tokens[l+1].children[n[a.placement]](Object.assign(new i.Token("text","",0),{content:" "})),i.tokens[l+1].children[n[a.placement]](...o)});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});const s=o(c.renderPermalinkImpl);s.defaults=Object.assign({},c.defaults,{ariaHidden:!0});const d=o((e,n,t,a,r)=>{const i=[Object.assign(new a.Token("link_open","a",1),{attrs:[...n.class?[["class",n.class]]:[],["href",n.renderHref(e,a)],...Object.entries(n.renderAttrs(e,a))]}),...a.tokens[r+1].children,new a.Token("link_close","a",-1)];a.tokens[r+1]=Object.assign(new a.Token("inline","",0),{children:i})}),b=o((e,a,r,i,l)=>{if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(a.style))throw new Error(`\`permalink.linkAfterHeader\` called with unknown style option \`${a.style}\``);if(!["aria-describedby","aria-labelledby"].includes(a.style)&&!a.assistiveText)throw new Error(`\`permalink.linkAfterHeader\` called without the \`assistiveText\` option in \`${a.style}\` style`);if("visually-hidden"===a.style&&!a.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");const o=i.tokens[l+1].children.filter(e=>"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,""),c=[],s=[];a.class&&s.push(["class",a.class]),s.push(["href",a.renderHref(e,i)]),s.push(...Object.entries(a.renderAttrs(e,i))),"visually-hidden"===a.style?(c.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",a.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:a.assistiveText(o)}),new i.Token("span_close","span",-1)),a.space&&c[n[a.placement]](Object.assign(new i.Token("text","",0),{content:" "})),c[n[a.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:a.symbol,meta:t}),new i.Token("span_close","span",-1))):c.push(Object.assign(new i.Token("html_inline","",0),{content:a.symbol,meta:t})),"aria-label"===a.style?s.push(["aria-label",a.assistiveText(o)]):["aria-describedby","aria-labelledby"].includes(a.style)&&s.push([a.style,e]);const d=[Object.assign(new i.Token("link_open","a",1),{attrs:s}),...c,new i.Token("link_close","a",-1)];i.tokens.splice(l+3,0,...d)});function p(e,n,t,a){let r=e,i=a;if(t&&Object.prototype.hasOwnProperty.call(n,r))throw new Error(`User defined \`id\` attribute \`${e}\` is not unique. Please fix it in your Markdown to continue.`);for(;Object.prototype.hasOwnProperty.call(n,r);)r=`${e}-${i}`,i+=1;return n[r]=!0,r}function u(e,n){n=Object.assign({},u.defaults,n),e.core.ruler.push("anchor",e=>{const t={},r=e.tokens,i=Array.isArray(n.level)?(l=n.level,e=>l.includes(e)):(e=>n=>n>=e)(n.level);var l;for(const l of r){if("heading_open"!==l.type)continue;if(!i(Number(l.tag.substr(1))))continue;const o=r.indexOf(l),c=r[o+1].children.filter(e=>"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,"");let s=l.attrGet("id");s=null==s?p(n.slugify(c),t,!1,n.uniqueSlugStartIndex):p(s,t,!0,n.uniqueSlugStartIndex),l.attrSet("id",s),!1!==n.tabIndex&&l.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(s,n,e,o):(n.permalink||n.renderPermalink&&n.renderPermalink!==a)&&n.renderPermalink(s,n,e,o),n.callback&&n.callback(l,{slug:s,title:c})}})}Object.assign(b.defaults,{style:"visually-hidden",space:!0,placement:"after"}),u.permalink={__proto__:null,legacy:a,renderHref:r,renderAttrs:i,makePermalink:o,linkInsideHeader:c,ariaHidden:s,headerLink:d,linkAfterHeader:b},u.defaults={level:1,slugify:e=>encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-")),uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:a,permalinkClass:s.defaults.class,permalinkSpace:s.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===s.defaults.placement,permalinkHref:s.defaults.renderHref,permalinkAttrs:s.defaults.renderAttrs};export default u; +let e=!1;const n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function a(a,r,i,l){if(!e){const n="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(n):console.warn(n),e=!0}const o=[Object.assign(new i.Token("link_open","a",1),{attrs:[...r.permalinkClass?[["class",r.permalinkClass]]:[],["href",r.permalinkHref(a,i)],...Object.entries(r.permalinkAttrs(a,i))]}),Object.assign(new i.Token("html_block","",0),{content:r.permalinkSymbol,meta:t}),new i.Token("link_close","a",-1)];r.permalinkSpace&&i.tokens[l+1].children[n[r.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),i.tokens[l+1].children[n[r.permalinkBefore]](...o)}function r(e){return"#"+e}function i(e){return{}}const l={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:i};function o(e){function n(t){return t=Object.assign({},n.defaults,t),(n,a,r,i)=>e(n,t,a,r,i)}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}const c=o((e,a,r,i,l)=>{const o=[Object.assign(new i.Token("link_open","a",1),{attrs:[...a.class?[["class",a.class]]:[],["href",a.renderHref(e,i)],...a.ariaHidden?[["aria-hidden","true"]]:[],...Object.entries(a.renderAttrs(e,i))]}),Object.assign(new i.Token("html_inline","",0),{content:a.symbol,meta:t}),new i.Token("link_close","a",-1)];a.space&&i.tokens[l+1].children[n[a.placement]](Object.assign(new i.Token("text","",0),{content:" "})),i.tokens[l+1].children[n[a.placement]](...o)});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});const s=o(c.renderPermalinkImpl);s.defaults=Object.assign({},c.defaults,{ariaHidden:!0});const d=o((e,n,t,a,r)=>{const i=[Object.assign(new a.Token("link_open","a",1),{attrs:[...n.class?[["class",n.class]]:[],["href",n.renderHref(e,a)],...Object.entries(n.renderAttrs(e,a))]}),...a.tokens[r+1].children,new a.Token("link_close","a",-1)];a.tokens[r+1]=Object.assign(new a.Token("inline","",0),{children:i})}),b=o((e,a,r,i,l)=>{if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(a.style))throw new Error(`\`permalink.linkAfterHeader\` called with unknown style option \`${a.style}\``);if(!["aria-describedby","aria-labelledby"].includes(a.style)&&!a.assistiveText)throw new Error(`\`permalink.linkAfterHeader\` called without the \`assistiveText\` option in \`${a.style}\` style`);if("visually-hidden"===a.style&&!a.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");const o=i.tokens[l+1].children.filter(e=>"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,""),c=[],s=[];a.class&&s.push(["class",a.class]),s.push(["href",a.renderHref(e,i)]),s.push(...Object.entries(a.renderAttrs(e,i))),"visually-hidden"===a.style?(c.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",a.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:a.assistiveText(o)}),new i.Token("span_close","span",-1)),a.space&&c[n[a.placement]](Object.assign(new i.Token("text","",0),{content:" "})),c[n[a.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:a.symbol,meta:t}),new i.Token("span_close","span",-1))):c.push(Object.assign(new i.Token("html_inline","",0),{content:a.symbol,meta:t})),"aria-label"===a.style?s.push(["aria-label",a.assistiveText(o)]):["aria-describedby","aria-labelledby"].includes(a.style)&&s.push([a.style,e]);const d=[Object.assign(new i.Token("link_open","a",1),{attrs:s}),...c,new i.Token("link_close","a",-1)];i.tokens.splice(l+3,0,...d)});function p(e,n,t,a){let r=e,i=a;if(t&&Object.prototype.hasOwnProperty.call(n,r))throw new Error(`User defined \`id\` attribute \`${e}\` is not unique. Please fix it in your Markdown to continue.`);for(;Object.prototype.hasOwnProperty.call(n,r);)r=`${e}-${i}`,i+=1;return n[r]=!0,r}function u(e,n){n=Object.assign({},u.defaults,n),e.core.ruler.push("anchor",e=>{const t={},r=e.tokens,i=Array.isArray(n.level)?(l=n.level,e=>l.includes(e)):(e=>n=>n>=e)(n.level);var l;for(let l=0;l"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,"");let s=o.attrGet("id");s=null==s?p(n.slugify(c),t,!1,n.uniqueSlugStartIndex):p(s,t,!0,n.uniqueSlugStartIndex),o.attrSet("id",s),!1!==n.tabIndex&&o.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(s,n,e,l):(n.permalink||n.renderPermalink&&n.renderPermalink!==a)&&n.renderPermalink(s,n,e,l),l=r.indexOf(o),n.callback&&n.callback(o,{slug:s,title:c})}})}Object.assign(b.defaults,{style:"visually-hidden",space:!0,placement:"after"}),u.permalink={__proto__:null,legacy:a,renderHref:r,renderAttrs:i,makePermalink:o,linkInsideHeader:c,ariaHidden:s,headerLink:d,linkAfterHeader:b},u.defaults={level:1,slugify:e=>encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-")),uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:a,permalinkClass:s.defaults.class,permalinkSpace:s.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===s.defaults.placement,permalinkHref:s.defaults.renderHref,permalinkAttrs:s.defaults.renderAttrs};export default u; //# sourceMappingURL=markdownItAnchor.modern.js.map diff --git a/dist/markdownItAnchor.modern.js.map b/dist/markdownItAnchor.modern.js.map index e6d1a59..5743569 100644 --- a/dist/markdownItAnchor.modern.js.map +++ b/dist/markdownItAnchor.modern.js.map @@ -1 +1 @@ -{"version":3,"file":"markdownItAnchor.modern.js","sources":["../permalink.js","../index.js"],"sourcesContent":["let emittedWarning = false\n\nconst position = {\n false: 'push',\n true: 'unshift',\n after: 'push',\n before: 'unshift'\n}\n\nconst permalinkSymbolMeta = {\n isPermalinkSymbol: true\n}\n\nexport function legacy (slug, opts, state, idx) {\n if (!emittedWarning) {\n const warningText = 'Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file'\n\n if (typeof process === 'object' && process && process.emitWarning) {\n process.emitWarning(warningText)\n } else {\n console.warn(warningText)\n }\n\n emittedWarning = true\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.permalinkClass ? [['class', opts.permalinkClass]] : []),\n ['href', opts.permalinkHref(slug, state)],\n ...Object.entries(opts.permalinkAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_block', '', 0), { content: opts.permalinkSymbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.permalinkSpace) {\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](...linkTokens)\n}\n\nexport function renderHref (slug) {\n return `#${slug}`\n}\n\nexport function renderAttrs (slug) {\n return {}\n}\n\nconst commonDefaults = {\n class: 'header-anchor',\n symbol: '#',\n renderHref,\n renderAttrs\n}\n\nexport function makePermalink (renderPermalinkImpl) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (const token of tokens) {\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n const index = tokens.indexOf(token)\n\n // Aggregate the next token children text.\n const title = tokens[index + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, index)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, index)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, index)\n }\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","isLevelSelected","Array","isArray","level","selection","isLevelSelectedNumber","Number","tag","substr","index","indexOf","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"AAAA,IAAIA,GAAiB,EAErB,MAAMC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,WAGJC,EAAsB,CAC1BC,mBAAmB,YAGLC,EAAQC,EAAMC,EAAMC,EAAOC,GACzC,IAAKZ,EAAgB,CACnB,MAAMa,EAAc,sIAEG,iBAAZC,SAAwBA,SAAWA,QAAQC,YACpDD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfb,GAAiB,EAGnB,MAAMkB,EAAa,CACjBC,OAAOC,OAAO,IAAIT,EAAMU,MAAM,YAAa,IAAK,GAAI,CAClDC,MAAO,IACDZ,EAAKa,eAAiB,CAAC,CAAC,QAASb,EAAKa,iBAAmB,GAC7D,CAAC,OAAQb,EAAKc,cAAcf,EAAME,OAC/BQ,OAAOM,QAAQf,EAAKgB,eAAejB,EAAME,OAGhDQ,OAAOC,OAAO,IAAIT,EAAMU,MAAM,aAAc,GAAI,GAAI,CAAEM,QAASjB,EAAKkB,gBAAiBC,KAAMvB,IAC3F,IAAIK,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKoB,gBACPnB,EAAMoB,OAAOnB,EAAM,GAAGoB,SAAS/B,EAASS,EAAKuB,kBAAkBd,OAAOC,OAAO,IAAIT,EAAMU,MAAM,OAAQ,GAAI,GAAI,CAAEM,QAAS,OAG1HhB,EAAMoB,OAAOnB,EAAM,GAAGoB,SAAS/B,EAASS,EAAKuB,qBAAqBf,YAGpDgB,EAAYzB,GAC1B,MAAQ,IAAGA,WAGG0B,EAAa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O6E,IACzB9E,EAAKqF,WAELrF,EAAK+B,iBAAmB/B,EAAK+B,kBAAoBsD,IAD1DrF,EAAK+B,gBAAgBhC,EAAMC,EAAMC,EAAO6E,GAKtC9E,EAAKsF,UACPtF,EAAKsF,SAASvC,EAAO,CAAEhD,KAAAA,EAAM8C,MAAAA,OD+HrCpC,OAAOC,OAAO6B,EAAgBP,SAAU,CACtCS,MAAO,kBACPL,OAAO,EACPC,UAAW,UC5Hb4B,EAAOoB,8IAEPpB,EAAOjC,SAAW,CAChBwC,MAAO,EACPS,QAtFeM,GAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,MAuFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXtD,gBAAiBsD,EACjBxE,eAAgBwE,EAAqBrD,SAASL,MAC9CP,eAAgBiE,EAAqBrD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C8D,EAAqBrD,SAASK,UAC/CvB,cAAeuE,EAAqBrD,SAASR,WAC7CR,eAAgBqE,EAAqBrD,SAASP"} \ No newline at end of file +{"version":3,"file":"markdownItAnchor.modern.js","sources":["../permalink.js","../index.js"],"sourcesContent":["let emittedWarning = false\n\nconst position = {\n false: 'push',\n true: 'unshift',\n after: 'push',\n before: 'unshift'\n}\n\nconst permalinkSymbolMeta = {\n isPermalinkSymbol: true\n}\n\nexport function legacy (slug, opts, state, idx) {\n if (!emittedWarning) {\n const warningText = 'Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file'\n\n if (typeof process === 'object' && process && process.emitWarning) {\n process.emitWarning(warningText)\n } else {\n console.warn(warningText)\n }\n\n emittedWarning = true\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.permalinkClass ? [['class', opts.permalinkClass]] : []),\n ['href', opts.permalinkHref(slug, state)],\n ...Object.entries(opts.permalinkAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_block', '', 0), { content: opts.permalinkSymbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.permalinkSpace) {\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](...linkTokens)\n}\n\nexport function renderHref (slug) {\n return `#${slug}`\n}\n\nexport function renderAttrs (slug) {\n return {}\n}\n\nconst commonDefaults = {\n class: 'header-anchor',\n symbol: '#',\n renderHref,\n renderAttrs\n}\n\nexport function makePermalink (renderPermalinkImpl) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (let idx = 0; idx < tokens.length; idx++) {\n const token = tokens[idx]\n\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // Aggregate the next token children text.\n const title = tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, idx)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, idx)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, idx)\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n idx = tokens.indexOf(token)\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","isLevelSelected","Array","isArray","level","selection","isLevelSelectedNumber","length","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","indexOf","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"AAAA,IAAIA,GAAiB,EAErB,MAAMC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,WAGJC,EAAsB,CAC1BC,mBAAmB,YAGLC,EAAQC,EAAMC,EAAMC,EAAOC,GACzC,IAAKZ,EAAgB,CACnB,MAAMa,EAAc,sIAEG,iBAAZC,SAAwBA,SAAWA,QAAQC,YACpDD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfb,GAAiB,EAGnB,MAAMkB,EAAa,CACjBC,OAAOC,OAAO,IAAIT,EAAMU,MAAM,YAAa,IAAK,GAAI,CAClDC,MAAO,IACDZ,EAAKa,eAAiB,CAAC,CAAC,QAASb,EAAKa,iBAAmB,GAC7D,CAAC,OAAQb,EAAKc,cAAcf,EAAME,OAC/BQ,OAAOM,QAAQf,EAAKgB,eAAejB,EAAME,OAGhDQ,OAAOC,OAAO,IAAIT,EAAMU,MAAM,aAAc,GAAI,GAAI,CAAEM,QAASjB,EAAKkB,gBAAiBC,KAAMvB,IAC3F,IAAIK,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKoB,gBACPnB,EAAMoB,OAAOnB,EAAM,GAAGoB,SAAS/B,EAASS,EAAKuB,kBAAkBd,OAAOC,OAAO,IAAIT,EAAMU,MAAM,OAAQ,GAAI,GAAI,CAAEM,QAAS,O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QAAQ,KAAMnF,IAEE,IAAlBC,EAAKmF,UACPpC,EAAMmC,QAAQ,WAAa,GAAElF,EAAKmF,UAGN,mBAAnBnF,EAAKoF,UACdpF,EAAKoF,UAAUrF,EAAMC,EAAMC,EAAOC,IACzBF,EAAKoF,WAELpF,EAAK+B,iBAAmB/B,EAAK+B,kBAAoBqD,IAD1DpF,EAAK+B,gBAAgBhC,EAAMC,EAAMC,EAAOC,GAO1CA,EAAMmB,EAAOgE,QAAQtC,GAEjB/C,EAAKsF,UACPtF,EAAKsF,SAASvC,EAAO,CAAEhD,KAAAA,EAAM8C,MAAAA,OD6HrCpC,OAAOC,OAAO6B,EAAgBP,SAAU,CACtCS,MAAO,kBACPL,OAAO,EACPC,UAAW,UC1Hb4B,EAAOmB,8IAEPnB,EAAOjC,SAAW,CAChBwC,MAAO,EACPQ,QAxFeO,GAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,MAyFvFX,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXrD,gBAAiBqD,EACjBvE,eAAgBuE,EAAqBpD,SAASL,MAC9CP,eAAgBgE,EAAqBpD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C6D,EAAqBpD,SAASK,UAC/CvB,cAAesE,EAAqBpD,SAASR,WAC7CR,eAAgBoE,EAAqBpD,SAASP"} \ No newline at end of file diff --git a/dist/markdownItAnchor.umd.js b/dist/markdownItAnchor.umd.js index c28d9dd..a42283b 100644 --- a/dist/markdownItAnchor.umd.js +++ b/dist/markdownItAnchor.umd.js @@ -1,2 +1,2 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).markdownItAnchor=n()}(this,function(){function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t=e}}(t.level),s=function(n){var t=0;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(n=function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(n,void 0):void 0}}(n)))return function(){return t>=n.length?{done:!0}:{done:!1,value:n[t++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=n[Symbol.iterator]()).next.bind(t)}(l);!(a=s()).done;){var u=a.value;if("heading_open"===u.type&&c(Number(u.tag.substr(1)))){var d=l.indexOf(u),f=l[d+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),p=u.attrGet("id");p=null==p?b(t.slugify(f),o,!1,t.uniqueSlugStartIndex):b(p,o,!0,t.uniqueSlugStartIndex),u.attrSet("id",p),!1!==t.tabIndex&&u.attrSet("tabindex",""+t.tabIndex),"function"==typeof t.permalink?t.permalink(p,t,n,d):(t.permalink||t.renderPermalink&&t.renderPermalink!==i)&&t.renderPermalink(p,t,n,d),t.callback&&t.callback(u,{slug:p,title:f})}}})}return Object.assign(f.defaults,{style:"visually-hidden",space:!0,placement:"after"}),p.permalink={__proto__:null,legacy:i,renderHref:a,renderAttrs:o,makePermalink:c,linkInsideHeader:s,ariaHidden:u,headerLink:d,linkAfterHeader:f},p.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:i,permalinkClass:u.defaults.class,permalinkSpace:u.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===u.defaults.placement,permalinkHref:u.defaults.renderHref,permalinkAttrs:u.defaults.renderAttrs},p}); +!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).markdownItAnchor=n()}(this,function(){var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"},t={isPermalinkSymbol:!0};function r(r,i,a,l){var o;if(!e){var c="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";"object"==typeof process&&process&&process.emitWarning?process.emitWarning(c):console.warn(c),e=!0}var s=[Object.assign(new a.Token("link_open","a",1),{attrs:[].concat(i.permalinkClass?[["class",i.permalinkClass]]:[],[["href",i.permalinkHref(r,a)]],Object.entries(i.permalinkAttrs(r,a)))}),Object.assign(new a.Token("html_block","",0),{content:i.permalinkSymbol,meta:t}),new a.Token("link_close","a",-1)];i.permalinkSpace&&a.tokens[l+1].children[n[i.permalinkBefore]](Object.assign(new a.Token("text","",0),{content:" "})),(o=a.tokens[l+1].children)[n[i.permalinkBefore]].apply(o,s)}function i(e){return"#"+e}function a(e){return{}}var l={class:"header-anchor",symbol:"#",renderHref:i,renderAttrs:a};function o(e){function n(t){return t=Object.assign({},n.defaults,t),function(n,r,i,a){return e(n,t,r,i,a)}}return n.defaults=Object.assign({},l),n.renderPermalinkImpl=e,n}var c=o(function(e,r,i,a,l){var o,c=[Object.assign(new a.Token("link_open","a",1),{attrs:[].concat(r.class?[["class",r.class]]:[],[["href",r.renderHref(e,a)]],r.ariaHidden?[["aria-hidden","true"]]:[],Object.entries(r.renderAttrs(e,a)))}),Object.assign(new a.Token("html_inline","",0),{content:r.symbol,meta:t}),new a.Token("link_close","a",-1)];r.space&&a.tokens[l+1].children[n[r.placement]](Object.assign(new a.Token("text","",0),{content:" "})),(o=a.tokens[l+1].children)[n[r.placement]].apply(o,c)});Object.assign(c.defaults,{space:!0,placement:"after",ariaHidden:!1});var s=o(c.renderPermalinkImpl);s.defaults=Object.assign({},c.defaults,{ariaHidden:!0});var d=o(function(e,n,t,r,i){var a=[Object.assign(new r.Token("link_open","a",1),{attrs:[].concat(n.class?[["class",n.class]]:[],[["href",n.renderHref(e,r)]],Object.entries(n.renderAttrs(e,r)))})].concat(r.tokens[i+1].children,[new r.Token("link_close","a",-1)]);r.tokens[i+1]=Object.assign(new r.Token("inline","",0),{children:a})}),u=o(function(e,r,i,a,l){var o;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(r.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+r.style+"`");if(!["aria-describedby","aria-labelledby"].includes(r.style)&&!r.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+r.style+"` style");if("visually-hidden"===r.style&&!r.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var c=a.tokens[l+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=[],d=[];r.class&&d.push(["class",r.class]),d.push(["href",r.renderHref(e,a)]),d.push.apply(d,Object.entries(r.renderAttrs(e,a))),"visually-hidden"===r.style?(s.push(Object.assign(new a.Token("span_open","span",1),{attrs:[["class",r.visuallyHiddenClass]]}),Object.assign(new a.Token("text","",0),{content:r.assistiveText(c)}),new a.Token("span_close","span",-1)),r.space&&s[n[r.placement]](Object.assign(new a.Token("text","",0),{content:" "})),s[n[r.placement]](Object.assign(new a.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new a.Token("html_inline","",0),{content:r.symbol,meta:t}),new a.Token("span_close","span",-1))):s.push(Object.assign(new a.Token("html_inline","",0),{content:r.symbol,meta:t})),"aria-label"===r.style?d.push(["aria-label",r.assistiveText(c)]):["aria-describedby","aria-labelledby"].includes(r.style)&&d.push([r.style,e]);var u=[Object.assign(new a.Token("link_open","a",1),{attrs:d})].concat(s,[new a.Token("link_close","a",-1)]);(o=a.tokens).splice.apply(o,[l+3,0].concat(u))});function f(e,n,t,r){var i=e,a=r;if(t&&Object.prototype.hasOwnProperty.call(n,i))throw new Error("User defined `id` attribute `"+e+"` is not unique. Please fix it in your Markdown to continue.");for(;Object.prototype.hasOwnProperty.call(n,i);)i=e+"-"+a,a+=1;return n[i]=!0,i}function b(e,n){n=Object.assign({},b.defaults,n),e.core.ruler.push("anchor",function(e){for(var t,i={},a=e.tokens,l=Array.isArray(n.level)?(t=n.level,function(e){return t.includes(e)}):function(e){return function(n){return n>=e}}(n.level),o=0;o {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (const token of tokens) {\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n const index = tokens.indexOf(token)\n\n // Aggregate the next token children text.\n const title = tokens[index + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, index)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, index)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, index)\n }\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","selection","isLevelSelected","Array","isArray","level","isLevelSelectedNumber","Number","tag","substr","index","indexOf","attrGet","slugify","uniqueSlugStartIndex","attr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AMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAuFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXtD,gBAAiBsD,EACjBxE,eAAgBwE,EAAqBrD,eACrCZ,eAAgBiE,EAAqBrD,SAASI,MAC9ClB,gBAAiB,IACjBK,gBAA6D,WAA5C8D,EAAqBrD,SAASK,UAC/CvB,cAAeuE,EAAqBrD,SAASR,WAC7CR,eAAgBqE,EAAqBrD,SAASP"} \ No newline at end of file +{"version":3,"file":"markdownItAnchor.umd.js","sources":["../permalink.js","../index.js"],"sourcesContent":["let emittedWarning = false\n\nconst position = {\n false: 'push',\n true: 'unshift',\n after: 'push',\n before: 'unshift'\n}\n\nconst permalinkSymbolMeta = {\n isPermalinkSymbol: true\n}\n\nexport function legacy (slug, opts, state, idx) {\n if (!emittedWarning) {\n const warningText = 'Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file'\n\n if (typeof process === 'object' && process && process.emitWarning) {\n process.emitWarning(warningText)\n } else {\n console.warn(warningText)\n }\n\n emittedWarning = true\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.permalinkClass ? [['class', opts.permalinkClass]] : []),\n ['href', opts.permalinkHref(slug, state)],\n ...Object.entries(opts.permalinkAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_block', '', 0), { content: opts.permalinkSymbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.permalinkSpace) {\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.permalinkBefore]](...linkTokens)\n}\n\nexport function renderHref (slug) {\n return `#${slug}`\n}\n\nexport function renderAttrs (slug) {\n return {}\n}\n\nconst commonDefaults = {\n class: 'header-anchor',\n symbol: '#',\n renderHref,\n renderAttrs\n}\n\nexport function makePermalink (renderPermalinkImpl) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return renderPermalinkImpl(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n renderPermalink.renderPermalinkImpl = renderPermalinkImpl\n\n return renderPermalink\n}\n\nexport const linkInsideHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...(opts.ariaHidden ? [['aria-hidden', 'true']] : []),\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol, meta: permalinkSymbolMeta }),\n new state.Token('link_close', 'a', -1)\n ]\n\n if (opts.space) {\n state.tokens[idx + 1].children[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n state.tokens[idx + 1].children[position[opts.placement]](...linkTokens)\n})\n\nObject.assign(linkInsideHeader.defaults, {\n space: true,\n placement: 'after',\n ariaHidden: false\n})\n\nexport const ariaHidden = makePermalink(linkInsideHeader.renderPermalinkImpl)\n\nariaHidden.defaults = Object.assign({}, linkInsideHeader.defaults, {\n ariaHidden: true\n})\n\nexport const headerLink = makePermalink((slug, opts, anchorOpts, state, idx) => {\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: [\n ...(opts.class ? [['class', opts.class]] : []),\n ['href', opts.renderHref(slug, state)],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n ...state.tokens[idx + 1].children,\n new state.Token('link_close', 'a', -1)\n ]\n\n state.tokens[idx + 1] = Object.assign(new state.Token('inline', '', 0), {\n children: linkTokens\n })\n})\n\nexport const linkAfterHeader = makePermalink((slug, opts, anchorOpts, state, idx) => {\n if (!['visually-hidden', 'aria-label', 'aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called with unknown style option \\`${opts.style}\\``)\n }\n\n if (!['aria-describedby', 'aria-labelledby'].includes(opts.style) && !opts.assistiveText) {\n throw new Error(`\\`permalink.linkAfterHeader\\` called without the \\`assistiveText\\` option in \\`${opts.style}\\` style`)\n }\n\n if (opts.style === 'visually-hidden' && !opts.visuallyHiddenClass) {\n throw new Error('`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style')\n }\n\n const title = state.tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n const subLinkTokens = []\n const linkAttrs = []\n\n if (opts.class) {\n linkAttrs.push(['class', opts.class])\n }\n\n linkAttrs.push(['href', opts.renderHref(slug, state)])\n linkAttrs.push(...Object.entries(opts.renderAttrs(slug, state)))\n\n if (opts.style === 'visually-hidden') {\n subLinkTokens.push(\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['class', opts.visuallyHiddenClass]],\n }),\n Object.assign(new state.Token('text', '', 0), {\n content: opts.assistiveText(title)\n }),\n new state.Token('span_close', 'span', -1)\n )\n\n if (opts.space) {\n subLinkTokens[position[opts.placement]](Object.assign(new state.Token('text', '', 0), { content: ' ' }))\n }\n\n subLinkTokens[position[opts.placement]](\n Object.assign(new state.Token('span_open', 'span', 1), {\n attrs: [['aria-hidden', 'true']],\n }),\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('html_inline', '', 0), {\n content: opts.symbol,\n meta: permalinkSymbolMeta\n })\n )\n }\n\n if (opts.style === 'aria-label') {\n linkAttrs.push(['aria-label', opts.assistiveText(title)])\n } else if (['aria-describedby', 'aria-labelledby'].includes(opts.style)) {\n linkAttrs.push([opts.style, slug])\n }\n\n const linkTokens = [\n Object.assign(new state.Token('link_open', 'a', 1), {\n attrs: linkAttrs\n }),\n ...subLinkTokens,\n new state.Token('link_close', 'a', -1),\n ]\n\n state.tokens.splice(idx + 3, 0, ...linkTokens)\n})\n\nObject.assign(linkAfterHeader.defaults, {\n style: 'visually-hidden',\n space: true,\n placement: 'after'\n})\n","import * as permalink from './permalink'\n\nconst slugify = (s) => encodeURIComponent(String(s).trim().toLowerCase().replace(/\\s+/g, '-'))\n\nfunction uniqueSlug (slug, slugs, failOnNonUnique, startIndex) {\n let uniq = slug\n let i = startIndex\n\n if (failOnNonUnique && Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n throw new Error(`User defined \\`id\\` attribute \\`${slug}\\` is not unique. Please fix it in your Markdown to continue.`)\n } else {\n while (Object.prototype.hasOwnProperty.call(slugs, uniq)) {\n uniq = `${slug}-${i}`\n i += 1\n }\n }\n\n slugs[uniq] = true\n\n return uniq\n}\n\nconst isLevelSelectedNumber = selection => level => level >= selection\nconst isLevelSelectedArray = selection => level => selection.includes(level)\n\nfunction anchor (md, opts) {\n opts = Object.assign({}, anchor.defaults, opts)\n\n md.core.ruler.push('anchor', state => {\n const slugs = {}\n const tokens = state.tokens\n\n const isLevelSelected = Array.isArray(opts.level)\n ? isLevelSelectedArray(opts.level)\n : isLevelSelectedNumber(opts.level)\n\n for (let idx = 0; idx < tokens.length; idx++) {\n const token = tokens[idx]\n\n if (token.type !== 'heading_open') {\n continue\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n continue\n }\n\n // Aggregate the next token children text.\n const title = tokens[idx + 1]\n .children\n .filter(token => token.type === 'text' || token.type === 'code_inline')\n .reduce((acc, t) => acc + t.content, '')\n\n let slug = token.attrGet('id')\n\n if (slug == null) {\n slug = uniqueSlug(opts.slugify(title), slugs, false, opts.uniqueSlugStartIndex)\n } else {\n slug = uniqueSlug(slug, slugs, true, opts.uniqueSlugStartIndex)\n }\n\n token.attrSet('id', slug)\n\n if (opts.tabIndex !== false) {\n token.attrSet('tabindex', `${opts.tabIndex}`)\n }\n\n if (typeof opts.permalink === 'function') {\n opts.permalink(slug, opts, state, idx)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, idx)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, idx)\n }\n\n // A permalink renderer could modify the `tokens` array so\n // make sure to get the up-to-date index on each iteration.\n idx = tokens.indexOf(token)\n\n if (opts.callback) {\n opts.callback(token, { slug, title })\n }\n }\n })\n}\n\nanchor.permalink = permalink\n\nanchor.defaults = {\n level: 1,\n slugify,\n uniqueSlugStartIndex: 1,\n tabIndex: '-1',\n\n // Legacy options.\n permalink: false,\n renderPermalink: permalink.legacy,\n permalinkClass: permalink.ariaHidden.defaults.class,\n permalinkSpace: permalink.ariaHidden.defaults.space,\n permalinkSymbol: '¶',\n permalinkBefore: permalink.ariaHidden.defaults.placement === 'before',\n permalinkHref: permalink.ariaHidden.defaults.renderHref,\n permalinkAttrs: permalink.ariaHidden.defaults.renderAttrs\n}\n\nexport default anchor\n"],"names":["emittedWarning","position","false","true","after","before","permalinkSymbolMeta","isPermalinkSymbol","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","meta","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","renderPermalinkImpl","renderPermalink","defaults","anchorOpts","linkInsideHeader","ariaHidden","space","placement","headerLink","linkAfterHeader","includes","style","Error","assistiveText","visuallyHiddenClass","title","filter","token","type","reduce","acc","t","subLinkTokens","linkAttrs","push","splice","uniqueSlug","slugs","failOnNonUnique","startIndex","uniq","i","prototype","hasOwnProperty","call","anchor","md","core","ruler","selection","isLevelSelected","Array","isArray","level","isLevelSelectedNumber","length","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","indexOf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