@mdit/plugin-footnote 1.1.4 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/cdn.umd.js +6 -7
- package/dist/cdn.umd.js.map +1 -1
- package/dist/index.d.ts +113 -10
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,3 +16,13 @@ npm i -D @mdit/plugin-footnote
|
|
|
16
16
|
# yarn
|
|
17
17
|
yarn add -D @mdit/plugin-footnote
|
|
18
18
|
```
|
|
19
|
+
|
|
20
|
+
## Comparison / 对比
|
|
21
|
+
|
|
22
|
+
Compared against the upstream [`markdown-it-footnote`](https://www.npmjs.com/package/markdown-it-footnote) package `4.0.0`.
|
|
23
|
+
|
|
24
|
+
- Correctness: **6/22** cases match the reference exactly (16 matching after normalization).
|
|
25
|
+
- Throughput: **0.99×** the reference (geometric mean across 6 benchmark cases; above 1× means faster).
|
|
26
|
+
- Entry gzip: **2.2 kB** versus **2.7 kB** for the reference (import cost).
|
|
27
|
+
|
|
28
|
+
See the full comparison report: [English](https://mdit-plugins.github.io/compare.html) · [中文](https://mdit-plugins.github.io/zh/compare.html).
|
package/dist/cdn.umd.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.mdItPluginFootnote={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),String.raw`\$&`;let t=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`),n=(e,t,n)=>(n?[e[n].ruler]:[e.core.ruler,e.block.ruler,e.inline.ruler]).some(e=>e.__rules__.some(({name:e})=>e===t));String.raw`\^$.*+?()[]{}|`;let r=(e
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
`,c=()=>`</ol>
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.mdItPluginFootnote={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),String.raw`\$&`;let t=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`),n=(e,t,n)=>(n?[e[n].ruler]:[e.core.ruler,e.block.ruler,e.inline.ruler]).some(e=>e.__rules__.some(({name:e})=>e===t));String.raw`\^$.*+?()[]{}|`;let r=e=>{if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===34||n===39||n===47||n===60||n===61||n===62)return!1}return!0},i=e=>{let t=``,n=0;for(let r=0;r<e.length;r++){let i=``;switch(e.charCodeAt(r)){case 34:i=`"`;break;case 38:i=`&`;break;case 60:i=`<`;break;case 62:i=`>`}i&&(t+=e.slice(n,r)+i,n=r+1)}return n===0?e:t+e.slice(n)},a=(e,t)=>{if(t){for(let[n,i]of Object.entries(t))if(r(n)){if(n===`class`){let t=String(i).trim();t&&e.attrJoin(`class`,t)}else e.attrSet(n,i)}}},o=e=>(e??0)>0?`:${e}`:``,s=(e,t)=>`${typeof e==`string`?`-${e}-`:``}${t+1}`,c=(e,t)=>`[${e+1}${o(t)}]`,l=(e,t)=>{let{id:n,subId:r}=e[t].meta;return c(n,r)},u=(e,t,n,r,a)=>{let{href:o,anchorId:s,anchorClass:c}=e[t].meta,l=a.rules.footnote_caption(e,t,n,r,a);return`<sup${a.renderAttrs(e[t])}><a href="${i(o)}">${l}</a><a class="${i(c)}" id="${i(s)}"></a></sup>`},d=(e,t,n,r,a)=>{let{separatorClass:o,listClass:s}=e[t].meta;return`<hr class="${i(o)}"${n.xhtmlOut?` /`:``}>
|
|
2
|
+
<section${a.renderAttrs(e[t])}>
|
|
3
|
+
<ol class="${i(s)}">
|
|
4
|
+
`},f=()=>`</ol>
|
|
6
5
|
</section>
|
|
7
|
-
`,
|
|
8
|
-
`,
|
|
6
|
+
`,p=(e,t,n,r,i)=>`<li${i.renderAttrs(e[t])}>`,m=()=>`</li>
|
|
7
|
+
`,h=(e,n,r,i,a)=>{let{text:o}=e[n].meta;return` <a${a.renderAttrs(e[n])}>${t(o)}</a>`},g=(e,t,n,r)=>{let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o;if(i+4>a||e.src.charCodeAt(i)!==91||e.src.charCodeAt(i+1)!==94)return!1;let s=i+2;for(;s<a;){if(o=e.src.charCodeAt(s),o===32)return!1;if(o===93)break;s++}if(s===i+2||s+1>=a||e.src.charCodeAt(++s)!==58)return!1;if(r)return!0;s++,(e.env.footnotes??={}).refs??={};let c=e.src.slice(i+2,s-2);e.env.footnotes.refs[`:${c}`]=-1;let l=e.push(`footnote_reference_open`,``,1);l.meta={label:c},l.level=e.level++;let u=e.bMarks[t],d=e.tShift[t],f=e.sCount[t],p=e.parentType,m=s,h=e.sCount[t]+s-(e.bMarks[t]+e.tShift[t]),g=h;for(;s<a;){if(o=e.src.charCodeAt(s),o===9)g+=4-g%4;else if(o===32)g++;else break;s++}e.tShift[t]=s-m,e.sCount[t]=g-h,e.bMarks[t]=m,e.blkIndent+=4,e.parentType=`footnote`,e.sCount[t]<e.blkIndent&&(e.sCount[t]+=e.blkIndent),e.md.block.tokenize(e,t,n),e.parentType=p,e.blkIndent-=4,e.tShift[t]=d,e.sCount[t]=f,e.bMarks[t]=u;let _=e.push(`footnote_reference_close`,``,-1);return _.level=--e.level,!0},_=(e,t,n,r,i)=>{let c=e.push(`footnote_ref`,``,0),l=s(e.env.docId,n),u=o(r);c.meta={id:n,subId:r,label:i,href:`#footnote${l}`,anchorId:`footnote-ref${l}${u}`,anchorClass:`footnote-anchor`},c.attrJoin(`class`,`footnote-ref`),a(c,t.refAttrs)},v=e=>(t,n)=>{let r=t.posMax,i=t.pos;if(i+2>=r||t.src.charCodeAt(i)!==94||t.src.charCodeAt(i+1)!==91)return!1;let a=t.md.helpers.parseLinkLabel(t,i+1);if(a<0)return!1;let o=i+2;if(!n){let n=((t.env.footnotes??={}).list??=[]).length,r=[];t.md.inline.parse(t.src.slice(o,a),t.md,t.env,r),t.env.footnotes.list[n]={content:t.src.slice(o,a),tokens:r},_(t,e,n)}return t.pos=a+1,t.posMax=r,!0},y=e=>(t,n)=>{let r=t.pos,i=t.posMax;if(r+3>i||!t.env.footnotes?.refs||t.src.charCodeAt(r)!==91||t.src.charCodeAt(r+1)!==94)return!1;let a=r+2,o;for(;a<i;){if(o=t.src.charCodeAt(a),o===32||o===10)return!1;if(o===93)break;a++}if(a===r+2||a>=i)return!1;a++;let s=t.src.slice(r+2,a-1);if(typeof t.env.footnotes.refs[`:${s}`]!=`number`)return!1;if(!n){let n=t.env.footnotes.list??=[],{refs:r}=t.env.footnotes,i;r[`:${s}`]<0?(i=n.length,n[i]={label:s,count:0},r[`:${s}`]=i):i=r[`:${s}`];let a=n[i].count;n[i].count+=1,_(t,e,i,a,s)}return t.pos=a,t.posMax=i,!0},b=e=>t=>{let n={},r=[];if(!t.env.footnotes?.list){let e=0;t.tokens=t.tokens.filter(t=>t.type===`footnote_reference_open`?(e++,!1):t.type===`footnote_reference_close`?(e--,!1):e===0);return}let{list:i}=t.env.footnotes;t.tokens=t.tokens.filter(e=>{if(e.type===`footnote_reference_open`)return r.push({label:e.meta.label,tokens:[]}),!1;if(e.type===`footnote_reference_close`){let{label:e,tokens:t}=r.pop();return n[`:${e}`]=t,!1}return r.length===0||(r[r.length-1].tokens.push(e),!1)});let c=new t.Token(`footnote_block_open`,``,1);c.meta={separatorClass:`footnotes-sep`,listClass:`footnotes-list`},c.attrJoin(`class`,`footnotes`),a(c,e.containerAttrs),t.tokens.push(c);let l=i.length;for(let r=0;r<l;r++){let c=new t.Token(`footnote_open`,``,1),l=s(t.env.docId,r);if(c.meta={id:r,label:i[r].label},c.attrSet(`id`,`footnote${l}`),c.attrJoin(`class`,`footnote-item`),a(c,e.itemAttrs),t.tokens.push(c),i[r].tokens){let e=new t.Token(`paragraph_open`,`p`,1);e.block=!0;let n=new t.Token(`inline`,``,0);n.children=i[r].tokens,n.content=i[r].content;let a=new t.Token(`paragraph_close`,`p`,-1);a.block=!0,t.tokens.push(e,n,a)}else{let e=n[`:${i[r].label}`];e&&t.tokens.push(...e)}let u=t.tokens[t.tokens.length-1].type===`paragraph_close`?t.tokens.pop():null;for(let n=0;n<(Number(i[r].count)>0?i[r].count:1);n++){let s=new t.Token(`footnote_anchor`,``,0);s.meta={id:r,subId:n,label:i[r].label,text:`↩︎`},s.attrSet(`href`,`#footnote-ref${l}${o(n)}`),s.attrJoin(`class`,`footnote-backref`),a(s,e.backrefAttrs),t.tokens.push(s)}u&&t.tokens.push(u),t.tokens.push(new t.Token(`footnote_close`,``,-1))}t.tokens.push(new t.Token(`footnote_block_close`,``,-1))};e.footnote=(e,t)=>{n(e,`footnoteTail`,`core`)||(e.renderer.rules.footnote_ref=u,e.renderer.rules.footnote_block_open=d,e.renderer.rules.footnote_block_close=f,e.renderer.rules.footnote_open=p,e.renderer.rules.footnote_close=m,e.renderer.rules.footnote_anchor=h,e.renderer.rules.footnote_caption=l,e.block.ruler.before(`reference`,`footnoteDef`,g,{alt:[`paragraph`,`reference`]}),e.inline.ruler.after(`image`,`footnoteInline`,v(t??{})),e.inline.ruler.after(`footnoteInline`,`footnote_ref`,y(t??{})),e.core.ruler.after(`inline`,`footnoteTail`,b(t??{})))}});
|
|
9
8
|
//# sourceMappingURL=cdn.umd.js.map
|
package/dist/cdn.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cdn.umd.js","names":["escapeHtml","hasRule","factory","global","exports","r","c","getIDSuffix","tokens","index","subId","renderFootnoteAnchorName","docId","env","id","renderFootnoteCaption","renderFootnoteRef","self","options","renderFootnoteBlockOpen","renderFootnoteBlockClose","renderFootnoteOpen","renderFootnoteClose","renderFootnoteAnchor","footnoteDef","start","state","startLine","max","charCode","pos","silent","label","referenceOpenToken","oldBMark","oldTShift","oldSCount","oldParentType","posAfterColon","initial","offset","endLine","referenceCloseToken","footnoteInline","labelEnd","labelStart","footnoteId","refToken","footnoteRef","list","refs","footnoteTail","refTokens","current","currentLabel","isInsideRef","stateToken","footnoteBlockOpenToken","listLength","footnoteOpenToken","paragraphOpenToken","inlineToken","paragraphCloseToken","lastParagraph","j","footnoteAnchorToken","md"],"sources":["../../helper/dist/index.js","../src/plugin.ts"],"sourcesContent":["const e=e=>{let t=e.split(`\n`),n=t.reduce((e,t)=>{for(let n=0;n<t.length;n++)if(t[n]!==` `&&t[n]!==`\t`)return Math.min(n,e);return e},1/0);return n<1/0?t.map(e=>e.slice(n)).join(`\n`):e},t=/[-/\\\\^$*+?.()|[\\]{}]/g,n=String.raw`\\$&`,r=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`\"`,`"`).replaceAll(`'`,`'`),i=e=>e.replaceAll(t,n),a=(e,t,n,r)=>{let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-r>=4||i+3>a)return null;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return null;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return null;let l=e.src.slice(i,a);if(o===96&&l.includes(\"`\"))return null;let u=t,d=!1;for(;u++,!(u>=n||(i=s=e.bMarks[u]+e.tShift[u],a=e.eMarks[u],i<a&&e.sCount[u]<r));)if(e.src.charCodeAt(i)===o&&!(e.sCount[u]-r>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){d=!0;break}return u+ +!!d},o=/\\r\\n?|\\n/g,s=/\\\\(?<char>[ \\\\!\"#$%&'()*+,./:;<=>?@[\\]^_`{|}~-])/gu,c=(e,t,n)=>(n?[e[n].ruler]:[e.core.ruler,e.block.ruler,e.inline.ruler]).some(e=>e.__rules__.some(({name:e})=>e===t)),l=String.raw`\\^$.*+?()[]{}|`,u=[`.env`,`.env.*`,`.npmrc`,`.netrc`,`.git-credentials`,`id_rsa*`,`id_ed25519*`,`*.pem`,`*.key`,`*.p12`,`.git/**`,`**/.git/**`,`.ssh/**`,`**/.ssh/**`,`.aws/**`,`**/.aws/**`,`.azure/**`,`**/.azure/**`,`.kube/**`,`**/.kube/**`,`.docker/config.json`,`**/.docker/config.json`,`*.tfstate*`],d=e=>{let t=`^`,{length:n}=e;for(let r=0;r<n;r++){let n=e[r];n===`*`?e.charCodeAt(r+1)===42?(r++,e.charCodeAt(r+1)===47?(r++,t+=`(?:.*/)?`):t+=`.*`):t+=`[^/]*`:t+=n===`?`?`[^/]`:l.includes(n)?`\\\\${n}`:n}return RegExp(`${t}$`)},f=/* @__PURE__ */ new Map,p=e=>{let t=f.get(e);if(t)return t;let n=d(e);return f.set(e,n),n},m=(e,t)=>((e.global||e.sticky)&&(e.lastIndex=0),e.test(t)),h=(e,t=u)=>{let n=e.lastIndexOf(`/`),r=n===-1?e:e.slice(n+1);for(let n of t)if(typeof n==`string`){let t=n.includes(`/`)?e:r;if(p(n).test(t))return!0}else if(m(n,e)||m(n,r))return!0;return!1};export{o as NEWLINE_RE,s as UNESCAPE_RE,e as dedent,u as defaultSensitiveFiles,r as escapeHtml,i as escapeRegExp,c as hasRule,h as isSensitiveFile,a as scanFence};\n//# sourceMappingURL=index.js.map","/** Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.mjs */\n\nimport { escapeHtml, hasRule } from \"@mdit/helper\";\nimport type { BlockRule, CoreRule, InlineRule, PluginSimple } from \"@mdit/helper\";\nimport type { RendererRule, StateBlock, StateCore, StateInline, Token } from \"markdown-it\";\n\nimport type { FootNoteEnv, FootNoteToken } from \"./types.js\";\n\ninterface FootNoteStateBlock extends StateBlock {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateInline extends StateInline {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateCore extends StateCore {\n env: FootNoteEnv;\n}\n\ntype FootNoteMeta = FootNoteToken[\"meta\"];\n\nconst getIDSuffix = (tokens: Token[], index: number): string => {\n // add suffix when multiple id was found\n const { subId } = tokens[index].meta as FootNoteMeta;\n\n return subId > 0 ? `:${subId}` : \"\";\n};\n\nconst renderFootnoteAnchorName: RendererRule = (tokens, index, _options, env) => {\n // prefix\n const docId = env?.docId;\n // increasing id\n const id = (tokens[index].meta as FootNoteMeta).id;\n\n // `docId` comes from the caller-provided `env` and is interpolated into `id` / `href`\n // attributes, so it must be escaped to prevent attribute injection.\n return `${typeof docId === \"string\" ? `-${escapeHtml(docId)}-` : \"\"}${(id + 1).toString()}`;\n};\n\nconst renderFootnoteCaption: RendererRule = (tokens: Token[], index) =>\n `[${\n // number\n ((tokens[index].meta as FootNoteMeta).id + 1).toString()\n }${getIDSuffix(tokens, index)}]`;\n\nconst renderFootnoteRef: RendererRule = (tokens, index, options, env, self) => {\n const id = self.rules.footnote_anchor_name(tokens, index, options, env, self);\n const caption = self.rules.footnote_caption(tokens, index, options, env, self);\n\n // A separate anchor element allows scroll offset control via CSS\n // (e.g. `.footnote-anchor { scroll-margin-top: 80px; }` to leave\n // space for a fixed navbar), which isn't possible when id and href\n // share the same <a> element.\n return `<sup class=\"footnote-ref\"><a href=\"#footnote${id}\">${caption}</a><a class=\"footnote-anchor\" id=\"footnote-ref${id}${getIDSuffix(\n tokens,\n index,\n )}\"></a></sup>`;\n};\n\nconst renderFootnoteBlockOpen: RendererRule = (_tokens, _index, options) =>\n `\\\n<hr class=\"footnotes-sep\"${options.xhtmlOut ? \" /\" : \"\"}>\n<section class=\"footnotes\">\n<ol class=\"footnotes-list\">\n`;\n\nconst renderFootnoteBlockClose = (): string => `\\\n</ol>\n</section>\n`;\n\nconst renderFootnoteOpen: RendererRule = (tokens, index, options, env, self) =>\n `<li id=\"footnote${self.rules.footnote_anchor_name(\n tokens,\n index,\n options,\n env,\n self,\n )}${getIDSuffix(tokens, index)}\" class=\"footnote-item\">`;\n\nconst renderFootnoteClose: RendererRule = () => \"</li>\\n\";\n\nconst renderFootnoteAnchor: RendererRule = (tokens, index, options, env, self) =>\n ` <a href=\"#footnote-ref${self.rules.footnote_anchor_name(tokens, index, options, env, self)}${\n getIDSuffix(tokens, index)\n /* ↩ with escape code to prevent display as Apple Emoji on iOS */\n }\" class=\"footnote-backref\">\\u21A9\\uFE0E</a>`;\n\n// Process footnote block definition\nconst footnoteDef: BlockRule = (state: FootNoteStateBlock, startLine, endLine, silent) => {\n const start = state.bMarks[startLine] + state.tShift[startLine];\n const max = state.eMarks[startLine];\n let charCode: number;\n\n if (\n // line should be at least 5 chars - \"[^x]:\"\n start + 4 > max ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n if (\n // empty footnote label\n pos === start + 2 ||\n pos + 1 >= max ||\n state.src.charCodeAt(++pos) !== 58 /* : */\n )\n return false;\n\n if (silent) return true;\n\n pos++;\n\n (state.env.footnotes ??= {}).refs ??= {};\n\n const label = state.src.slice(start + 2, pos - 2);\n\n state.env.footnotes.refs[`:${label}`] = -1;\n\n const referenceOpenToken = state.push(\"footnote_reference_open\", \"\", 1);\n\n referenceOpenToken.meta = { label };\n referenceOpenToken.level = state.level++;\n\n const oldBMark = state.bMarks[startLine];\n const oldTShift = state.tShift[startLine];\n const oldSCount = state.sCount[startLine];\n const oldParentType = state.parentType;\n const posAfterColon = pos;\n const initial =\n state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);\n\n let offset = initial;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n\n if (charCode === 9 /* \\t */) offset += 4 - (offset % 4);\n else if (charCode === 32 /* space */) offset++;\n else break;\n\n pos++;\n }\n\n state.tShift[startLine] = pos - posAfterColon;\n state.sCount[startLine] = offset - initial;\n state.bMarks[startLine] = posAfterColon;\n state.blkIndent += 4;\n state.parentType = \"footnote\";\n\n if (state.sCount[startLine] < state.blkIndent) state.sCount[startLine] += state.blkIndent;\n\n state.md.block.tokenize(state, startLine, endLine);\n\n state.parentType = oldParentType;\n state.blkIndent -= 4;\n state.tShift[startLine] = oldTShift;\n state.sCount[startLine] = oldSCount;\n state.bMarks[startLine] = oldBMark;\n\n const referenceCloseToken = state.push(\"footnote_reference_close\", \"\", -1);\n\n referenceCloseToken.level = --state.level;\n\n return true;\n};\n\n// Process inline footnotes (^[...])\nconst footnoteInline: InlineRule = (state: FootNoteStateInline, silent) => {\n const max = state.posMax;\n const start = state.pos;\n\n if (\n start + 2 >= max ||\n state.src.charCodeAt(start) !== 94 /* ^ */ ||\n state.src.charCodeAt(start + 1) !== 91 /* [ */\n )\n return false;\n\n const labelEnd = state.md.helpers.parseLinkLabel(state, start + 1);\n\n // parser failed to find ']', so it’s not a valid note\n if (labelEnd < 0) return false;\n\n const labelStart = start + 2;\n\n /*\n * We found the end of the link, and know for a fact it’s a valid link;\n * so all that’s left to do is to call tokenizer.\n *\n */\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = ((state.env.footnotes ??= {}).list ??= []);\n const footnoteId = list.length;\n const tokens: Token[] = [];\n\n state.md.inline.parse(state.src.slice(labelStart, labelEnd), state.md, state.env, tokens);\n\n const refToken = state.push(\"footnote_ref\", \"\", 0);\n\n refToken.meta = { id: footnoteId };\n\n state.env.footnotes.list[footnoteId] = {\n content: state.src.slice(labelStart, labelEnd),\n tokens,\n };\n }\n\n state.pos = labelEnd + 1;\n state.posMax = max;\n\n return true;\n};\n\n// Process footnote references ([^...])\nconst footnoteRef: InlineRule = (state: FootNoteStateInline, silent) => {\n const start = state.pos;\n const max = state.posMax;\n\n if (\n // should be at least 4 chars - \"[^x]\"\n start + 3 > max ||\n !state.env.footnotes?.refs ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n let charCode: number;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */ || charCode === 10 /* \\n */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n // empty footnote labels\n if (pos === start + 2 || pos >= max) return false;\n\n pos++;\n\n const label = state.src.slice(start + 2, pos - 1);\n\n if (typeof state.env.footnotes.refs[`:${label}`] !== \"number\") return false;\n\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = (state.env.footnotes.list ??= []);\n const { refs } = state.env.footnotes;\n let footnoteId: number;\n\n if (refs[`:${label}`] < 0) {\n footnoteId = list.length;\n list[footnoteId] = { label, count: 0 };\n refs[`:${label}`] = footnoteId;\n } else {\n footnoteId = refs[`:${label}`];\n }\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const subId = list[footnoteId].count!;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n list[footnoteId].count! += 1;\n\n const refToken = state.push(\"footnote_ref\", \"\", 0);\n\n refToken.meta = { id: footnoteId, subId, label };\n }\n\n state.pos = pos;\n state.posMax = max;\n\n return true;\n};\n\n// Glue footnote tokens to end of token stream\nconst footnoteTail: CoreRule = (state: FootNoteStateCore) => {\n const refTokens: Record<string, Token[]> = {};\n\n let current: Token[], currentLabel: string;\n let isInsideRef = false;\n\n if (!state.env.footnotes?.list) {\n // If no footnotes list, remove all footnote reference tokens\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n isInsideRef = true;\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n isInsideRef = false;\n\n return false;\n }\n\n return !isInsideRef;\n });\n\n return;\n }\n\n const { list } = state.env.footnotes;\n\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n isInsideRef = true;\n current = [];\n currentLabel = (stateToken.meta as { label: string }).label;\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n isInsideRef = false;\n // prepend ':' to avoid conflict with Object.prototype members\n refTokens[`:${currentLabel}`] = current;\n\n return false;\n }\n if (isInsideRef) current.push(stateToken);\n\n return !isInsideRef;\n });\n\n const footnoteBlockOpenToken = new state.Token(\"footnote_block_open\", \"\", 1);\n\n state.tokens.push(footnoteBlockOpenToken);\n\n const listLength = list.length;\n\n for (let index = 0; index < listLength; index++) {\n const footnoteOpenToken = new state.Token(\"footnote_open\", \"\", 1);\n\n footnoteOpenToken.meta = { id: index, label: list[index].label };\n state.tokens.push(footnoteOpenToken);\n\n if (list[index].tokens) {\n const paragraphOpenToken = new state.Token(\"paragraph_open\", \"p\", 1);\n\n paragraphOpenToken.block = true;\n\n const inlineToken = new state.Token(\"inline\", \"\", 0);\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.children = list[index].tokens!;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.content = list[index].content!;\n\n const paragraphCloseToken = new state.Token(\"paragraph_close\", \"p\", -1);\n\n paragraphCloseToken.block = true;\n\n state.tokens.push(paragraphOpenToken, inlineToken, paragraphCloseToken);\n } else {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const tokens = refTokens[`:${list[index].label!}`];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (tokens) state.tokens.push(...tokens);\n }\n\n const lastParagraph =\n // oxlint-disable-next-line typescript/no-non-null-assertion\n state.tokens[state.tokens.length - 1].type === \"paragraph_close\" ? state.tokens.pop()! : null;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n for (let j = 0; j < (Number(list[index].count) > 0 ? list[index].count! : 1); j++) {\n const footnoteAnchorToken = new state.Token(\"footnote_anchor\", \"\", 0);\n\n footnoteAnchorToken.meta = {\n id: index,\n subId: j,\n label: list[index].label,\n };\n state.tokens.push(footnoteAnchorToken);\n }\n\n if (lastParagraph) state.tokens.push(lastParagraph);\n\n state.tokens.push(new state.Token(\"footnote_close\", \"\", -1));\n }\n\n state.tokens.push(new state.Token(\"footnote_block_close\", \"\", -1));\n};\n\nexport const footnote: PluginSimple = (md) => {\n // A second installation would append the footnote section twice.\n if (hasRule(md, \"footnoteTail\", \"core\")) return;\n\n md.renderer.rules.footnote_ref = renderFootnoteRef;\n md.renderer.rules.footnote_block_open = renderFootnoteBlockOpen;\n md.renderer.rules.footnote_block_close = renderFootnoteBlockClose;\n md.renderer.rules.footnote_open = renderFootnoteOpen;\n md.renderer.rules.footnote_close = renderFootnoteClose;\n md.renderer.rules.footnote_anchor = renderFootnoteAnchor;\n\n // helpers (only used in other rules, no tokens are attached to those)\n // helpers (only used in other rules, no tokens are attached to those)\n md.renderer.rules.footnote_caption = renderFootnoteCaption;\n md.renderer.rules.footnote_anchor_name = renderFootnoteAnchorName;\n\n md.block.ruler.before(\"reference\", \"footnoteDef\", footnoteDef, {\n alt: [\"paragraph\", \"reference\"],\n });\n md.inline.ruler.after(\"image\", \"footnoteInline\", footnoteInline);\n md.inline.ruler.after(\"footnoteInline\", \"footnote_ref\", footnoteRef);\n md.core.ruler.after(\"inline\", \"footnoteTail\", footnoteTail);\n};\n"],"mappings":"C,yRAEkC,OAAO,GAAG,MAAM,IAAAK,EAAE,GAAG,EAAE,WAAW,IAAI,OAAO,CAAC,CAAC,WAAW,IAAI,MAAM,CAAC,CAAC,WAAW,IAAI,MAAM,CAAC,CAAC,WAAW,IAAI,QAAQ,CAAC,CAAC,WAAW,IAAI,OAAO,EAAolBC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,OAAO,KAAK,EAAA,CAAG,KAAK,GAAG,EAAE,UA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MAAM,MAAM,iBAAkB,eAAgBlB,CAAW,EACnEkB,EAAG,KAAK,MAAM,MAAM,SAAU,eAAgBf,CAAY,EAC5D,C"}
|
|
1
|
+
{"version":3,"file":"cdn.umd.js","names":["escapeHtml","hasRule","factory","global","exports","r","c","isValidAttributeName","name","index","charCode","escapeAttribute","result","lastIndex","value","replacement","applyAttrs","attrs","className","token","getFootnoteSuffix","subId","getFootnoteAnchorName","docId","id","getFootnoteCaption","renderFootnoteCaption","tokens","renderFootnoteRef","caption","self","options","env","href","anchorClass","anchorId","renderFootnoteBlockOpen","separatorClass","listClass","renderFootnoteBlockClose","renderFootnoteOpen","renderFootnoteClose","renderFootnoteAnchor","text","footnoteDef","start","state","startLine","max","pos","silent","label","referenceOpenToken","oldBMark","oldTShift","oldSCount","oldParentType","posAfterColon","initial","offset","endLine","referenceCloseToken","createFootnoteRefToken","refToken","anchorName","suffix","createFootnoteInline","labelEnd","labelStart","footnoteId","createFootnoteRef","list","refs","createFootnoteTail","refTokens","refStack","refDepth","stateToken","footnoteBlockOpenToken","listLength","footnoteOpenToken","paragraphOpenToken","inlineToken","paragraphCloseToken","lastParagraph","j","footnoteAnchorToken","md"],"sources":["../../helper/dist/index.js","../src/utils.ts","../src/plugin.ts"],"sourcesContent":["const e=e=>{let t=e.split(`\n`),n=1/0;for(let r=0;r<t.length;r++){let i=t[r],{length:a}=i;for(let t=0;t<a;t++){let r=i.charCodeAt(t);if(r!==32&&r!==9){if(t===0)return e;t<n&&(n=t);break}}}return n===1/0?e:t.map(e=>e.slice(n)).join(`\n`)},t=/[-/\\\\^$*+?.()|[\\]{}]/g,n=String.raw`\\$&`,r=e=>e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`\"`,`"`).replaceAll(`'`,`'`),i=e=>e.replaceAll(t,n),a=(e,t,n,r)=>{let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-r>=4||i+3>a)return null;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return null;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return null;let l=e.src.slice(i,a);if(o===96&&l.includes(\"`\"))return null;let u=t,d=!1;for(;u++,!(u>=n||(i=s=e.bMarks[u]+e.tShift[u],a=e.eMarks[u],i<a&&e.sCount[u]<r));)if(e.src.charCodeAt(i)===o&&!(e.sCount[u]-r>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){d=!0;break}return u+ +!!d},o=/\\r\\n?|\\n/g,s=/\\\\(?<char>[ \\\\!\"#$%&'()*+,./:;<=>?@[\\]^_`{|}~-])/gu,c=(e,t,n)=>(n?[e[n].ruler]:[e.core.ruler,e.block.ruler,e.inline.ruler]).some(e=>e.__rules__.some(({name:e})=>e===t)),l=String.raw`\\^$.*+?()[]{}|`,u=[`.env`,`.env.*`,`.npmrc`,`.netrc`,`.git-credentials`,`id_rsa*`,`id_ed25519*`,`*.pem`,`*.key`,`*.p12`,`.git/**`,`**/.git/**`,`.ssh/**`,`**/.ssh/**`,`.aws/**`,`**/.aws/**`,`.azure/**`,`**/.azure/**`,`.kube/**`,`**/.kube/**`,`.docker/config.json`,`**/.docker/config.json`,`*.tfstate*`],d=e=>{let t=`^`,{length:n}=e;for(let r=0;r<n;r++){let n=e[r];n===`*`?e.charCodeAt(r+1)===42?(r++,e.charCodeAt(r+1)===47?(r++,t+=`(?:.*/)?`):t+=`.*`):t+=`[^/]*`:t+=n===`?`?`[^/]`:l.includes(n)?`\\\\${n}`:n}return RegExp(`${t}$`)},f=/* @__PURE__ */ new Map,p=e=>{let t=f.get(e);if(t)return t;let n=d(e);return f.set(e,n),n},m=(e,t)=>((e.global||e.sticky)&&(e.lastIndex=0),e.test(t)),h=(e,t=u)=>{let n=e.lastIndexOf(`/`),r=n===-1?e:e.slice(n+1);for(let n of t)if(typeof n==`string`){let t=n.includes(`/`)?e:r;if(p(n).test(t))return!0}else if(m(n,e)||m(n,r))return!0;return!1};export{o as NEWLINE_RE,s as UNESCAPE_RE,e as dedent,u as defaultSensitiveFiles,r as escapeHtml,i as escapeRegExp,c as hasRule,h as isSensitiveFile,a as scanFence};\n//# sourceMappingURL=index.js.map","import type { Token } from \"markdown-it\";\n\n/**\n * Check whether an attribute name can be safely emitted into HTML.\n *\n * Attribute names are interpolated as-is by `renderAttrs`, so names containing whitespace or quotes\n * could inject extra attributes. Such names are ignored.\n *\n * @param name - Attribute name / 属性名\n * @returns Whether the name is safe / 是否安全\n */\nconst isValidAttributeName = (name: string): boolean => {\n if (name.length === 0) return false;\n\n for (let index = 0; index < name.length; index++) {\n const charCode = name.charCodeAt(index);\n\n // control characters, whitespace, `\"`, `'`, `/`, `<`, `=`, `>`\n if (\n charCode <= 32 ||\n charCode === 34 /* \" */ ||\n charCode === 39 /* ' */ ||\n charCode === 47 /* / */ ||\n charCode === 60 /* < */ ||\n charCode === 61 /* = */ ||\n charCode === 62 /* > */\n )\n return false;\n }\n\n return true;\n};\n\n/**\n * Escape a value for a double-quoted HTML attribute.\n *\n * Every generated attribute is double-quoted, so apostrophes are kept as-is, matching how\n * markdown-it escapes `token.attrs`. `&`, `<`, `>` and `\"` are escaped so a caller-provided value\n * cannot break out of the attribute or inject markup.\n *\n * @param value - Raw attribute value / 原始属性值\n * @returns Escaped attribute value / 转义后的属性值\n */\nexport const escapeAttribute = (value: string): string => {\n let result = \"\";\n let lastIndex = 0;\n\n for (let index = 0; index < value.length; index++) {\n let replacement = \"\";\n\n switch (value.charCodeAt(index)) {\n case 34 /* \" */: {\n replacement = \""\";\n break;\n }\n case 38 /* & */: {\n replacement = \"&\";\n break;\n }\n case 60 /* < */: {\n replacement = \"<\";\n break;\n }\n case 62 /* > */: {\n replacement = \">\";\n break;\n }\n default: {\n break;\n }\n }\n\n if (replacement) {\n result += value.slice(lastIndex, index) + replacement;\n lastIndex = index + 1;\n }\n }\n\n return lastIndex === 0 ? value : result + value.slice(lastIndex);\n};\n\n/**\n * Apply user-provided attributes to a token.\n *\n * `class` is joined with the generated class, any other attribute overrides the generated value.\n * Invalid attribute names are ignored.\n *\n * @param token - Target token / 目标 token\n * @param attrs - Attributes to apply / 要应用的属性\n */\nexport const applyAttrs = (token: Token, attrs?: Record<string, string | number>): void => {\n if (!attrs) return;\n\n for (const [name, value] of Object.entries(attrs)) {\n if (!isValidAttributeName(name)) continue;\n\n if (name === \"class\") {\n const className = String(value).trim();\n\n if (className) token.attrJoin(\"class\", className);\n } else {\n token.attrSet(name, value);\n }\n }\n};\n\n/**\n * Get the id suffix of duplicated footnote references.\n *\n * @param subId - Index of duplicated references / 重复引用的索引\n * @returns `:${subId}` for duplicated references, otherwise an empty string / 重复引用时为\n * `:${subId}`,否则为空字符串\n */\nexport const getFootnoteSuffix = (subId?: number): string => ((subId ?? 0) > 0 ? `:${subId}` : \"\");\n\n/**\n * Get the anchor name used by generated ids and hrefs.\n *\n * The footnote number is generated by the plugin and always starts from `1`. When `docId` is\n * provided, it is prefixed so multiple documents on the same page do not share anchors. The values\n * are kept raw here and escaped by the renderer.\n *\n * @param docId - Document id from the render env / 渲染环境中的文档 id\n * @param id - Zero-based footnote index / 从 0 开始的脚注索引\n * @returns Raw anchor name / 原始锚点名\n */\nexport const getFootnoteAnchorName = (docId: string | null | undefined, id: number): string =>\n `${typeof docId === \"string\" ? `-${docId}-` : \"\"}${id + 1}`;\n\n/**\n * Get the caption of a footnote reference.\n *\n * @param id - Zero-based footnote index / 从 0 开始的脚注索引\n * @param subId - Index of duplicated references / 重复引用的索引\n * @returns Caption like `[1]` or `[1:1]` / 类似 `[1]` 或 `[1:1]` 的标题\n */\nexport const getFootnoteCaption = (id: number, subId?: number): string =>\n `[${id + 1}${getFootnoteSuffix(subId)}]`;\n","/**\n * Forked and modified from\n * https://github.com/markdown-it/markdown-it-footnote/blob/master/index.mjs\n */\n\nimport { escapeHtml, hasRule } from \"@mdit/helper\";\nimport type { BlockRule, CoreRule, InlineRule, PluginWithOptions } from \"@mdit/helper\";\nimport type { RendererRule, StateBlock, StateCore, StateInline, Token } from \"markdown-it\";\n\nimport type { FootnoteOptions } from \"./options.js\";\nimport type {\n FootnoteAnchorMeta,\n FootnoteBlockOpenMeta,\n FootnoteRefMeta,\n FootNoteEnv,\n FootNoteMeta,\n} from \"./types.js\";\nimport {\n applyAttrs,\n escapeAttribute,\n getFootnoteAnchorName,\n getFootnoteCaption,\n getFootnoteSuffix,\n} from \"./utils.js\";\n\ninterface FootNoteStateBlock extends StateBlock {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateInline extends StateInline {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateCore extends StateCore {\n env: FootNoteEnv;\n}\n\nconst REF_CLASS = \"footnote-ref\";\nconst ANCHOR_CLASS = \"footnote-anchor\";\nconst ITEM_CLASS = \"footnote-item\";\nconst BACK_REFERENCE_CLASS = \"footnote-backref\";\nconst SEPARATOR_CLASS = \"footnotes-sep\";\nconst CONTAINER_CLASS = \"footnotes\";\nconst LIST_CLASS = \"footnotes-list\";\n\n// `↩` with escape code to prevent display as Apple Emoji on iOS\nconst BACK_REFERENCE_TEXT = \"\\u21A9\\uFE0E\";\n\nconst renderFootnoteCaption: RendererRule = (tokens, index) => {\n const { id, subId } = tokens[index].meta as unknown as FootNoteMeta;\n\n return getFootnoteCaption(id, subId);\n};\n\nconst renderFootnoteRef: RendererRule = (tokens, index, options, env, self) => {\n const { href, anchorId, anchorClass } = tokens[index].meta as unknown as FootnoteRefMeta;\n // The caption goes through the `footnote_caption` rule so overriding it keeps working like in\n // previous versions. Renderer rules return HTML, so the caption is embedded as-is.\n const caption = self.rules.footnote_caption(tokens, index, options, env, self);\n\n // A separate anchor element allows scroll offset control via CSS\n // (e.g. `.footnote-anchor { scroll-margin-top: 80px; }` to leave\n // space for a fixed navbar), which isn't possible when id and href\n // share the same <a> element.\n return `<sup${self.renderAttrs(tokens[index])}><a href=\"${escapeAttribute(href)}\">${caption}</a><a class=\"${escapeAttribute(anchorClass)}\" id=\"${escapeAttribute(anchorId)}\"></a></sup>`;\n};\n\nconst renderFootnoteBlockOpen: RendererRule = (tokens, index, options, _env, self) => {\n const { separatorClass, listClass } = tokens[index].meta as unknown as FootnoteBlockOpenMeta;\n\n return `<hr class=\"${escapeAttribute(separatorClass)}\"${options.xhtmlOut ? \" /\" : \"\"}>\n<section${self.renderAttrs(tokens[index])}>\n<ol class=\"${escapeAttribute(listClass)}\">\n`;\n};\n\nconst renderFootnoteBlockClose = (): string => `\\\n</ol>\n</section>\n`;\n\nconst renderFootnoteOpen: RendererRule = (tokens, index, _options, _env, self) =>\n `<li${self.renderAttrs(tokens[index])}>`;\n\nconst renderFootnoteClose = (): string => \"</li>\\n\";\n\nconst renderFootnoteAnchor: RendererRule = (tokens, index, _options, _env, self) => {\n const { text } = tokens[index].meta as unknown as FootnoteAnchorMeta;\n\n return ` <a${self.renderAttrs(tokens[index])}>${escapeHtml(text)}</a>`;\n};\n\n// Process footnote block definition\nconst footnoteDef: BlockRule = (state: FootNoteStateBlock, startLine, endLine, silent) => {\n const start = state.bMarks[startLine] + state.tShift[startLine];\n const max = state.eMarks[startLine];\n let charCode: number;\n\n if (\n // line should be at least 5 chars - \"[^x]:\"\n start + 4 > max ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n if (\n // empty footnote label\n pos === start + 2 ||\n pos + 1 >= max ||\n state.src.charCodeAt(++pos) !== 58 /* : */\n )\n return false;\n\n if (silent) return true;\n\n pos++;\n\n (state.env.footnotes ??= {}).refs ??= {};\n\n const label = state.src.slice(start + 2, pos - 2);\n\n state.env.footnotes.refs[`:${label}`] = -1;\n\n const referenceOpenToken = state.push(\"footnote_reference_open\", \"\", 1);\n\n referenceOpenToken.meta = { label };\n referenceOpenToken.level = state.level++;\n\n const oldBMark = state.bMarks[startLine];\n const oldTShift = state.tShift[startLine];\n const oldSCount = state.sCount[startLine];\n const oldParentType = state.parentType;\n const posAfterColon = pos;\n const initial =\n state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);\n\n let offset = initial;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n\n if (charCode === 9 /* \\t */) offset += 4 - (offset % 4);\n else if (charCode === 32 /* space */) offset++;\n else break;\n\n pos++;\n }\n\n state.tShift[startLine] = pos - posAfterColon;\n state.sCount[startLine] = offset - initial;\n state.bMarks[startLine] = posAfterColon;\n state.blkIndent += 4;\n state.parentType = \"footnote\";\n\n if (state.sCount[startLine] < state.blkIndent) state.sCount[startLine] += state.blkIndent;\n\n state.md.block.tokenize(state, startLine, endLine);\n\n state.parentType = oldParentType;\n state.blkIndent -= 4;\n state.tShift[startLine] = oldTShift;\n state.sCount[startLine] = oldSCount;\n state.bMarks[startLine] = oldBMark;\n\n const referenceCloseToken = state.push(\"footnote_reference_close\", \"\", -1);\n\n referenceCloseToken.level = --state.level;\n\n return true;\n};\n\n// Create the footnote reference token from parsed data, resolved at parse time so renderers are\n// pure serializers.\nconst createFootnoteRefToken = (\n state: FootNoteStateInline,\n options: FootnoteOptions,\n id: number,\n subId?: number,\n label?: string,\n): void => {\n const refToken = state.push(\"footnote_ref\", \"\", 0);\n const anchorName = getFootnoteAnchorName(state.env.docId, id);\n const suffix = getFootnoteSuffix(subId);\n\n refToken.meta = {\n id,\n subId,\n label,\n href: `#footnote${anchorName}`,\n anchorId: `footnote-ref${anchorName}${suffix}`,\n anchorClass: ANCHOR_CLASS,\n } satisfies FootNoteMeta;\n\n refToken.attrJoin(\"class\", REF_CLASS);\n applyAttrs(refToken, options.refAttrs);\n};\n\n// Process inline footnotes (^[...])\nconst createFootnoteInline =\n (options: FootnoteOptions): InlineRule =>\n (state: FootNoteStateInline, silent) => {\n const max = state.posMax;\n const start = state.pos;\n\n if (\n start + 2 >= max ||\n state.src.charCodeAt(start) !== 94 /* ^ */ ||\n state.src.charCodeAt(start + 1) !== 91 /* [ */\n )\n return false;\n\n const labelEnd = state.md.helpers.parseLinkLabel(state, start + 1);\n\n // parser failed to find ']', so it’s not a valid note\n if (labelEnd < 0) return false;\n\n const labelStart = start + 2;\n\n /*\n * We found the end of the link, and know for a fact it’s a valid link;\n * so all that’s left to do is to call tokenizer.\n *\n */\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = ((state.env.footnotes ??= {}).list ??= []);\n const footnoteId = list.length;\n const tokens: Token[] = [];\n\n state.md.inline.parse(state.src.slice(labelStart, labelEnd), state.md, state.env, tokens);\n\n state.env.footnotes.list[footnoteId] = {\n content: state.src.slice(labelStart, labelEnd),\n tokens,\n };\n\n createFootnoteRefToken(state, options, footnoteId);\n }\n\n state.pos = labelEnd + 1;\n state.posMax = max;\n\n return true;\n };\n\n// Process footnote references ([^...])\nconst createFootnoteRef =\n (options: FootnoteOptions): InlineRule =>\n (state: FootNoteStateInline, silent) => {\n const start = state.pos;\n const max = state.posMax;\n\n if (\n // should be at least 4 chars - \"[^x]\"\n start + 3 > max ||\n !state.env.footnotes?.refs ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n let charCode: number;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */ || charCode === 10 /* \\n */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n // empty footnote labels\n if (pos === start + 2 || pos >= max) return false;\n\n pos++;\n\n const label = state.src.slice(start + 2, pos - 1);\n\n if (typeof state.env.footnotes.refs[`:${label}`] !== \"number\") return false;\n\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = (state.env.footnotes.list ??= []);\n const { refs } = state.env.footnotes;\n let footnoteId: number;\n\n if (refs[`:${label}`] < 0) {\n footnoteId = list.length;\n list[footnoteId] = { label, count: 0 };\n refs[`:${label}`] = footnoteId;\n } else {\n footnoteId = refs[`:${label}`];\n }\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const subId = list[footnoteId].count!;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n list[footnoteId].count! += 1;\n\n createFootnoteRefToken(state, options, footnoteId, subId, label);\n }\n\n state.pos = pos;\n state.posMax = max;\n\n return true;\n };\n\n// Glue footnote tokens to end of token stream\nconst createFootnoteTail =\n (options: FootnoteOptions): CoreRule =>\n (state: FootNoteStateCore) => {\n const refTokens: Record<string, Token[]> = {};\n const refStack: { label: string; tokens: Token[] }[] = [];\n\n if (!state.env.footnotes?.list) {\n let refDepth = 0;\n\n // If no footnotes list, remove all footnote reference tokens\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n refDepth++;\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n refDepth--;\n\n return false;\n }\n\n return refDepth === 0;\n });\n\n return;\n }\n\n const { list } = state.env.footnotes;\n\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n refStack.push({\n label: (stateToken.meta as { label: string }).label,\n tokens: [],\n });\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n // `footnoteDef` always pushes a balanced pair, so the stack has a matching entry here.\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const { label, tokens } = refStack.pop()!;\n\n // prepend ':' to avoid conflict with Object.prototype members\n refTokens[`:${label}`] = tokens;\n\n return false;\n }\n\n // Tokens outside any definition stay in the document.\n if (refStack.length === 0) return true;\n\n // Only the innermost definition collects the token, so a nested definition keeps its\n // content out of the outer note.\n refStack[refStack.length - 1].tokens.push(stateToken);\n\n return false;\n });\n\n const footnoteBlockOpenToken = new state.Token(\"footnote_block_open\", \"\", 1);\n\n footnoteBlockOpenToken.meta = {\n separatorClass: SEPARATOR_CLASS,\n listClass: LIST_CLASS,\n } satisfies FootnoteBlockOpenMeta;\n footnoteBlockOpenToken.attrJoin(\"class\", CONTAINER_CLASS);\n applyAttrs(footnoteBlockOpenToken, options.containerAttrs);\n\n state.tokens.push(footnoteBlockOpenToken);\n\n const listLength = list.length;\n\n for (let index = 0; index < listLength; index++) {\n const footnoteOpenToken = new state.Token(\"footnote_open\", \"\", 1);\n const anchorName = getFootnoteAnchorName(state.env.docId, index);\n\n footnoteOpenToken.meta = { id: index, label: list[index].label };\n footnoteOpenToken.attrSet(\"id\", `footnote${anchorName}`);\n footnoteOpenToken.attrJoin(\"class\", ITEM_CLASS);\n applyAttrs(footnoteOpenToken, options.itemAttrs);\n\n state.tokens.push(footnoteOpenToken);\n\n if (list[index].tokens) {\n const paragraphOpenToken = new state.Token(\"paragraph_open\", \"p\", 1);\n\n paragraphOpenToken.block = true;\n\n const inlineToken = new state.Token(\"inline\", \"\", 0);\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.children = list[index].tokens!;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.content = list[index].content!;\n\n const paragraphCloseToken = new state.Token(\"paragraph_close\", \"p\", -1);\n\n paragraphCloseToken.block = true;\n\n state.tokens.push(paragraphOpenToken, inlineToken, paragraphCloseToken);\n } else {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const tokens = refTokens[`:${list[index].label!}`];\n\n // A list entry may exist when the definition is not in this token stream, e.g. the\n // footnote reference sits in content rendered separately via `renderInline` (tab title).\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (tokens) state.tokens.push(...tokens);\n }\n\n const lastParagraph =\n state.tokens[state.tokens.length - 1].type === \"paragraph_close\"\n ? // oxlint-disable-next-line typescript/no-non-null-assertion\n state.tokens.pop()!\n : null;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n for (let j = 0; j < (Number(list[index].count) > 0 ? list[index].count! : 1); j++) {\n const footnoteAnchorToken = new state.Token(\"footnote_anchor\", \"\", 0);\n\n footnoteAnchorToken.meta = {\n id: index,\n subId: j,\n label: list[index].label,\n text: BACK_REFERENCE_TEXT,\n } satisfies FootNoteMeta;\n\n footnoteAnchorToken.attrSet(\"href\", `#footnote-ref${anchorName}${getFootnoteSuffix(j)}`);\n footnoteAnchorToken.attrJoin(\"class\", BACK_REFERENCE_CLASS);\n applyAttrs(footnoteAnchorToken, options.backrefAttrs);\n\n state.tokens.push(footnoteAnchorToken);\n }\n\n if (lastParagraph) state.tokens.push(lastParagraph);\n\n state.tokens.push(new state.Token(\"footnote_close\", \"\", -1));\n }\n\n state.tokens.push(new state.Token(\"footnote_block_close\", \"\", -1));\n };\n\nexport const footnote: PluginWithOptions<FootnoteOptions> = (md, options) => {\n // A second installation would append the footnote section twice.\n if (hasRule(md, \"footnoteTail\", \"core\")) return;\n\n md.renderer.rules.footnote_ref = renderFootnoteRef;\n md.renderer.rules.footnote_block_open = renderFootnoteBlockOpen;\n md.renderer.rules.footnote_block_close = renderFootnoteBlockClose;\n md.renderer.rules.footnote_open = renderFootnoteOpen;\n md.renderer.rules.footnote_close = renderFootnoteClose;\n md.renderer.rules.footnote_anchor = renderFootnoteAnchor;\n\n // The caption helper is still routed through `renderFootnoteRef`, so overriding it works.\n // `footnote_anchor_name` was an internal helper and is gone: anchor names are resolved while\n // parsing, so update the generated ids / hrefs on the tokens instead.\n md.renderer.rules.footnote_caption = renderFootnoteCaption;\n\n md.block.ruler.before(\"reference\", \"footnoteDef\", footnoteDef, {\n alt: [\"paragraph\", \"reference\"],\n });\n md.inline.ruler.after(\"image\", \"footnoteInline\", createFootnoteInline(options ?? {}));\n md.inline.ruler.after(\"footnoteInline\", \"footnote_ref\", createFootnoteRef(options ?? {}));\n md.core.ruler.after(\"inline\", \"footnoteTail\", createFootnoteTail(options ?? {}));\n};\n"],"mappings":"C,yRAEgC,OAAO,GAAG,MAAM,IAAAK,EAAE,GAAG,EAAE,WAAW,IAAI,OAAO,CAAC,CAAC,WAAW,IAAI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,116 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginWithOptions } from "@mdit/helper";
|
|
2
2
|
import { Env, Token } from "markdown-it";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Options of `@mdit/plugin-footnote`.
|
|
5
|
+
*
|
|
6
|
+
* `@mdit/plugin-footnote` 的选项。
|
|
7
|
+
*/
|
|
8
|
+
interface FootnoteOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Extra attributes of the `<sup>` element wrapping a footnote reference. `class` is merged with
|
|
11
|
+
* `footnote-ref`, any other attribute overrides the generated value. The links live on the inner
|
|
12
|
+
* `<a>` elements, which are rendered from the token metadata, so an `href` here changes neither
|
|
13
|
+
* link.
|
|
14
|
+
*
|
|
15
|
+
* 脚注引用外层 `<sup>` 元素的额外属性。`class` 会与 `footnote-ref` 合并,其他属性会覆盖生成的值。两个链接都由 token 元数据渲染到内部的 `<a>`
|
|
16
|
+
* 元素上,因此在这里写 `href` 不会改变任何一个链接。
|
|
17
|
+
*/
|
|
18
|
+
refAttrs?: Record<string, string | number>;
|
|
19
|
+
/**
|
|
20
|
+
* Extra attributes of the `<li>` element of each footnote item. `class` is merged with
|
|
21
|
+
* `footnote-item`, any other attribute overrides the generated value (including the generated
|
|
22
|
+
* `id`). Overriding `id` breaks the forward link from the reference marker unless `meta.href` of
|
|
23
|
+
* the `footnote_ref` tokens is updated as well.
|
|
24
|
+
*
|
|
25
|
+
* 每个脚注项 `<li>` 元素的额外属性。`class` 会与 `footnote-item` 合并,其他属性会覆盖生成的值(包括生成的 `id`)。覆盖 `id`
|
|
26
|
+
* 会断开引用标记指向脚注项的前向链接,除非同时更新 `footnote_ref` token 上的 `meta.href`。
|
|
27
|
+
*/
|
|
28
|
+
itemAttrs?: Record<string, string | number>;
|
|
29
|
+
/**
|
|
30
|
+
* Extra attributes of the back reference `<a>` element. `class` is merged with
|
|
31
|
+
* `footnote-backref`, any other attribute overrides the generated value (including the generated
|
|
32
|
+
* `href`). The forward link from the reference marker to the footnote item is unaffected.
|
|
33
|
+
*
|
|
34
|
+
* 返回引用 `<a>` 元素的额外属性。`class` 会与 `footnote-backref` 合并,其他属性会覆盖生成的值(包括生成的
|
|
35
|
+
* `href`)。引用标记指向脚注项的前向链接不受影响。
|
|
36
|
+
*/
|
|
37
|
+
backrefAttrs?: Record<string, string | number>;
|
|
38
|
+
/**
|
|
39
|
+
* Extra attributes of the `<section>` element wrapping the footnote list. `class` is merged with
|
|
40
|
+
* `footnotes`, any other attribute overrides the generated value.
|
|
41
|
+
*
|
|
42
|
+
* 包裹脚注列表的 `<section>` 元素的额外属性。`class` 会与 `footnotes` 合并,其他属性会覆盖生成的值。
|
|
43
|
+
*/
|
|
44
|
+
containerAttrs?: Record<string, string | number>;
|
|
45
|
+
}
|
|
46
|
+
export declare const footnote: PluginWithOptions<FootnoteOptions>;
|
|
47
|
+
/**
|
|
48
|
+
* Metadata carried by footnote tokens.
|
|
49
|
+
*
|
|
50
|
+
* Token renderers only serialize these fields (plus `token.attrs`), so changing them from a core
|
|
51
|
+
* rule updates the output without overriding the renderer rules.
|
|
52
|
+
*
|
|
53
|
+
* 脚注 token 携带的元数据。
|
|
54
|
+
*
|
|
55
|
+
* Token 渲染器只序列化这些字段(以及 `token.attrs`),因此可以在 core 规则中修改它们来调整输出,而无需覆盖渲染规则。
|
|
56
|
+
*/
|
|
57
|
+
interface FootNoteMeta {
|
|
58
|
+
/** Zero-based footnote index. / 从 0 开始的脚注索引。 */
|
|
59
|
+
id: number;
|
|
60
|
+
/** Index of duplicated references to the same footnote. / 同一脚注的重复引用索引。 */
|
|
61
|
+
subId?: number;
|
|
62
|
+
/** Source label of the footnote. / 脚注的原始标签。 */
|
|
63
|
+
label?: string;
|
|
64
|
+
/** Raw target of the reference link, e.g. `#footnote-1`. / 引用链接的原始目标,例如 `#footnote-1`。 */
|
|
65
|
+
href?: string;
|
|
66
|
+
/** Raw id of the scroll anchor inside the reference. / 引用内部滚动锚点的原始 id。 */
|
|
67
|
+
anchorId?: string;
|
|
68
|
+
/** Class of the scroll anchor inside the reference. / 引用内部滚动锚点的类名。 */
|
|
69
|
+
anchorClass?: string;
|
|
70
|
+
/** Text of the back reference link. / 返回引用链接的文本。 */
|
|
71
|
+
text?: string;
|
|
72
|
+
/** Class of the footnote separator. / 脚注分隔线的类名。 */
|
|
73
|
+
separatorClass?: string;
|
|
74
|
+
/** Class of the footnote list. / 脚注列表的类名。 */
|
|
75
|
+
listClass?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Footnote token with typed metadata.
|
|
79
|
+
*
|
|
80
|
+
* 带有类型化元数据的脚注 token。
|
|
81
|
+
*/
|
|
82
|
+
type FootNoteToken = Token & {
|
|
83
|
+
meta: FootNoteMeta;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Metadata of a `footnote_ref` token.
|
|
87
|
+
*
|
|
88
|
+
* `footnote_ref` token 的元数据。
|
|
89
|
+
*/
|
|
90
|
+
interface FootnoteRefMeta extends FootNoteMeta {
|
|
91
|
+
href: string;
|
|
92
|
+
anchorId: string;
|
|
93
|
+
anchorClass: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Metadata of a `footnote_anchor` token.
|
|
97
|
+
*
|
|
98
|
+
* `footnote_anchor` token 的元数据。
|
|
99
|
+
*/
|
|
100
|
+
interface FootnoteAnchorMeta extends FootNoteMeta {
|
|
101
|
+
subId: number;
|
|
102
|
+
text: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Metadata of a `footnote_block_open` token.
|
|
106
|
+
*
|
|
107
|
+
* `footnote_block_open` token 的元数据。
|
|
108
|
+
*/
|
|
109
|
+
interface FootnoteBlockOpenMeta {
|
|
110
|
+
/** Class of the footnote separator. / 脚注分隔线的类名。 */
|
|
111
|
+
separatorClass: string;
|
|
112
|
+
/** Class of the footnote list. / 脚注列表的类名。 */
|
|
113
|
+
listClass: string;
|
|
10
114
|
}
|
|
11
115
|
interface FootNoteEnv extends Env {
|
|
12
116
|
docId?: string;
|
|
@@ -21,5 +125,4 @@ interface FootNoteEnv extends Env {
|
|
|
21
125
|
}[];
|
|
22
126
|
};
|
|
23
127
|
}
|
|
24
|
-
export type { FootNoteEnv, FootNoteToken };
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
|
128
|
+
export type { FootNoteEnv, FootNoteMeta, FootNoteToken, FootnoteAnchorMeta, FootnoteBlockOpenMeta, FootnoteOptions, FootnoteRefMeta };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import{escapeHtml as e,hasRule as t}from"@mdit/helper";const n=(e
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
`,s=()=>`</ol>
|
|
1
|
+
import{escapeHtml as e,hasRule as t}from"@mdit/helper";const n=e=>{if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<=32||n===34||n===39||n===47||n===60||n===61||n===62)return!1}return!0},r=e=>{let t=``,n=0;for(let r=0;r<e.length;r++){let i=``;switch(e.charCodeAt(r)){case 34:i=`"`;break;case 38:i=`&`;break;case 60:i=`<`;break;case 62:i=`>`}i&&(t+=e.slice(n,r)+i,n=r+1)}return n===0?e:t+e.slice(n)},i=(e,t)=>{if(t){for(let[r,i]of Object.entries(t))if(n(r)){if(r===`class`){let t=String(i).trim();t&&e.attrJoin(`class`,t)}else e.attrSet(r,i)}}},a=e=>(e??0)>0?`:${e}`:``,o=(e,t)=>`${typeof e==`string`?`-${e}-`:``}${t+1}`,s=(e,t)=>`[${e+1}${a(t)}]`,c=(e,t)=>{let{id:n,subId:r}=e[t].meta;return s(n,r)},l=(e,t,n,i,a)=>{let{href:o,anchorId:s,anchorClass:c}=e[t].meta,l=a.rules.footnote_caption(e,t,n,i,a);return`<sup${a.renderAttrs(e[t])}><a href="${r(o)}">${l}</a><a class="${r(c)}" id="${r(s)}"></a></sup>`},u=(e,t,n,i,a)=>{let{separatorClass:o,listClass:s}=e[t].meta;return`<hr class="${r(o)}"${n.xhtmlOut?` /`:``}>
|
|
2
|
+
<section${a.renderAttrs(e[t])}>
|
|
3
|
+
<ol class="${r(s)}">
|
|
4
|
+
`},d=()=>`</ol>
|
|
6
5
|
</section>
|
|
7
|
-
`,
|
|
8
|
-
`,
|
|
6
|
+
`,f=(e,t,n,r,i)=>`<li${i.renderAttrs(e[t])}>`,p=()=>`</li>
|
|
7
|
+
`,m=(t,n,r,i,a)=>{let{text:o}=t[n].meta;return` <a${a.renderAttrs(t[n])}>${e(o)}</a>`},h=(e,t,n,r)=>{let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o;if(i+4>a||e.src.charCodeAt(i)!==91||e.src.charCodeAt(i+1)!==94)return!1;let s=i+2;for(;s<a;){if(o=e.src.charCodeAt(s),o===32)return!1;if(o===93)break;s++}if(s===i+2||s+1>=a||e.src.charCodeAt(++s)!==58)return!1;if(r)return!0;s++,(e.env.footnotes??={}).refs??={};let c=e.src.slice(i+2,s-2);e.env.footnotes.refs[`:${c}`]=-1;let l=e.push(`footnote_reference_open`,``,1);l.meta={label:c},l.level=e.level++;let u=e.bMarks[t],d=e.tShift[t],f=e.sCount[t],p=e.parentType,m=s,h=e.sCount[t]+s-(e.bMarks[t]+e.tShift[t]),g=h;for(;s<a;){if(o=e.src.charCodeAt(s),o===9)g+=4-g%4;else if(o===32)g++;else break;s++}e.tShift[t]=s-m,e.sCount[t]=g-h,e.bMarks[t]=m,e.blkIndent+=4,e.parentType=`footnote`,e.sCount[t]<e.blkIndent&&(e.sCount[t]+=e.blkIndent),e.md.block.tokenize(e,t,n),e.parentType=p,e.blkIndent-=4,e.tShift[t]=d,e.sCount[t]=f,e.bMarks[t]=u;let _=e.push(`footnote_reference_close`,``,-1);return _.level=--e.level,!0},g=(e,t,n,r,s)=>{let c=e.push(`footnote_ref`,``,0),l=o(e.env.docId,n),u=a(r);c.meta={id:n,subId:r,label:s,href:`#footnote${l}`,anchorId:`footnote-ref${l}${u}`,anchorClass:`footnote-anchor`},c.attrJoin(`class`,`footnote-ref`),i(c,t.refAttrs)},_=e=>(t,n)=>{let r=t.posMax,i=t.pos;if(i+2>=r||t.src.charCodeAt(i)!==94||t.src.charCodeAt(i+1)!==91)return!1;let a=t.md.helpers.parseLinkLabel(t,i+1);if(a<0)return!1;let o=i+2;if(!n){let n=((t.env.footnotes??={}).list??=[]).length,r=[];t.md.inline.parse(t.src.slice(o,a),t.md,t.env,r),t.env.footnotes.list[n]={content:t.src.slice(o,a),tokens:r},g(t,e,n)}return t.pos=a+1,t.posMax=r,!0},v=e=>(t,n)=>{let r=t.pos,i=t.posMax;if(r+3>i||!t.env.footnotes?.refs||t.src.charCodeAt(r)!==91||t.src.charCodeAt(r+1)!==94)return!1;let a=r+2,o;for(;a<i;){if(o=t.src.charCodeAt(a),o===32||o===10)return!1;if(o===93)break;a++}if(a===r+2||a>=i)return!1;a++;let s=t.src.slice(r+2,a-1);if(typeof t.env.footnotes.refs[`:${s}`]!=`number`)return!1;if(!n){let n=t.env.footnotes.list??=[],{refs:r}=t.env.footnotes,i;r[`:${s}`]<0?(i=n.length,n[i]={label:s,count:0},r[`:${s}`]=i):i=r[`:${s}`];let a=n[i].count;n[i].count+=1,g(t,e,i,a,s)}return t.pos=a,t.posMax=i,!0},y=e=>t=>{let n={},r=[];if(!t.env.footnotes?.list){let e=0;t.tokens=t.tokens.filter(t=>t.type===`footnote_reference_open`?(e++,!1):t.type===`footnote_reference_close`?(e--,!1):e===0);return}let{list:s}=t.env.footnotes;t.tokens=t.tokens.filter(e=>{if(e.type===`footnote_reference_open`)return r.push({label:e.meta.label,tokens:[]}),!1;if(e.type===`footnote_reference_close`){let{label:e,tokens:t}=r.pop();return n[`:${e}`]=t,!1}return r.length===0||(r[r.length-1].tokens.push(e),!1)});let c=new t.Token(`footnote_block_open`,``,1);c.meta={separatorClass:`footnotes-sep`,listClass:`footnotes-list`},c.attrJoin(`class`,`footnotes`),i(c,e.containerAttrs),t.tokens.push(c);let l=s.length;for(let r=0;r<l;r++){let c=new t.Token(`footnote_open`,``,1),l=o(t.env.docId,r);if(c.meta={id:r,label:s[r].label},c.attrSet(`id`,`footnote${l}`),c.attrJoin(`class`,`footnote-item`),i(c,e.itemAttrs),t.tokens.push(c),s[r].tokens){let e=new t.Token(`paragraph_open`,`p`,1);e.block=!0;let n=new t.Token(`inline`,``,0);n.children=s[r].tokens,n.content=s[r].content;let i=new t.Token(`paragraph_close`,`p`,-1);i.block=!0,t.tokens.push(e,n,i)}else{let e=n[`:${s[r].label}`];e&&t.tokens.push(...e)}let u=t.tokens[t.tokens.length-1].type===`paragraph_close`?t.tokens.pop():null;for(let n=0;n<(Number(s[r].count)>0?s[r].count:1);n++){let o=new t.Token(`footnote_anchor`,``,0);o.meta={id:r,subId:n,label:s[r].label,text:`↩︎`},o.attrSet(`href`,`#footnote-ref${l}${a(n)}`),o.attrJoin(`class`,`footnote-backref`),i(o,e.backrefAttrs),t.tokens.push(o)}u&&t.tokens.push(u),t.tokens.push(new t.Token(`footnote_close`,``,-1))}t.tokens.push(new t.Token(`footnote_block_close`,``,-1))},b=(e,n)=>{t(e,`footnoteTail`,`core`)||(e.renderer.rules.footnote_ref=l,e.renderer.rules.footnote_block_open=u,e.renderer.rules.footnote_block_close=d,e.renderer.rules.footnote_open=f,e.renderer.rules.footnote_close=p,e.renderer.rules.footnote_anchor=m,e.renderer.rules.footnote_caption=c,e.block.ruler.before(`reference`,`footnoteDef`,h,{alt:[`paragraph`,`reference`]}),e.inline.ruler.after(`image`,`footnoteInline`,_(n??{})),e.inline.ruler.after(`footnoteInline`,`footnote_ref`,v(n??{})),e.core.ruler.after(`inline`,`footnoteTail`,y(n??{})))};export{b as footnote};
|
|
9
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getIDSuffix","tokens","index","subId","renderFootnoteAnchorName","docId","env","id","escapeHtml","renderFootnoteCaption","renderFootnoteRef","self","options","renderFootnoteBlockOpen","renderFootnoteBlockClose","renderFootnoteOpen","renderFootnoteClose","renderFootnoteAnchor","footnoteDef","start","state","startLine","max","charCode","pos","silent","label","referenceOpenToken","oldBMark","oldTShift","oldSCount","oldParentType","posAfterColon","initial","offset","endLine","referenceCloseToken","footnoteInline","labelEnd","labelStart","footnoteId","refToken","footnoteRef","list","refs","footnoteTail","refTokens","current","currentLabel","isInsideRef","stateToken","footnoteBlockOpenToken","listLength","footnoteOpenToken","paragraphOpenToken","inlineToken","paragraphCloseToken","lastParagraph","j","footnoteAnchorToken","footnote","hasRule","md"],"sources":["../src/plugin.ts"],"sourcesContent":["/** Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.mjs */\n\nimport { escapeHtml, hasRule } from \"@mdit/helper\";\nimport type { BlockRule, CoreRule, InlineRule, PluginSimple } from \"@mdit/helper\";\nimport type { RendererRule, StateBlock, StateCore, StateInline, Token } from \"markdown-it\";\n\nimport type { FootNoteEnv, FootNoteToken } from \"./types.js\";\n\ninterface FootNoteStateBlock extends StateBlock {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateInline extends StateInline {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateCore extends StateCore {\n env: FootNoteEnv;\n}\n\ntype FootNoteMeta = FootNoteToken[\"meta\"];\n\nconst getIDSuffix = (tokens: Token[], index: number): string => {\n // add suffix when multiple id was found\n const { subId } = tokens[index].meta as FootNoteMeta;\n\n return subId > 0 ? `:${subId}` : \"\";\n};\n\nconst renderFootnoteAnchorName: RendererRule = (tokens, index, _options, env) => {\n // prefix\n const docId = env?.docId;\n // increasing id\n const id = (tokens[index].meta as FootNoteMeta).id;\n\n // `docId` comes from the caller-provided `env` and is interpolated into `id` / `href`\n // attributes, so it must be escaped to prevent attribute injection.\n return `${typeof docId === \"string\" ? `-${escapeHtml(docId)}-` : \"\"}${(id + 1).toString()}`;\n};\n\nconst renderFootnoteCaption: RendererRule = (tokens: Token[], index) =>\n `[${\n // number\n ((tokens[index].meta as FootNoteMeta).id + 1).toString()\n }${getIDSuffix(tokens, index)}]`;\n\nconst renderFootnoteRef: RendererRule = (tokens, index, options, env, self) => {\n const id = self.rules.footnote_anchor_name(tokens, index, options, env, self);\n const caption = self.rules.footnote_caption(tokens, index, options, env, self);\n\n // A separate anchor element allows scroll offset control via CSS\n // (e.g. `.footnote-anchor { scroll-margin-top: 80px; }` to leave\n // space for a fixed navbar), which isn't possible when id and href\n // share the same <a> element.\n return `<sup class=\"footnote-ref\"><a href=\"#footnote${id}\">${caption}</a><a class=\"footnote-anchor\" id=\"footnote-ref${id}${getIDSuffix(\n tokens,\n index,\n )}\"></a></sup>`;\n};\n\nconst renderFootnoteBlockOpen: RendererRule = (_tokens, _index, options) =>\n `\\\n<hr class=\"footnotes-sep\"${options.xhtmlOut ? \" /\" : \"\"}>\n<section class=\"footnotes\">\n<ol class=\"footnotes-list\">\n`;\n\nconst renderFootnoteBlockClose = (): string => `\\\n</ol>\n</section>\n`;\n\nconst renderFootnoteOpen: RendererRule = (tokens, index, options, env, self) =>\n `<li id=\"footnote${self.rules.footnote_anchor_name(\n tokens,\n index,\n options,\n env,\n self,\n )}${getIDSuffix(tokens, index)}\" class=\"footnote-item\">`;\n\nconst renderFootnoteClose: RendererRule = () => \"</li>\\n\";\n\nconst renderFootnoteAnchor: RendererRule = (tokens, index, options, env, self) =>\n ` <a href=\"#footnote-ref${self.rules.footnote_anchor_name(tokens, index, options, env, self)}${\n getIDSuffix(tokens, index)\n /* ↩ with escape code to prevent display as Apple Emoji on iOS */\n }\" class=\"footnote-backref\">\\u21A9\\uFE0E</a>`;\n\n// Process footnote block definition\nconst footnoteDef: BlockRule = (state: FootNoteStateBlock, startLine, endLine, silent) => {\n const start = state.bMarks[startLine] + state.tShift[startLine];\n const max = state.eMarks[startLine];\n let charCode: number;\n\n if (\n // line should be at least 5 chars - \"[^x]:\"\n start + 4 > max ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n if (\n // empty footnote label\n pos === start + 2 ||\n pos + 1 >= max ||\n state.src.charCodeAt(++pos) !== 58 /* : */\n )\n return false;\n\n if (silent) return true;\n\n pos++;\n\n (state.env.footnotes ??= {}).refs ??= {};\n\n const label = state.src.slice(start + 2, pos - 2);\n\n state.env.footnotes.refs[`:${label}`] = -1;\n\n const referenceOpenToken = state.push(\"footnote_reference_open\", \"\", 1);\n\n referenceOpenToken.meta = { label };\n referenceOpenToken.level = state.level++;\n\n const oldBMark = state.bMarks[startLine];\n const oldTShift = state.tShift[startLine];\n const oldSCount = state.sCount[startLine];\n const oldParentType = state.parentType;\n const posAfterColon = pos;\n const initial =\n state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);\n\n let offset = initial;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n\n if (charCode === 9 /* \\t */) offset += 4 - (offset % 4);\n else if (charCode === 32 /* space */) offset++;\n else break;\n\n pos++;\n }\n\n state.tShift[startLine] = pos - posAfterColon;\n state.sCount[startLine] = offset - initial;\n state.bMarks[startLine] = posAfterColon;\n state.blkIndent += 4;\n state.parentType = \"footnote\";\n\n if (state.sCount[startLine] < state.blkIndent) state.sCount[startLine] += state.blkIndent;\n\n state.md.block.tokenize(state, startLine, endLine);\n\n state.parentType = oldParentType;\n state.blkIndent -= 4;\n state.tShift[startLine] = oldTShift;\n state.sCount[startLine] = oldSCount;\n state.bMarks[startLine] = oldBMark;\n\n const referenceCloseToken = state.push(\"footnote_reference_close\", \"\", -1);\n\n referenceCloseToken.level = --state.level;\n\n return true;\n};\n\n// Process inline footnotes (^[...])\nconst footnoteInline: InlineRule = (state: FootNoteStateInline, silent) => {\n const max = state.posMax;\n const start = state.pos;\n\n if (\n start + 2 >= max ||\n state.src.charCodeAt(start) !== 94 /* ^ */ ||\n state.src.charCodeAt(start + 1) !== 91 /* [ */\n )\n return false;\n\n const labelEnd = state.md.helpers.parseLinkLabel(state, start + 1);\n\n // parser failed to find ']', so it’s not a valid note\n if (labelEnd < 0) return false;\n\n const labelStart = start + 2;\n\n /*\n * We found the end of the link, and know for a fact it’s a valid link;\n * so all that’s left to do is to call tokenizer.\n *\n */\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = ((state.env.footnotes ??= {}).list ??= []);\n const footnoteId = list.length;\n const tokens: Token[] = [];\n\n state.md.inline.parse(state.src.slice(labelStart, labelEnd), state.md, state.env, tokens);\n\n const refToken = state.push(\"footnote_ref\", \"\", 0);\n\n refToken.meta = { id: footnoteId };\n\n state.env.footnotes.list[footnoteId] = {\n content: state.src.slice(labelStart, labelEnd),\n tokens,\n };\n }\n\n state.pos = labelEnd + 1;\n state.posMax = max;\n\n return true;\n};\n\n// Process footnote references ([^...])\nconst footnoteRef: InlineRule = (state: FootNoteStateInline, silent) => {\n const start = state.pos;\n const max = state.posMax;\n\n if (\n // should be at least 4 chars - \"[^x]\"\n start + 3 > max ||\n !state.env.footnotes?.refs ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n let charCode: number;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */ || charCode === 10 /* \\n */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n // empty footnote labels\n if (pos === start + 2 || pos >= max) return false;\n\n pos++;\n\n const label = state.src.slice(start + 2, pos - 1);\n\n if (typeof state.env.footnotes.refs[`:${label}`] !== \"number\") return false;\n\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = (state.env.footnotes.list ??= []);\n const { refs } = state.env.footnotes;\n let footnoteId: number;\n\n if (refs[`:${label}`] < 0) {\n footnoteId = list.length;\n list[footnoteId] = { label, count: 0 };\n refs[`:${label}`] = footnoteId;\n } else {\n footnoteId = refs[`:${label}`];\n }\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const subId = list[footnoteId].count!;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n list[footnoteId].count! += 1;\n\n const refToken = state.push(\"footnote_ref\", \"\", 0);\n\n refToken.meta = { id: footnoteId, subId, label };\n }\n\n state.pos = pos;\n state.posMax = max;\n\n return true;\n};\n\n// Glue footnote tokens to end of token stream\nconst footnoteTail: CoreRule = (state: FootNoteStateCore) => {\n const refTokens: Record<string, Token[]> = {};\n\n let current: Token[], currentLabel: string;\n let isInsideRef = false;\n\n if (!state.env.footnotes?.list) {\n // If no footnotes list, remove all footnote reference tokens\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n isInsideRef = true;\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n isInsideRef = false;\n\n return false;\n }\n\n return !isInsideRef;\n });\n\n return;\n }\n\n const { list } = state.env.footnotes;\n\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n isInsideRef = true;\n current = [];\n currentLabel = (stateToken.meta as { label: string }).label;\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n isInsideRef = false;\n // prepend ':' to avoid conflict with Object.prototype members\n refTokens[`:${currentLabel}`] = current;\n\n return false;\n }\n if (isInsideRef) current.push(stateToken);\n\n return !isInsideRef;\n });\n\n const footnoteBlockOpenToken = new state.Token(\"footnote_block_open\", \"\", 1);\n\n state.tokens.push(footnoteBlockOpenToken);\n\n const listLength = list.length;\n\n for (let index = 0; index < listLength; index++) {\n const footnoteOpenToken = new state.Token(\"footnote_open\", \"\", 1);\n\n footnoteOpenToken.meta = { id: index, label: list[index].label };\n state.tokens.push(footnoteOpenToken);\n\n if (list[index].tokens) {\n const paragraphOpenToken = new state.Token(\"paragraph_open\", \"p\", 1);\n\n paragraphOpenToken.block = true;\n\n const inlineToken = new state.Token(\"inline\", \"\", 0);\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.children = list[index].tokens!;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.content = list[index].content!;\n\n const paragraphCloseToken = new state.Token(\"paragraph_close\", \"p\", -1);\n\n paragraphCloseToken.block = true;\n\n state.tokens.push(paragraphOpenToken, inlineToken, paragraphCloseToken);\n } else {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const tokens = refTokens[`:${list[index].label!}`];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (tokens) state.tokens.push(...tokens);\n }\n\n const lastParagraph =\n // oxlint-disable-next-line typescript/no-non-null-assertion\n state.tokens[state.tokens.length - 1].type === \"paragraph_close\" ? state.tokens.pop()! : null;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n for (let j = 0; j < (Number(list[index].count) > 0 ? list[index].count! : 1); j++) {\n const footnoteAnchorToken = new state.Token(\"footnote_anchor\", \"\", 0);\n\n footnoteAnchorToken.meta = {\n id: index,\n subId: j,\n label: list[index].label,\n };\n state.tokens.push(footnoteAnchorToken);\n }\n\n if (lastParagraph) state.tokens.push(lastParagraph);\n\n state.tokens.push(new state.Token(\"footnote_close\", \"\", -1));\n }\n\n state.tokens.push(new state.Token(\"footnote_block_close\", \"\", -1));\n};\n\nexport const footnote: PluginSimple = (md) => {\n // A second installation would append the footnote section twice.\n if (hasRule(md, \"footnoteTail\", \"core\")) return;\n\n md.renderer.rules.footnote_ref = renderFootnoteRef;\n md.renderer.rules.footnote_block_open = renderFootnoteBlockOpen;\n md.renderer.rules.footnote_block_close = renderFootnoteBlockClose;\n md.renderer.rules.footnote_open = renderFootnoteOpen;\n md.renderer.rules.footnote_close = renderFootnoteClose;\n md.renderer.rules.footnote_anchor = renderFootnoteAnchor;\n\n // helpers (only used in other rules, no tokens are attached to those)\n // helpers (only used in other rules, no tokens are attached to those)\n md.renderer.rules.footnote_caption = renderFootnoteCaption;\n md.renderer.rules.footnote_anchor_name = renderFootnoteAnchorName;\n\n md.block.ruler.before(\"reference\", \"footnoteDef\", footnoteDef, {\n alt: [\"paragraph\", \"reference\"],\n });\n md.inline.ruler.after(\"image\", \"footnoteInline\", footnoteInline);\n md.inline.ruler.after(\"footnoteInline\", \"footnote_ref\", footnoteRef);\n md.core.ruler.after(\"inline\", \"footnoteTail\", footnoteTail);\n};\n"],"mappings":"A,uDAsBA,MAAMA,GAAe,EAAiB,IAA0B,CAE9D,GAAM,CAAE,SAAUC,EAAOC,EAAM,CAAC,KAEhC,OAAOC,EAAQ,EAAI,IAAIA,IAAU,EACnC,EAEMC,GAA0C,EAAQ,EAAO,EAAU,IAAQ,CAE/E,IAAMC,EAAQC,GAAK,MAEbC,EAAMN,EAAOC,EAAM,CAAC,KAAsB,GAIhD,MAAO,GAAG,OAAOG,GAAU,SAAW,IAAIG,EAAWH,CAAK,EAAE,GAAK,MAAME,EAAK,EAAA,CAAG,SAAS,GAC1F,EAEME,GAAuC,EAAiB,IAC5D,KAEIR,EAAOC,EAAM,CAAC,KAAsB,GAAK,EAAA,CAAG,SAAS,IACtDF,EAAYC,EAAQC,CAAK,EAAE,GAE1BQ,GAAmC,EAAQ,EAAO,EAAS,EAAK,IAAS,CAC7E,IAAMH,EAAKI,EAAK,MAAM,qBAAqBV,EAAQC,EAAOU,EAASN,EAAKK,CAAI,EAO5E,MAAO,+CAA+CJ,EAAG,IANzCI,EAAK,MAAM,iBAAiBV,EAAQC,EAAOU,EAASN,EAAKK,CAMN,EAAE,iDAAiDJ,IAAKP,EACzHC,EACAC,CACF,EAAE,aACJ,EAEMW,GAAyC,EAAS,EAAQ,IAC9D;2BACyBD,EAAQ,SAAW,KAAO,GAAG;;;EAKl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MAAM,qBAAuBC,EACzC,EAAG,SAAS,MAAM,cAAgBC,EAClC,EAAG,SAAS,MAAM,eAAiBC,EACnC,EAAG,SAAS,MAAM,gBAAkBC,EAIpC,EAAG,SAAS,MAAM,iBAAmBR,EACrC,EAAG,SAAS,MAAM,qBAAuBL,EAEzC0D,EAAG,MAAM,MAAM,OAAO,YAAa,cAAe5C,EAAa,CAC7D,IAAK,CAAC,YAAa,WAAW,CAChC,CAAC,EACD4C,EAAG,OAAO,MAAM,MAAM,QAAS,iBAAkBzB,CAAc,EAC/DyB,EAAG,OAAO,MAAM,MAAM,iBAAkB,eAAgBpB,CAAW,EACnEoB,EAAG,KAAK,MAAM,MAAM,SAAU,eAAgBjB,CAAY,EAC5D,E"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isValidAttributeName","name","index","charCode","escapeAttribute","result","lastIndex","value","replacement","applyAttrs","attrs","className","token","getFootnoteSuffix","subId","getFootnoteAnchorName","docId","id","getFootnoteCaption","renderFootnoteCaption","tokens","renderFootnoteRef","caption","self","options","env","href","anchorClass","anchorId","renderFootnoteBlockOpen","separatorClass","listClass","renderFootnoteBlockClose","renderFootnoteOpen","renderFootnoteClose","renderFootnoteAnchor","escapeHtml","text","footnoteDef","start","state","startLine","max","pos","silent","label","referenceOpenToken","oldBMark","oldTShift","oldSCount","oldParentType","posAfterColon","initial","offset","endLine","referenceCloseToken","createFootnoteRefToken","refToken","anchorName","suffix","createFootnoteInline","labelEnd","labelStart","footnoteId","createFootnoteRef","list","refs","createFootnoteTail","refTokens","refStack","refDepth","stateToken","footnoteBlockOpenToken","listLength","footnoteOpenToken","paragraphOpenToken","inlineToken","paragraphCloseToken","lastParagraph","j","footnoteAnchorToken","footnote","hasRule","md"],"sources":["../src/utils.ts","../src/plugin.ts"],"sourcesContent":["import type { Token } from \"markdown-it\";\n\n/**\n * Check whether an attribute name can be safely emitted into HTML.\n *\n * Attribute names are interpolated as-is by `renderAttrs`, so names containing whitespace or quotes\n * could inject extra attributes. Such names are ignored.\n *\n * @param name - Attribute name / 属性名\n * @returns Whether the name is safe / 是否安全\n */\nconst isValidAttributeName = (name: string): boolean => {\n if (name.length === 0) return false;\n\n for (let index = 0; index < name.length; index++) {\n const charCode = name.charCodeAt(index);\n\n // control characters, whitespace, `\"`, `'`, `/`, `<`, `=`, `>`\n if (\n charCode <= 32 ||\n charCode === 34 /* \" */ ||\n charCode === 39 /* ' */ ||\n charCode === 47 /* / */ ||\n charCode === 60 /* < */ ||\n charCode === 61 /* = */ ||\n charCode === 62 /* > */\n )\n return false;\n }\n\n return true;\n};\n\n/**\n * Escape a value for a double-quoted HTML attribute.\n *\n * Every generated attribute is double-quoted, so apostrophes are kept as-is, matching how\n * markdown-it escapes `token.attrs`. `&`, `<`, `>` and `\"` are escaped so a caller-provided value\n * cannot break out of the attribute or inject markup.\n *\n * @param value - Raw attribute value / 原始属性值\n * @returns Escaped attribute value / 转义后的属性值\n */\nexport const escapeAttribute = (value: string): string => {\n let result = \"\";\n let lastIndex = 0;\n\n for (let index = 0; index < value.length; index++) {\n let replacement = \"\";\n\n switch (value.charCodeAt(index)) {\n case 34 /* \" */: {\n replacement = \""\";\n break;\n }\n case 38 /* & */: {\n replacement = \"&\";\n break;\n }\n case 60 /* < */: {\n replacement = \"<\";\n break;\n }\n case 62 /* > */: {\n replacement = \">\";\n break;\n }\n default: {\n break;\n }\n }\n\n if (replacement) {\n result += value.slice(lastIndex, index) + replacement;\n lastIndex = index + 1;\n }\n }\n\n return lastIndex === 0 ? value : result + value.slice(lastIndex);\n};\n\n/**\n * Apply user-provided attributes to a token.\n *\n * `class` is joined with the generated class, any other attribute overrides the generated value.\n * Invalid attribute names are ignored.\n *\n * @param token - Target token / 目标 token\n * @param attrs - Attributes to apply / 要应用的属性\n */\nexport const applyAttrs = (token: Token, attrs?: Record<string, string | number>): void => {\n if (!attrs) return;\n\n for (const [name, value] of Object.entries(attrs)) {\n if (!isValidAttributeName(name)) continue;\n\n if (name === \"class\") {\n const className = String(value).trim();\n\n if (className) token.attrJoin(\"class\", className);\n } else {\n token.attrSet(name, value);\n }\n }\n};\n\n/**\n * Get the id suffix of duplicated footnote references.\n *\n * @param subId - Index of duplicated references / 重复引用的索引\n * @returns `:${subId}` for duplicated references, otherwise an empty string / 重复引用时为\n * `:${subId}`,否则为空字符串\n */\nexport const getFootnoteSuffix = (subId?: number): string => ((subId ?? 0) > 0 ? `:${subId}` : \"\");\n\n/**\n * Get the anchor name used by generated ids and hrefs.\n *\n * The footnote number is generated by the plugin and always starts from `1`. When `docId` is\n * provided, it is prefixed so multiple documents on the same page do not share anchors. The values\n * are kept raw here and escaped by the renderer.\n *\n * @param docId - Document id from the render env / 渲染环境中的文档 id\n * @param id - Zero-based footnote index / 从 0 开始的脚注索引\n * @returns Raw anchor name / 原始锚点名\n */\nexport const getFootnoteAnchorName = (docId: string | null | undefined, id: number): string =>\n `${typeof docId === \"string\" ? `-${docId}-` : \"\"}${id + 1}`;\n\n/**\n * Get the caption of a footnote reference.\n *\n * @param id - Zero-based footnote index / 从 0 开始的脚注索引\n * @param subId - Index of duplicated references / 重复引用的索引\n * @returns Caption like `[1]` or `[1:1]` / 类似 `[1]` 或 `[1:1]` 的标题\n */\nexport const getFootnoteCaption = (id: number, subId?: number): string =>\n `[${id + 1}${getFootnoteSuffix(subId)}]`;\n","/**\n * Forked and modified from\n * https://github.com/markdown-it/markdown-it-footnote/blob/master/index.mjs\n */\n\nimport { escapeHtml, hasRule } from \"@mdit/helper\";\nimport type { BlockRule, CoreRule, InlineRule, PluginWithOptions } from \"@mdit/helper\";\nimport type { RendererRule, StateBlock, StateCore, StateInline, Token } from \"markdown-it\";\n\nimport type { FootnoteOptions } from \"./options.js\";\nimport type {\n FootnoteAnchorMeta,\n FootnoteBlockOpenMeta,\n FootnoteRefMeta,\n FootNoteEnv,\n FootNoteMeta,\n} from \"./types.js\";\nimport {\n applyAttrs,\n escapeAttribute,\n getFootnoteAnchorName,\n getFootnoteCaption,\n getFootnoteSuffix,\n} from \"./utils.js\";\n\ninterface FootNoteStateBlock extends StateBlock {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateInline extends StateInline {\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateCore extends StateCore {\n env: FootNoteEnv;\n}\n\nconst REF_CLASS = \"footnote-ref\";\nconst ANCHOR_CLASS = \"footnote-anchor\";\nconst ITEM_CLASS = \"footnote-item\";\nconst BACK_REFERENCE_CLASS = \"footnote-backref\";\nconst SEPARATOR_CLASS = \"footnotes-sep\";\nconst CONTAINER_CLASS = \"footnotes\";\nconst LIST_CLASS = \"footnotes-list\";\n\n// `↩` with escape code to prevent display as Apple Emoji on iOS\nconst BACK_REFERENCE_TEXT = \"\\u21A9\\uFE0E\";\n\nconst renderFootnoteCaption: RendererRule = (tokens, index) => {\n const { id, subId } = tokens[index].meta as unknown as FootNoteMeta;\n\n return getFootnoteCaption(id, subId);\n};\n\nconst renderFootnoteRef: RendererRule = (tokens, index, options, env, self) => {\n const { href, anchorId, anchorClass } = tokens[index].meta as unknown as FootnoteRefMeta;\n // The caption goes through the `footnote_caption` rule so overriding it keeps working like in\n // previous versions. Renderer rules return HTML, so the caption is embedded as-is.\n const caption = self.rules.footnote_caption(tokens, index, options, env, self);\n\n // A separate anchor element allows scroll offset control via CSS\n // (e.g. `.footnote-anchor { scroll-margin-top: 80px; }` to leave\n // space for a fixed navbar), which isn't possible when id and href\n // share the same <a> element.\n return `<sup${self.renderAttrs(tokens[index])}><a href=\"${escapeAttribute(href)}\">${caption}</a><a class=\"${escapeAttribute(anchorClass)}\" id=\"${escapeAttribute(anchorId)}\"></a></sup>`;\n};\n\nconst renderFootnoteBlockOpen: RendererRule = (tokens, index, options, _env, self) => {\n const { separatorClass, listClass } = tokens[index].meta as unknown as FootnoteBlockOpenMeta;\n\n return `<hr class=\"${escapeAttribute(separatorClass)}\"${options.xhtmlOut ? \" /\" : \"\"}>\n<section${self.renderAttrs(tokens[index])}>\n<ol class=\"${escapeAttribute(listClass)}\">\n`;\n};\n\nconst renderFootnoteBlockClose = (): string => `\\\n</ol>\n</section>\n`;\n\nconst renderFootnoteOpen: RendererRule = (tokens, index, _options, _env, self) =>\n `<li${self.renderAttrs(tokens[index])}>`;\n\nconst renderFootnoteClose = (): string => \"</li>\\n\";\n\nconst renderFootnoteAnchor: RendererRule = (tokens, index, _options, _env, self) => {\n const { text } = tokens[index].meta as unknown as FootnoteAnchorMeta;\n\n return ` <a${self.renderAttrs(tokens[index])}>${escapeHtml(text)}</a>`;\n};\n\n// Process footnote block definition\nconst footnoteDef: BlockRule = (state: FootNoteStateBlock, startLine, endLine, silent) => {\n const start = state.bMarks[startLine] + state.tShift[startLine];\n const max = state.eMarks[startLine];\n let charCode: number;\n\n if (\n // line should be at least 5 chars - \"[^x]:\"\n start + 4 > max ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n if (\n // empty footnote label\n pos === start + 2 ||\n pos + 1 >= max ||\n state.src.charCodeAt(++pos) !== 58 /* : */\n )\n return false;\n\n if (silent) return true;\n\n pos++;\n\n (state.env.footnotes ??= {}).refs ??= {};\n\n const label = state.src.slice(start + 2, pos - 2);\n\n state.env.footnotes.refs[`:${label}`] = -1;\n\n const referenceOpenToken = state.push(\"footnote_reference_open\", \"\", 1);\n\n referenceOpenToken.meta = { label };\n referenceOpenToken.level = state.level++;\n\n const oldBMark = state.bMarks[startLine];\n const oldTShift = state.tShift[startLine];\n const oldSCount = state.sCount[startLine];\n const oldParentType = state.parentType;\n const posAfterColon = pos;\n const initial =\n state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);\n\n let offset = initial;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n\n if (charCode === 9 /* \\t */) offset += 4 - (offset % 4);\n else if (charCode === 32 /* space */) offset++;\n else break;\n\n pos++;\n }\n\n state.tShift[startLine] = pos - posAfterColon;\n state.sCount[startLine] = offset - initial;\n state.bMarks[startLine] = posAfterColon;\n state.blkIndent += 4;\n state.parentType = \"footnote\";\n\n if (state.sCount[startLine] < state.blkIndent) state.sCount[startLine] += state.blkIndent;\n\n state.md.block.tokenize(state, startLine, endLine);\n\n state.parentType = oldParentType;\n state.blkIndent -= 4;\n state.tShift[startLine] = oldTShift;\n state.sCount[startLine] = oldSCount;\n state.bMarks[startLine] = oldBMark;\n\n const referenceCloseToken = state.push(\"footnote_reference_close\", \"\", -1);\n\n referenceCloseToken.level = --state.level;\n\n return true;\n};\n\n// Create the footnote reference token from parsed data, resolved at parse time so renderers are\n// pure serializers.\nconst createFootnoteRefToken = (\n state: FootNoteStateInline,\n options: FootnoteOptions,\n id: number,\n subId?: number,\n label?: string,\n): void => {\n const refToken = state.push(\"footnote_ref\", \"\", 0);\n const anchorName = getFootnoteAnchorName(state.env.docId, id);\n const suffix = getFootnoteSuffix(subId);\n\n refToken.meta = {\n id,\n subId,\n label,\n href: `#footnote${anchorName}`,\n anchorId: `footnote-ref${anchorName}${suffix}`,\n anchorClass: ANCHOR_CLASS,\n } satisfies FootNoteMeta;\n\n refToken.attrJoin(\"class\", REF_CLASS);\n applyAttrs(refToken, options.refAttrs);\n};\n\n// Process inline footnotes (^[...])\nconst createFootnoteInline =\n (options: FootnoteOptions): InlineRule =>\n (state: FootNoteStateInline, silent) => {\n const max = state.posMax;\n const start = state.pos;\n\n if (\n start + 2 >= max ||\n state.src.charCodeAt(start) !== 94 /* ^ */ ||\n state.src.charCodeAt(start + 1) !== 91 /* [ */\n )\n return false;\n\n const labelEnd = state.md.helpers.parseLinkLabel(state, start + 1);\n\n // parser failed to find ']', so it’s not a valid note\n if (labelEnd < 0) return false;\n\n const labelStart = start + 2;\n\n /*\n * We found the end of the link, and know for a fact it’s a valid link;\n * so all that’s left to do is to call tokenizer.\n *\n */\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = ((state.env.footnotes ??= {}).list ??= []);\n const footnoteId = list.length;\n const tokens: Token[] = [];\n\n state.md.inline.parse(state.src.slice(labelStart, labelEnd), state.md, state.env, tokens);\n\n state.env.footnotes.list[footnoteId] = {\n content: state.src.slice(labelStart, labelEnd),\n tokens,\n };\n\n createFootnoteRefToken(state, options, footnoteId);\n }\n\n state.pos = labelEnd + 1;\n state.posMax = max;\n\n return true;\n };\n\n// Process footnote references ([^...])\nconst createFootnoteRef =\n (options: FootnoteOptions): InlineRule =>\n (state: FootNoteStateInline, silent) => {\n const start = state.pos;\n const max = state.posMax;\n\n if (\n // should be at least 4 chars - \"[^x]\"\n start + 3 > max ||\n !state.env.footnotes?.refs ||\n state.src.charCodeAt(start) !== 91 /* [ */ ||\n state.src.charCodeAt(start + 1) !== 94 /* ^ */\n )\n return false;\n\n let pos = start + 2;\n let charCode: number;\n\n while (pos < max) {\n charCode = state.src.charCodeAt(pos);\n if (charCode === 32 /* space */ || charCode === 10 /* \\n */) return false;\n\n if (charCode === 93 /* ] */) break;\n\n pos++;\n }\n\n // empty footnote labels\n if (pos === start + 2 || pos >= max) return false;\n\n pos++;\n\n const label = state.src.slice(start + 2, pos - 1);\n\n if (typeof state.env.footnotes.refs[`:${label}`] !== \"number\") return false;\n\n // silent mode is hard to trigger with standard syntax\n // this is more like a guard to prevent run tokenizer in silent mode\n if (!silent) {\n const list = (state.env.footnotes.list ??= []);\n const { refs } = state.env.footnotes;\n let footnoteId: number;\n\n if (refs[`:${label}`] < 0) {\n footnoteId = list.length;\n list[footnoteId] = { label, count: 0 };\n refs[`:${label}`] = footnoteId;\n } else {\n footnoteId = refs[`:${label}`];\n }\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const subId = list[footnoteId].count!;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n list[footnoteId].count! += 1;\n\n createFootnoteRefToken(state, options, footnoteId, subId, label);\n }\n\n state.pos = pos;\n state.posMax = max;\n\n return true;\n };\n\n// Glue footnote tokens to end of token stream\nconst createFootnoteTail =\n (options: FootnoteOptions): CoreRule =>\n (state: FootNoteStateCore) => {\n const refTokens: Record<string, Token[]> = {};\n const refStack: { label: string; tokens: Token[] }[] = [];\n\n if (!state.env.footnotes?.list) {\n let refDepth = 0;\n\n // If no footnotes list, remove all footnote reference tokens\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n refDepth++;\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n refDepth--;\n\n return false;\n }\n\n return refDepth === 0;\n });\n\n return;\n }\n\n const { list } = state.env.footnotes;\n\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnote_reference_open\") {\n refStack.push({\n label: (stateToken.meta as { label: string }).label,\n tokens: [],\n });\n\n return false;\n }\n\n if (stateToken.type === \"footnote_reference_close\") {\n // `footnoteDef` always pushes a balanced pair, so the stack has a matching entry here.\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const { label, tokens } = refStack.pop()!;\n\n // prepend ':' to avoid conflict with Object.prototype members\n refTokens[`:${label}`] = tokens;\n\n return false;\n }\n\n // Tokens outside any definition stay in the document.\n if (refStack.length === 0) return true;\n\n // Only the innermost definition collects the token, so a nested definition keeps its\n // content out of the outer note.\n refStack[refStack.length - 1].tokens.push(stateToken);\n\n return false;\n });\n\n const footnoteBlockOpenToken = new state.Token(\"footnote_block_open\", \"\", 1);\n\n footnoteBlockOpenToken.meta = {\n separatorClass: SEPARATOR_CLASS,\n listClass: LIST_CLASS,\n } satisfies FootnoteBlockOpenMeta;\n footnoteBlockOpenToken.attrJoin(\"class\", CONTAINER_CLASS);\n applyAttrs(footnoteBlockOpenToken, options.containerAttrs);\n\n state.tokens.push(footnoteBlockOpenToken);\n\n const listLength = list.length;\n\n for (let index = 0; index < listLength; index++) {\n const footnoteOpenToken = new state.Token(\"footnote_open\", \"\", 1);\n const anchorName = getFootnoteAnchorName(state.env.docId, index);\n\n footnoteOpenToken.meta = { id: index, label: list[index].label };\n footnoteOpenToken.attrSet(\"id\", `footnote${anchorName}`);\n footnoteOpenToken.attrJoin(\"class\", ITEM_CLASS);\n applyAttrs(footnoteOpenToken, options.itemAttrs);\n\n state.tokens.push(footnoteOpenToken);\n\n if (list[index].tokens) {\n const paragraphOpenToken = new state.Token(\"paragraph_open\", \"p\", 1);\n\n paragraphOpenToken.block = true;\n\n const inlineToken = new state.Token(\"inline\", \"\", 0);\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.children = list[index].tokens!;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n inlineToken.content = list[index].content!;\n\n const paragraphCloseToken = new state.Token(\"paragraph_close\", \"p\", -1);\n\n paragraphCloseToken.block = true;\n\n state.tokens.push(paragraphOpenToken, inlineToken, paragraphCloseToken);\n } else {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const tokens = refTokens[`:${list[index].label!}`];\n\n // A list entry may exist when the definition is not in this token stream, e.g. the\n // footnote reference sits in content rendered separately via `renderInline` (tab title).\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (tokens) state.tokens.push(...tokens);\n }\n\n const lastParagraph =\n state.tokens[state.tokens.length - 1].type === \"paragraph_close\"\n ? // oxlint-disable-next-line typescript/no-non-null-assertion\n state.tokens.pop()!\n : null;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n for (let j = 0; j < (Number(list[index].count) > 0 ? list[index].count! : 1); j++) {\n const footnoteAnchorToken = new state.Token(\"footnote_anchor\", \"\", 0);\n\n footnoteAnchorToken.meta = {\n id: index,\n subId: j,\n label: list[index].label,\n text: BACK_REFERENCE_TEXT,\n } satisfies FootNoteMeta;\n\n footnoteAnchorToken.attrSet(\"href\", `#footnote-ref${anchorName}${getFootnoteSuffix(j)}`);\n footnoteAnchorToken.attrJoin(\"class\", BACK_REFERENCE_CLASS);\n applyAttrs(footnoteAnchorToken, options.backrefAttrs);\n\n state.tokens.push(footnoteAnchorToken);\n }\n\n if (lastParagraph) state.tokens.push(lastParagraph);\n\n state.tokens.push(new state.Token(\"footnote_close\", \"\", -1));\n }\n\n state.tokens.push(new state.Token(\"footnote_block_close\", \"\", -1));\n };\n\nexport const footnote: PluginWithOptions<FootnoteOptions> = (md, options) => {\n // A second installation would append the footnote section twice.\n if (hasRule(md, \"footnoteTail\", \"core\")) return;\n\n md.renderer.rules.footnote_ref = renderFootnoteRef;\n md.renderer.rules.footnote_block_open = renderFootnoteBlockOpen;\n md.renderer.rules.footnote_block_close = renderFootnoteBlockClose;\n md.renderer.rules.footnote_open = renderFootnoteOpen;\n md.renderer.rules.footnote_close = renderFootnoteClose;\n md.renderer.rules.footnote_anchor = renderFootnoteAnchor;\n\n // The caption helper is still routed through `renderFootnoteRef`, so overriding it works.\n // `footnote_anchor_name` was an internal helper and is gone: anchor names are resolved while\n // parsing, so update the generated ids / hrefs on the tokens instead.\n md.renderer.rules.footnote_caption = renderFootnoteCaption;\n\n md.block.ruler.before(\"reference\", \"footnoteDef\", footnoteDef, {\n alt: [\"paragraph\", \"reference\"],\n });\n md.inline.ruler.after(\"image\", \"footnoteInline\", createFootnoteInline(options ?? {}));\n md.inline.ruler.after(\"footnoteInline\", \"footnote_ref\", createFootnoteRef(options ?? {}));\n md.core.ruler.after(\"inline\", \"footnoteTail\", createFootnoteTail(options ?? {}));\n};\n"],"mappings":"A,uDAWA,MAAMA,EAAwB,GAA0B,CACtD,GAAIC,EAAK,SAAW,EAAG,MAAO,GAE9B,IAAK,IAAIC,EAAQ,EAAGA,EAAQD,EAAK,OAAQ,IAAS,CAChD,IAAME,EAAWF,EAAK,WAAWC,CAAK,EAGtC,GACEC,GAAY,IACZA,IAAa,IACbA,IAAa,IACbA,IAAa,IACbA,IAAa,IACbA,IAAa,IACbA,IAAa,GAEb,MAAO,EACX,CAEA,MAAO,EACT,EAYaC,EAAmB,GAA0B,CACxD,IAAIC,EAAS,GACTC,EAA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EACxC,EAAG,SAAS,MAAM,qBAAuBG,EACzC,EAAG,SAAS,MAAM,cAAgBC,EAClC,EAAG,SAAS,MAAM,eAAiBC,EACnC,EAAG,SAAS,MAAM,gBAAkBC,EAKpC,EAAG,SAAS,MAAM,iBAAmBhB,EAErCgE,EAAG,MAAM,MAAM,OAAO,YAAa,cAAe7C,EAAa,CAC7D,IAAK,CAAC,YAAa,WAAW,CAChC,CAAC,EACD6C,EAAG,OAAO,MAAM,MAAM,QAAS,iBAAkBvB,EAAqBpC,GAAW,CAAC,CAAC,CAAC,EACpF2D,EAAG,OAAO,MAAM,MAAM,iBAAkB,eAAgBnB,EAAkBxC,GAAW,CAAC,CAAC,CAAC,EACxF2D,EAAG,KAAK,MAAM,MAAM,SAAU,eAAgBhB,EAAmB3C,GAAW,CAAC,CAAC,CAAC,EACjF,E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit/plugin-footnote",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Footnote plugin for MarkdownIt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"footnote",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"clean": "rimraf ./dist"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@mdit/helper": "^1.2.
|
|
47
|
+
"@mdit/helper": "^1.2.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"markdown-it": "^15.0.3"
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=22"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "cb814cb40a5d92c7e5525ab6a4bc25116f02a619"
|
|
61
61
|
}
|