From 9b4950d03022d30d9532075c72c350c5218695f4 Mon Sep 17 00:00:00 2001 From: Val Date: Sat, 19 Jun 2021 10:16:58 -0400 Subject: [PATCH] Build --- dist/markdownItAnchor.js | 2 +- dist/markdownItAnchor.js.map | 2 +- dist/markdownItAnchor.mjs | 2 +- dist/markdownItAnchor.mjs.map | 2 +- dist/markdownItAnchor.modern.js | 2 +- dist/markdownItAnchor.modern.js.map | 2 +- dist/markdownItAnchor.umd.js | 2 +- dist/markdownItAnchor.umd.js.map | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/markdownItAnchor.js b/dist/markdownItAnchor.js index 721abea..7394976 100644 --- a/dist/markdownItAnchor.js +++ b/dist/markdownItAnchor.js @@ -1,2 +1,2 @@ -var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"};function t(t,r,a,i){var l;if(!e){var o="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";process&&process.emitWarning?process.emitWarning(o):console.warn(o),e=!0}var c=[Object.assign(new a.Token("link_open","a",1),{attrs:[].concat(r.permalinkClass?[["class",r.permalinkClass]]:[],[["href",r.permalinkHref(t,a)]],Object.entries(r.permalinkAttrs(t,a)))}),Object.assign(new a.Token("html_block","",0),{content:r.permalinkSymbol}),new a.Token("link_close","a",-1)];r.permalinkSpace&&a.tokens[i+1].children[n[r.permalinkBefore]](Object.assign(new a.Token("text","",0),{content:" "})),(l=a.tokens[i+1].children)[n[r.permalinkBefore]].apply(l,c)}function r(e){return"#"+e}function a(e){return{}}var i={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:a};function l(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({},i),n}var o=l(function(e,t,r,a,i){var l,o=[Object.assign(new a.Token("link_open","a",1),{attrs:[].concat(t.class?[["class",t.class]]:[],[["href",t.renderHref(e,a)],["aria-hidden","true"]],Object.entries(t.renderAttrs(e,a)))}),Object.assign(new a.Token("text","",0),{content:t.symbol}),new a.Token("link_close","a",-1)];t.space&&a.tokens[i+1].children[n[t.placement]](Object.assign(new a.Token("text","",0),{content:" "})),(l=a.tokens[i+1].children)[n[t.placement]].apply(l,o)});Object.assign(o.defaults,{space:!0,placement:"after"});var c=l(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})}),s=l(function(e,t,r,a,i){var l;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(t.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+t.style+"`");if(!["aria-describedby","aria-labelledby"].includes(t.style)&&!t.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+t.style+"` style");if("visually-hidden"===t.style&&!t.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var o=a.tokens[i+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),c=[],s=[];t.class&&s.push(["class",t.class]),s.push(["href",t.renderHref(e,a)]),s.push.apply(s,Object.entries(t.renderAttrs(e,a))),"visually-hidden"===t.style?(c.push(Object.assign(new a.Token("span_open","span",1),{attrs:[["class",t.visuallyHiddenClass]]}),Object.assign(new a.Token("text","",0),{content:t.assistiveText(o)}),new a.Token("span_close","span",-1)),t.space&&c[n[t.placement]](Object.assign(new a.Token("text","",0),{content:" "})),c[n[t.placement]](Object.assign(new a.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new a.Token("text","",0),{content:t.symbol}),new a.Token("span_close","span",-1))):c.push(Object.assign(new a.Token("text","",0),{content:t.symbol})),"aria-label"===t.style?s.push(["aria-label",t.assistiveText(o)]):["aria-describedby","aria-labelledby"].includes(t.style)&&s.push([t.style,e]);var u=[Object.assign(new a.Token("link_open","a",1),{attrs:s})].concat(c,[new a.Token("link_close","a",-1)]);(l=a.tokens).splice.apply(l,[i+3,0].concat(u))});function u(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 d(e,n){n=Object.assign({},d.defaults,n),e.core.ruler.push("anchor",function(e){var r,a={},i=e.tokens,l=Array.isArray(n.level)?(r=n.level,function(e){return r.includes(e)}):function(e){return function(n){return n>=e}}(n.level);i.forEach(function(r,o){if("heading_open"===r.type&&l(Number(r.tag.substr(1)))){var c=i[o+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=r.attrGet("id");s=null==s?u(n.slugify(c),a,!1,n.uniqueSlugStartIndex):u(s,a,!0,n.uniqueSlugStartIndex),r.attrSet("id",s),!1!==n.tabIndex&&r.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(s,n,e,o):(n.permalink||n.renderPermalink&&n.renderPermalink!==t)&&n.renderPermalink(s,n,e,o),n.callback&&n.callback(r,{slug:s,title:c})}})})}Object.assign(s.defaults,{style:"visually-hidden",space:!0,placement:"after"}),d.permalink={__proto__:null,legacy:t,renderHref:r,renderAttrs:a,makePermalink:l,ariaHidden:o,headerLink:c,linkAfterHeader:s},d.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:t,permalinkClass:o.defaults.class,permalinkSpace:o.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===o.defaults.placement,permalinkHref:o.defaults.renderHref,permalinkAttrs:o.defaults.renderAttrs},module.exports=d; +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)}(o);!(i=s()).done;){var u=i.value;if("heading_open"===u.type&&c(Number(u.tag.substr(1)))){var f=o.indexOf(u),b=o[f+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?d(t.slugify(b),l,!1,t.uniqueSlugStartIndex):d(p,l,!0,t.uniqueSlugStartIndex),u.attrSet("id",p),!1!==t.tabIndex&&u.attrSet("tabindex",""+t.tabIndex),"function"==typeof t.permalink?t.permalink(p,t,n,f):(t.permalink||t.renderPermalink&&t.renderPermalink!==r)&&t.renderPermalink(p,t,n,f),t.callback&&t.callback(u,{slug:p,title:b})}}})}Object.assign(u.defaults,{style:"visually-hidden",space:!0,placement:"after"}),f.permalink={__proto__:null,legacy:r,renderHref:a,renderAttrs:i,makePermalink:o,ariaHidden:c,headerLink:s,linkAfterHeader:u},f.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:r,permalinkClass:c.defaults.class,permalinkSpace:c.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===c.defaults.placement,permalinkHref:c.defaults.renderHref,permalinkAttrs:c.defaults.renderAttrs},module.exports=f; //# sourceMappingURL=markdownItAnchor.js.map diff --git a/dist/markdownItAnchor.js.map b/dist/markdownItAnchor.js.map index efe1d35..f3743b2 100644 --- a/dist/markdownItAnchor.js.map +++ b/dist/markdownItAnchor.js.map @@ -1 +1 @@ -{"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\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 (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 }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('text', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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('text', '', 0), {\n content: opts.symbol,\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('text', '', 0), {\n content: opts.symbol,\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 tokens.forEach((token, i) => {\n if (token.type !== 'heading_open') {\n return\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n return\n }\n\n // Aggregate the next token children text.\n const title = tokens[i + 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, i)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, i)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, i)\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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","forEach","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"AAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,oBAGMC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKV,EAAgB,CACnB,IAAMW,EAAc,sIAEhBC,SAAWA,QAAQC,YACrBD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfX,GAAiB,EAGnB,IAAMgB,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,kBACpE,IAAIjB,EAA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AAoBoD,IAD1DlF,EAAK8B,gBAAgB/B,EAAMC,EAAMC,EAAO0D,GAKtC3D,EAAKmF,UACPnF,EAAKmF,SAAStC,EAAO,CAAE9C,KAAAA,EAAM4C,MAAAA,SDqHrClC,OAAOC,OAAO2B,EAAgBN,SAAU,CACtCQ,MAAO,kBACPL,OAAO,EACPC,UAAW,UClHb4B,EAAOmB,2HAEPnB,EAAOhC,SAAW,CAChBwC,MAAO,EACPO,QAlFc,SAACM,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAmFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXpD,gBAAiBoD,EACjBrE,eAAgBqE,EAAqBnD,eACrCZ,eAAgB+D,EAAqBnD,SAASG,MAC9ChB,gBAAiB,IACjBI,gBAA6D,WAA5C4D,EAAqBnD,SAASI,UAC/CrB,cAAeoE,EAAqBnD,SAASR,WAC7CP,eAAgBkE,EAAqBnD,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\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 (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_inline', '', 0), { content: opts.permalinkSymbol }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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 }),\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 })\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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,OAC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 100644 --- a/dist/markdownItAnchor.mjs +++ b/dist/markdownItAnchor.mjs @@ -1,2 +1,2 @@ -var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"};function t(t,r,a,i){var l;if(!e){var o="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";process&&process.emitWarning?process.emitWarning(o):console.warn(o),e=!0}var c=[Object.assign(new a.Token("link_open","a",1),{attrs:[].concat(r.permalinkClass?[["class",r.permalinkClass]]:[],[["href",r.permalinkHref(t,a)]],Object.entries(r.permalinkAttrs(t,a)))}),Object.assign(new a.Token("html_block","",0),{content:r.permalinkSymbol}),new a.Token("link_close","a",-1)];r.permalinkSpace&&a.tokens[i+1].children[n[r.permalinkBefore]](Object.assign(new a.Token("text","",0),{content:" "})),(l=a.tokens[i+1].children)[n[r.permalinkBefore]].apply(l,c)}function r(e){return"#"+e}function a(e){return{}}var i={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:a};function l(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({},i),n}var o=l(function(e,t,r,a,i){var l,o=[Object.assign(new a.Token("link_open","a",1),{attrs:[].concat(t.class?[["class",t.class]]:[],[["href",t.renderHref(e,a)],["aria-hidden","true"]],Object.entries(t.renderAttrs(e,a)))}),Object.assign(new a.Token("text","",0),{content:t.symbol}),new a.Token("link_close","a",-1)];t.space&&a.tokens[i+1].children[n[t.placement]](Object.assign(new a.Token("text","",0),{content:" "})),(l=a.tokens[i+1].children)[n[t.placement]].apply(l,o)});Object.assign(o.defaults,{space:!0,placement:"after"});var c=l(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})}),s=l(function(e,t,r,a,i){var l;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(t.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+t.style+"`");if(!["aria-describedby","aria-labelledby"].includes(t.style)&&!t.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+t.style+"` style");if("visually-hidden"===t.style&&!t.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var o=a.tokens[i+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),c=[],s=[];t.class&&s.push(["class",t.class]),s.push(["href",t.renderHref(e,a)]),s.push.apply(s,Object.entries(t.renderAttrs(e,a))),"visually-hidden"===t.style?(c.push(Object.assign(new a.Token("span_open","span",1),{attrs:[["class",t.visuallyHiddenClass]]}),Object.assign(new a.Token("text","",0),{content:t.assistiveText(o)}),new a.Token("span_close","span",-1)),t.space&&c[n[t.placement]](Object.assign(new a.Token("text","",0),{content:" "})),c[n[t.placement]](Object.assign(new a.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new a.Token("text","",0),{content:t.symbol}),new a.Token("span_close","span",-1))):c.push(Object.assign(new a.Token("text","",0),{content:t.symbol})),"aria-label"===t.style?s.push(["aria-label",t.assistiveText(o)]):["aria-describedby","aria-labelledby"].includes(t.style)&&s.push([t.style,e]);var u=[Object.assign(new a.Token("link_open","a",1),{attrs:s})].concat(c,[new a.Token("link_close","a",-1)]);(l=a.tokens).splice.apply(l,[i+3,0].concat(u))});function u(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 d(e,n){n=Object.assign({},d.defaults,n),e.core.ruler.push("anchor",function(e){var r,a={},i=e.tokens,l=Array.isArray(n.level)?(r=n.level,function(e){return r.includes(e)}):function(e){return function(n){return n>=e}}(n.level);i.forEach(function(r,o){if("heading_open"===r.type&&l(Number(r.tag.substr(1)))){var c=i[o+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=r.attrGet("id");s=null==s?u(n.slugify(c),a,!1,n.uniqueSlugStartIndex):u(s,a,!0,n.uniqueSlugStartIndex),r.attrSet("id",s),!1!==n.tabIndex&&r.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(s,n,e,o):(n.permalink||n.renderPermalink&&n.renderPermalink!==t)&&n.renderPermalink(s,n,e,o),n.callback&&n.callback(r,{slug:s,title:c})}})})}Object.assign(s.defaults,{style:"visually-hidden",space:!0,placement:"after"}),d.permalink={__proto__:null,legacy:t,renderHref:r,renderAttrs:a,makePermalink:l,ariaHidden:o,headerLink:c,linkAfterHeader:s},d.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:t,permalinkClass:o.defaults.class,permalinkSpace:o.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===o.defaults.placement,permalinkHref:o.defaults.renderHref,permalinkAttrs:o.defaults.renderAttrs};export default d; +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)}(o);!(i=s()).done;){var u=i.value;if("heading_open"===u.type&&c(Number(u.tag.substr(1)))){var f=o.indexOf(u),b=o[f+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?d(t.slugify(b),l,!1,t.uniqueSlugStartIndex):d(p,l,!0,t.uniqueSlugStartIndex),u.attrSet("id",p),!1!==t.tabIndex&&u.attrSet("tabindex",""+t.tabIndex),"function"==typeof t.permalink?t.permalink(p,t,n,f):(t.permalink||t.renderPermalink&&t.renderPermalink!==r)&&t.renderPermalink(p,t,n,f),t.callback&&t.callback(u,{slug:p,title:b})}}})}Object.assign(u.defaults,{style:"visually-hidden",space:!0,placement:"after"}),f.permalink={__proto__:null,legacy:r,renderHref:a,renderAttrs:i,makePermalink:o,ariaHidden:c,headerLink:s,linkAfterHeader:u},f.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:r,permalinkClass:c.defaults.class,permalinkSpace:c.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===c.defaults.placement,permalinkHref:c.defaults.renderHref,permalinkAttrs:c.defaults.renderAttrs};export default f; //# sourceMappingURL=markdownItAnchor.mjs.map diff --git a/dist/markdownItAnchor.mjs.map b/dist/markdownItAnchor.mjs.map index 69f4324..71b1161 100644 --- a/dist/markdownItAnchor.mjs.map +++ b/dist/markdownItAnchor.mjs.map @@ -1 +1 @@ -{"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\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 (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 }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('text', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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('text', '', 0), {\n content: opts.symbol,\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('text', '', 0), {\n content: opts.symbol,\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 tokens.forEach((token, i) => {\n if (token.type !== 'heading_open') {\n return\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n return\n }\n\n // Aggregate the next token children text.\n const title = tokens[i + 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, i)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, i)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, i)\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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","forEach","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"AAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,oBAGMC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKV,EAAgB,CACnB,IAAMW,EAAc,sIAEhBC,SAAWA,QAAQC,YACrBD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfX,GAAiB,EAGnB,IAAMgB,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,kBACpE,IAAIjB,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKmB,gBACPlB,EAAMmB,OAAOlB,EAAM,GAAGmB,SAAS5B,EAASO,EAAKsB,kBAAkBb,OAAOC,OAAO,IAAIT,EAAMU,MAAM,OAAQ,GAAI,GAAI,CAAEM,QAAS,UAG1HhB,EAAMmB,OAAOlB,EAAM,GAAGmB,UAAS5B,EAASO,EAAKsB,0BAAqBd,YAGpDe,EAAYxB,GAC1B,UAAWA,WAGGyB,EAAazB,GAC3B,MAAO,GAGT,IAAM0B,EAAiB,CACrBC,MAAO,gBACPC,OAAQ,IACRJ,WAAAA,EACAC,YAAAA,YA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,WAAW,EACXpD,gBAAiBoD,EACjBrE,eAAgBqE,EAAqBnD,eACrCZ,eAAgB+D,EAAqBnD,SAASG,MAC9ChB,gBAAiB,IACjBI,gBAA6D,WAA5C4D,EAAqBnD,SAASI,UAC/CrB,cAAeoE,EAAqBnD,SAASR,WAC7CP,eAAgBkE,EAAqBnD,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\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 (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_inline', '', 0), { content: opts.permalinkSymbol }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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 }),\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 })\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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,oBAGMC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKV,EAAgB,CACnB,IAAMW,EAAc,sIAEhBC,SAAWA,QAAQC,YACrBD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfX,GAAiB,EAGnB,IAAMgB,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/B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ACPrC,EAAMoC,QAAQ,cAAejF,EAAKkF,UAGN,mBAAnBlF,EAAKmF,UACdnF,EAAKmF,UAAUpF,EAAMC,EAAMC,EAAO2E,IACzB5E,EAAKmF,WAELnF,EAAK8B,iBAAmB9B,EAAK8B,kBAAoBqD,IAD1DnF,EAAK8B,gBAAgB/B,EAAMC,EAAMC,EAAO2E,GAKtC5E,EAAKoF,UACPpF,EAAKoF,SAASvC,EAAO,CAAE9C,KAAAA,EAAM4C,MAAAA,QDiHrClC,OAAOC,OAAO2B,EAAgBN,SAAU,CACtCQ,MAAO,kBACPL,OAAO,EACPC,UAAW,UC9Gb4B,EAAOoB,2HAEPpB,EAAOhC,SAAW,CAChBwC,MAAO,EACPQ,QAtFc,SAACM,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAuFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXrD,gBAAiBqD,EACjBtE,eAAgBsE,EAAqBpD,eACrCZ,eAAgBgE,EAAqBpD,SAASG,MAC9ChB,gBAAiB,IACjBI,gBAA6D,WAA5C6D,EAAqBpD,SAASI,UAC/CrB,cAAeqE,EAAqBpD,SAASR,WAC7CP,eAAgBmE,EAAqBpD,SAASP"} \ No newline at end of file diff --git a/dist/markdownItAnchor.modern.js b/dist/markdownItAnchor.modern.js index 79360b9..ba4dea1 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"};function t(t,r,a,i){if(!e){const n="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";process&&process.emitWarning?process.emitWarning(n):console.warn(n),e=!0}const l=[Object.assign(new a.Token("link_open","a",1),{attrs:[...r.permalinkClass?[["class",r.permalinkClass]]:[],["href",r.permalinkHref(t,a)],...Object.entries(r.permalinkAttrs(t,a))]}),Object.assign(new a.Token("html_block","",0),{content:r.permalinkSymbol}),new a.Token("link_close","a",-1)];r.permalinkSpace&&a.tokens[i+1].children[n[r.permalinkBefore]](Object.assign(new a.Token("text","",0),{content:" "})),a.tokens[i+1].children[n[r.permalinkBefore]](...l)}function r(e){return"#"+e}function a(e){return{}}const i={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:a};function l(e){function n(t){return t=Object.assign({},n.defaults,t),(n,r,a,i)=>e(n,t,r,a,i)}return n.defaults=Object.assign({},i),n}const o=l((e,t,r,a,i)=>{const l=[Object.assign(new a.Token("link_open","a",1),{attrs:[...t.class?[["class",t.class]]:[],["href",t.renderHref(e,a)],["aria-hidden","true"],...Object.entries(t.renderAttrs(e,a))]}),Object.assign(new a.Token("text","",0),{content:t.symbol}),new a.Token("link_close","a",-1)];t.space&&a.tokens[i+1].children[n[t.placement]](Object.assign(new a.Token("text","",0),{content:" "})),a.tokens[i+1].children[n[t.placement]](...l)});Object.assign(o.defaults,{space:!0,placement:"after"});const c=l((e,n,t,r,a)=>{const i=[Object.assign(new r.Token("link_open","a",1),{attrs:[...n.class?[["class",n.class]]:[],["href",n.renderHref(e,r)],...Object.entries(n.renderAttrs(e,r))]}),...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})}),s=l((e,t,r,a,i)=>{if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(t.style))throw new Error(`\`permalink.linkAfterHeader\` called with unknown style option \`${t.style}\``);if(!["aria-describedby","aria-labelledby"].includes(t.style)&&!t.assistiveText)throw new Error(`\`permalink.linkAfterHeader\` called without the \`assistiveText\` option in \`${t.style}\` style`);if("visually-hidden"===t.style&&!t.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");const l=a.tokens[i+1].children.filter(e=>"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,""),o=[],c=[];t.class&&c.push(["class",t.class]),c.push(["href",t.renderHref(e,a)]),c.push(...Object.entries(t.renderAttrs(e,a))),"visually-hidden"===t.style?(o.push(Object.assign(new a.Token("span_open","span",1),{attrs:[["class",t.visuallyHiddenClass]]}),Object.assign(new a.Token("text","",0),{content:t.assistiveText(l)}),new a.Token("span_close","span",-1)),t.space&&o[n[t.placement]](Object.assign(new a.Token("text","",0),{content:" "})),o[n[t.placement]](Object.assign(new a.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new a.Token("text","",0),{content:t.symbol}),new a.Token("span_close","span",-1))):o.push(Object.assign(new a.Token("text","",0),{content:t.symbol})),"aria-label"===t.style?c.push(["aria-label",t.assistiveText(l)]):["aria-describedby","aria-labelledby"].includes(t.style)&&c.push([t.style,e]);const s=[Object.assign(new a.Token("link_open","a",1),{attrs:c}),...o,new a.Token("link_close","a",-1)];a.tokens.splice(i+3,0,...s)});function d(e,n,t,r){let 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",e=>{const r={},a=e.tokens,i=Array.isArray(n.level)?(l=n.level,e=>l.includes(e)):(e=>n=>n>=e)(n.level);var l;a.forEach((l,o)=>{if("heading_open"!==l.type)return;if(!i(Number(l.tag.substr(1))))return;const c=a[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?d(n.slugify(c),r,!1,n.uniqueSlugStartIndex):d(s,r,!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!==t)&&n.renderPermalink(s,n,e,o),n.callback&&n.callback(l,{slug:s,title:c})})})}Object.assign(s.defaults,{style:"visually-hidden",space:!0,placement:"after"}),b.permalink={__proto__:null,legacy:t,renderHref:r,renderAttrs:a,makePermalink:l,ariaHidden:o,headerLink:c,linkAfterHeader:s},b.defaults={level:1,slugify:e=>encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-")),uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:t,permalinkClass:o.defaults.class,permalinkSpace:o.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===o.defaults.placement,permalinkHref:o.defaults.renderHref,permalinkAttrs:o.defaults.renderAttrs};export default b; +let e=!1;const n={false:"push",true:"unshift",after:"push",before:"unshift"};function t(t,r,i,a){if(!e){const n="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";process&&process.emitWarning?process.emitWarning(n):console.warn(n),e=!0}const l=[Object.assign(new i.Token("link_open","a",1),{attrs:[...r.permalinkClass?[["class",r.permalinkClass]]:[],["href",r.permalinkHref(t,i)],...Object.entries(r.permalinkAttrs(t,i))]}),Object.assign(new i.Token("html_inline","",0),{content:r.permalinkSymbol}),new i.Token("link_close","a",-1)];r.permalinkSpace&&i.tokens[a+1].children[n[r.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),i.tokens[a+1].children[n[r.permalinkBefore]](...l)}function r(e){return"#"+e}function i(e){return{}}const a={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:i};function l(e){function n(t){return t=Object.assign({},n.defaults,t),(n,r,i,a)=>e(n,t,r,i,a)}return n.defaults=Object.assign({},a),n}const o=l((e,t,r,i,a)=>{const l=[Object.assign(new i.Token("link_open","a",1),{attrs:[...t.class?[["class",t.class]]:[],["href",t.renderHref(e,i)],["aria-hidden","true"],...Object.entries(t.renderAttrs(e,i))]}),Object.assign(new i.Token("html_inline","",0),{content:t.symbol}),new i.Token("link_close","a",-1)];t.space&&i.tokens[a+1].children[n[t.placement]](Object.assign(new i.Token("text","",0),{content:" "})),i.tokens[a+1].children[n[t.placement]](...l)});Object.assign(o.defaults,{space:!0,placement:"after"});const c=l((e,n,t,r,i)=>{const a=[Object.assign(new r.Token("link_open","a",1),{attrs:[...n.class?[["class",n.class]]:[],["href",n.renderHref(e,r)],...Object.entries(n.renderAttrs(e,r))]}),...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})}),s=l((e,t,r,i,a)=>{if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(t.style))throw new Error(`\`permalink.linkAfterHeader\` called with unknown style option \`${t.style}\``);if(!["aria-describedby","aria-labelledby"].includes(t.style)&&!t.assistiveText)throw new Error(`\`permalink.linkAfterHeader\` called without the \`assistiveText\` option in \`${t.style}\` style`);if("visually-hidden"===t.style&&!t.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");const l=i.tokens[a+1].children.filter(e=>"text"===e.type||"code_inline"===e.type).reduce((e,n)=>e+n.content,""),o=[],c=[];t.class&&c.push(["class",t.class]),c.push(["href",t.renderHref(e,i)]),c.push(...Object.entries(t.renderAttrs(e,i))),"visually-hidden"===t.style?(o.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",t.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:t.assistiveText(l)}),new i.Token("span_close","span",-1)),t.space&&o[n[t.placement]](Object.assign(new i.Token("text","",0),{content:" "})),o[n[t.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("html_inline","",0),{content:t.symbol}),new i.Token("span_close","span",-1))):o.push(Object.assign(new i.Token("html_inline","",0),{content:t.symbol})),"aria-label"===t.style?c.push(["aria-label",t.assistiveText(l)]):["aria-describedby","aria-labelledby"].includes(t.style)&&c.push([t.style,e]);const s=[Object.assign(new i.Token("link_open","a",1),{attrs:c}),...o,new i.Token("link_close","a",-1)];i.tokens.splice(a+3,0,...s)});function d(e,n,t,r){let 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",e=>{const r={},i=e.tokens,a=Array.isArray(n.level)?(l=n.level,e=>l.includes(e)):(e=>n=>n>=e)(n.level);var l;for(const l of i){if("heading_open"!==l.type)continue;if(!a(Number(l.tag.substr(1))))continue;const o=i.indexOf(l),c=i[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?d(n.slugify(c),r,!1,n.uniqueSlugStartIndex):d(s,r,!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!==t)&&n.renderPermalink(s,n,e,o),n.callback&&n.callback(l,{slug:s,title:c})}})}Object.assign(s.defaults,{style:"visually-hidden",space:!0,placement:"after"}),b.permalink={__proto__:null,legacy:t,renderHref:r,renderAttrs:i,makePermalink:l,ariaHidden:o,headerLink:c,linkAfterHeader:s},b.defaults={level:1,slugify:e=>encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-")),uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:t,permalinkClass:o.defaults.class,permalinkSpace:o.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===o.defaults.placement,permalinkHref:o.defaults.renderHref,permalinkAttrs:o.defaults.renderAttrs};export default b; //# sourceMappingURL=markdownItAnchor.modern.js.map diff --git a/dist/markdownItAnchor.modern.js.map b/dist/markdownItAnchor.modern.js.map index 2e8c659..84df804 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\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 (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 }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('text', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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('text', '', 0), {\n content: opts.symbol,\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('text', '', 0), {\n content: opts.symbol,\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 tokens.forEach((token, i) => {\n if (token.type !== 'heading_open') {\n return\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n return\n }\n\n // Aggregate the next token children text.\n const title = tokens[i + 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, i)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, i)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, i)\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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","forEach","Number","tag","substr","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,oBAGMC,EAAQC,EAAMC,EAAMC,EAAOC,GACzC,IAAKV,EAAgB,CACnB,MAAMW,EAAc,sIAEhBC,SAAWA,QAAQC,YACrBD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfX,GAAiB,EAGnB,MAAMgB,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,kBACpE,IAAIjB,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKmB,gBACPlB,EAAMmB,OAAOlB,EAAM,GAAGmB,SAAS5B,EAASO,EAAKsB,kBAAkBb,OAAOC,OAAO,IAAIT,EAAMU,MA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AK8B,gBAAgB/B,EAAMC,EAAMC,EAAO0D,GAKtC3D,EAAKmF,UACPnF,EAAKmF,SAAStC,EAAO,CAAE9C,KAAAA,EAAM4C,MAAAA,QDqHrClC,OAAOC,OAAO2B,EAAgBN,SAAU,CACtCQ,MAAO,kBACPL,OAAO,EACPC,UAAW,UClHb4B,EAAOmB,2HAEPnB,EAAOhC,SAAW,CAChBuC,MAAO,EACPQ,QAlFeM,GAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,MAmFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXpD,gBAAiBoD,EACjBrE,eAAgBqE,EAAqBnD,SAASL,MAC9CP,eAAgB+D,EAAqBnD,SAASG,MAC9ChB,gBAAiB,IACjBI,gBAA6D,WAA5C4D,EAAqBnD,SAASI,UAC/CrB,cAAeoE,EAAqBnD,SAASR,WAC7CP,eAAgBkE,EAAqBnD,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\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 (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_inline', '', 0), { content: opts.permalinkSymbol }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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 }),\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 })\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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,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qBpD,SAASR,WAC7CP,eAAgBmE,EAAqBpD,SAASP"} \ No newline at end of file diff --git a/dist/markdownItAnchor.umd.js b/dist/markdownItAnchor.umd.js index df0b54a..8f0f5f5 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(){var e=!1,n={false:"push",true:"unshift",after:"push",before:"unshift"};function t(t,r,i,a){var o;if(!e){var l="Using deprecated markdown-it-anchor permalink option, see https://github.com/valeriangalliat/markdown-it-anchor#todo-anchor-or-file";process&&process.emitWarning?process.emitWarning(l):console.warn(l),e=!0}var c=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(r.permalinkClass?[["class",r.permalinkClass]]:[],[["href",r.permalinkHref(t,i)]],Object.entries(r.permalinkAttrs(t,i)))}),Object.assign(new i.Token("html_block","",0),{content:r.permalinkSymbol}),new i.Token("link_close","a",-1)];r.permalinkSpace&&i.tokens[a+1].children[n[r.permalinkBefore]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[a+1].children)[n[r.permalinkBefore]].apply(o,c)}function r(e){return"#"+e}function i(e){return{}}var a={class:"header-anchor",symbol:"#",renderHref:r,renderAttrs:i};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({},a),n}var l=o(function(e,t,r,i,a){var o,l=[Object.assign(new i.Token("link_open","a",1),{attrs:[].concat(t.class?[["class",t.class]]:[],[["href",t.renderHref(e,i)],["aria-hidden","true"]],Object.entries(t.renderAttrs(e,i)))}),Object.assign(new i.Token("text","",0),{content:t.symbol}),new i.Token("link_close","a",-1)];t.space&&i.tokens[a+1].children[n[t.placement]](Object.assign(new i.Token("text","",0),{content:" "})),(o=i.tokens[a+1].children)[n[t.placement]].apply(o,l)});Object.assign(l.defaults,{space:!0,placement:"after"});var c=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})}),s=o(function(e,t,r,i,a){var o;if(!["visually-hidden","aria-label","aria-describedby","aria-labelledby"].includes(t.style))throw new Error("`permalink.linkAfterHeader` called with unknown style option `"+t.style+"`");if(!["aria-describedby","aria-labelledby"].includes(t.style)&&!t.assistiveText)throw new Error("`permalink.linkAfterHeader` called without the `assistiveText` option in `"+t.style+"` style");if("visually-hidden"===t.style&&!t.visuallyHiddenClass)throw new Error("`permalink.linkAfterHeader` called without the `visuallyHiddenClass` option in `visually-hidden` style");var l=i.tokens[a+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),c=[],s=[];t.class&&s.push(["class",t.class]),s.push(["href",t.renderHref(e,i)]),s.push.apply(s,Object.entries(t.renderAttrs(e,i))),"visually-hidden"===t.style?(c.push(Object.assign(new i.Token("span_open","span",1),{attrs:[["class",t.visuallyHiddenClass]]}),Object.assign(new i.Token("text","",0),{content:t.assistiveText(l)}),new i.Token("span_close","span",-1)),t.space&&c[n[t.placement]](Object.assign(new i.Token("text","",0),{content:" "})),c[n[t.placement]](Object.assign(new i.Token("span_open","span",1),{attrs:[["aria-hidden","true"]]}),Object.assign(new i.Token("text","",0),{content:t.symbol}),new i.Token("span_close","span",-1))):c.push(Object.assign(new i.Token("text","",0),{content:t.symbol})),"aria-label"===t.style?s.push(["aria-label",t.assistiveText(l)]):["aria-describedby","aria-labelledby"].includes(t.style)&&s.push([t.style,e]);var u=[Object.assign(new i.Token("link_open","a",1),{attrs:s})].concat(c,[new i.Token("link_close","a",-1)]);(o=i.tokens).splice.apply(o,[a+3,0].concat(u))});function u(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 d(e,n){n=Object.assign({},d.defaults,n),e.core.ruler.push("anchor",function(e){var r,i={},a=e.tokens,o=Array.isArray(n.level)?(r=n.level,function(e){return r.includes(e)}):function(e){return function(n){return n>=e}}(n.level);a.forEach(function(r,l){if("heading_open"===r.type&&o(Number(r.tag.substr(1)))){var c=a[l+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),s=r.attrGet("id");s=null==s?u(n.slugify(c),i,!1,n.uniqueSlugStartIndex):u(s,i,!0,n.uniqueSlugStartIndex),r.attrSet("id",s),!1!==n.tabIndex&&r.attrSet("tabindex",""+n.tabIndex),"function"==typeof n.permalink?n.permalink(s,n,e,l):(n.permalink||n.renderPermalink&&n.renderPermalink!==t)&&n.renderPermalink(s,n,e,l),n.callback&&n.callback(r,{slug:s,title:c})}})})}return Object.assign(s.defaults,{style:"visually-hidden",space:!0,placement:"after"}),d.permalink={__proto__:null,legacy:t,renderHref:r,renderAttrs:i,makePermalink:o,ariaHidden:l,headerLink:c,linkAfterHeader:s},d.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:t,permalinkClass:l.defaults.class,permalinkSpace:l.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===l.defaults.placement,permalinkHref:l.defaults.renderHref,permalinkAttrs:l.defaults.renderAttrs},d}); +!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),u=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=u()).done;){var s=a.value;if("heading_open"===s.type&&c(Number(s.tag.substr(1)))){var f=l.indexOf(s),b=l[f+1].children.filter(function(e){return"text"===e.type||"code_inline"===e.type}).reduce(function(e,n){return e+n.content},""),p=s.attrGet("id");p=null==p?d(t.slugify(b),o,!1,t.uniqueSlugStartIndex):d(p,o,!0,t.uniqueSlugStartIndex),s.attrSet("id",p),!1!==t.tabIndex&&s.attrSet("tabindex",""+t.tabIndex),"function"==typeof t.permalink?t.permalink(p,t,n,f):(t.permalink||t.renderPermalink&&t.renderPermalink!==r)&&t.renderPermalink(p,t,n,f),t.callback&&t.callback(s,{slug:p,title:b})}}})}return Object.assign(s.defaults,{style:"visually-hidden",space:!0,placement:"after"}),f.permalink={__proto__:null,legacy:r,renderHref:i,renderAttrs:a,makePermalink:l,ariaHidden:c,headerLink:u,linkAfterHeader:s},f.defaults={level:1,slugify:function(e){return encodeURIComponent(String(e).trim().toLowerCase().replace(/\s+/g,"-"))},uniqueSlugStartIndex:1,tabIndex:"-1",permalink:!1,renderPermalink:r,permalinkClass:c.defaults.class,permalinkSpace:c.defaults.space,permalinkSymbol:"¶",permalinkBefore:"before"===c.defaults.placement,permalinkHref:c.defaults.renderHref,permalinkAttrs:c.defaults.renderAttrs},f}); //# sourceMappingURL=markdownItAnchor.umd.js.map diff --git a/dist/markdownItAnchor.umd.js.map b/dist/markdownItAnchor.umd.js.map index 4b897ab..e5c6828 100644 --- a/dist/markdownItAnchor.umd.js.map +++ b/dist/markdownItAnchor.umd.js.map @@ -1 +1 @@ -{"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\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 (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 }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('text', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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('text', '', 0), {\n content: opts.symbol,\n }),\n new state.Token('span_close', 'span', -1)\n )\n } else {\n subLinkTokens.push(\n Object.assign(new state.Token('text', '', 0), {\n content: opts.symbol,\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 tokens.forEach((token, i) => {\n if (token.type !== 'heading_open') {\n return\n }\n\n if (!isLevelSelected(Number(token.tag.substr(1)))) {\n return\n }\n\n // Aggregate the next token children text.\n const title = tokens[i + 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, i)\n } else if (opts.permalink) {\n opts.renderPermalink(slug, opts, state, i)\n } else if (opts.renderPermalink && opts.renderPermalink !== permalink.legacy) {\n opts.renderPermalink(slug, opts, state, i)\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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","forEach","Number","tag","substr","attrGet","slugify","uniqueSlugStartIndex","attrSet","tabIndex","permalink","callback","s","encodeURIComponent","String","trim","toLowerCase","replace"],"mappings":"yLAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,oBAGMC,EAAQC,EAAMC,EAAMC,EAAOC,SACzC,IAAKV,EAAgB,CACnB,IAAMW,EAAc,sIAEhBC,SAAWA,QAAQC,YACrBD,QAAQC,YAAYF,GAEpBG,QAAQC,KAAKJ,GAGfX,GAAiB,EAGnB,IAAMgB,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,kBACpE,IAAIjB,EAAMU,MAAM,aAAc,KAAM,IAGlCX,EAAKmB,gBACPlB,EAAMmB,OAA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,GAKtC3D,EAAKmF,UACPnF,EAAKmF,SAAStC,EAAO,CAAE9C,KAAAA,EAAM4C,MAAAA,gBDqHrClC,OAAOC,OAAO2B,EAAgBN,SAAU,CACtCQ,MAAO,kBACPL,OAAO,EACPC,UAAW,UClHb4B,EAAOmB,2HAEPnB,EAAOhC,SAAW,CAChBwC,MAAO,EACPO,QAlFc,SAACM,UAAMC,mBAAmBC,OAAOF,GAAGG,OAAOC,cAAcC,QAAQ,OAAQ,OAmFvFV,qBAAsB,EACtBE,SAAU,KAGVC,WAAW,EACXpD,gBAAiBoD,EACjBrE,eAAgBqE,EAAqBnD,eACrCZ,eAAgB+D,EAAqBnD,SAASG,MAC9ChB,gBAAiB,IACjBI,gBAA6D,WAA5C4D,EAAqBnD,SAASI,UAC/CrB,cAAeoE,EAAqBnD,SAASR,WAC7CP,eAAgBkE,EAAqBnD,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\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 (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_inline', '', 0), { content: opts.permalinkSymbol }),\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 (wrappedRenderPermalink) {\n function renderPermalink (opts) {\n opts = Object.assign({}, renderPermalink.defaults, opts)\n\n return (slug, anchorOpts, state, idx) => {\n return wrappedRenderPermalink(slug, opts, anchorOpts, state, idx)\n }\n }\n\n renderPermalink.defaults = Object.assign({}, commonDefaults)\n\n return renderPermalink\n}\n\nexport const ariaHidden = 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 ['aria-hidden', 'true'],\n ...Object.entries(opts.renderAttrs(slug, state))\n ]\n }),\n Object.assign(new state.Token('html_inline', '', 0), { content: opts.symbol }),\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(ariaHidden.defaults, {\n space: true,\n placement: 'after'\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 }),\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 })\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","legacy","slug","opts","state","idx","warningText","process","emitWarning","console","warn","linkTokens","Object","assign","Token","attrs","permalinkClass","permalinkHref","entries","permalinkAttrs","content","permalinkSymbol","permalinkSpace","tokens","children","permalinkBefore","renderHref","renderAttrs","commonDefaults","class","symbol","makePermalink","wrappedRenderPermalink","renderPermalink","defaults","anchorOpts","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":"mSAAA,IAAIA,GAAiB,EAEfC,EAAW,CACfC,MAAO,OACPC,KAAM,UACNC,MAAO,OACPC,OAAQ,oBAGMC,EAAQC,EAA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