@mdit/plugin-footnote 0.1.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 Vitaly Puzrin, Alex Kocharin.
4
+ Copyright (C) 2022 - PRESENT by MrHope
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @mdit/plugin-footnote
2
+
3
+ [![Version](https://img.shields.io/npm/v/@mdit/plugin-footnote.svg?style=flat-square&logo=npm) ![Downloads](https://img.shields.io/npm/dm/@mdit/plugin-footnote.svg?style=flat-square&logo=npm) ![Size](https://img.shields.io/bundlephobia/min/@mdit/plugin-footnote?style=flat-square&logo=npm)](https://www.npmjs.com/package/@mdit/plugin-footnote)
4
+
5
+ footnote plugin for MarkdownIt.
6
+
7
+ ## Install / 安装
8
+
9
+ ```bash
10
+ # pnpm
11
+ pnpm add -D @mdit/plugin-footnote
12
+ # npm
13
+ npm i -D @mdit/plugin-footnote
14
+ # yarn
15
+ yarn add -D @mdit/plugin-footnote
16
+ ```
package/lib/index.cjs ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";var i=require("markdown-it/lib/token.js"),m=require("markdown-it/lib/helpers/parse_link_label.js");const h=(e,n)=>e[n].meta.subId>0?`:${e[n].meta.subId}`:"",A=(e,n,t,s)=>`${typeof s.docId=="string"?`-${s.docId}-`:""}${(e[n].meta.id+1).toString()}`,C=(e,n)=>`[${(e[n].meta.id+1).toString()}${h(e,n)}]`,g=(e,n,t,s,o)=>{const c=o.rules.footnoteAnchorName(e,n,t,s,o),f=o.rules.footnoteCaption(e,n,t,s,o);return`<sup class="footnote-ref"><a href="#footnote${c}">${f}</a><a class="footnote-anchor" id="footnote-ref${c}${h(e,n)}" /></sup>`},I=(e,n,t)=>`${t.xhtmlOut?`<hr class="footnotes-sep" />
2
+ `:`<hr class="footnotes-sep">
3
+ `}<section class="footnotes">
4
+ <ol class="footnotes-list">
5
+ `,w=()=>`</ol>
6
+ </section>
7
+ `,M=(e,n,t,s,o)=>`<li id="footnote${o.rules.footnoteAnchorName(e,n,t,s,o)}${h(e,n)}" class="footnote-item">`,y=()=>`</li>
8
+ `,R=(e,n,t,s,o)=>` <a href="#footnote-ref${o.rules.footnoteAnchorName(e,n,t,s,o)}${h(e,n)}" class="footnote-backref">↩︎</a>`,S=(e,n,t,s)=>{let o,c,f,a;const r=e.bMarks[n]+e.tShift[n],l=e.eMarks[n];if(r+4>l||e.src.charAt(r)!=="["||e.src.charAt(r+1)!=="^")return!1;for(o=r+2;o<l;o++){if(e.src.charAt(o)===" ")return!1;if(e.src.charAt(o)==="]")break}if(o===r+2||o+1>=l||e.src.charAt(++o)!==":")return!1;if(s)return!0;o+=1,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={});const p=e.src.slice(r+2,o-2);e.env.footnotes.refs[`:${p}`]=-1,c=new i("footnoteReferenceOpen","",1),c.meta={label:p},c.level=e.level++,e.tokens.push(c);const u=e.bMarks[n],b=e.tShift[n],v=e.sCount[n],d=e.parentType,k=o,$=e.sCount[n]+o-(e.bMarks[n]+e.tShift[n]);for(f=e.sCount[n]+o-(e.bMarks[n]+e.tShift[n]);o<l;){if(a=e.src.charAt(o),a===" ")f+=4-f%4;else if(a===" ")f+=1;else break;o+=1}return e.tShift[n]=o-k,e.sCount[n]=f-$,e.bMarks[n]=k,e.blkIndent+=4,e.parentType="footnote",e.sCount[n]<e.blkIndent&&(e.sCount[n]+=e.blkIndent),e.md.block.tokenize(e,n,t),e.parentType=d,e.blkIndent-=4,e.tShift[n]=b,e.sCount[n]=v,e.bMarks[n]=u,c=new i("footnoteReferenceClose","",-1),c.level=--e.level,e.tokens.push(c),!0},O=(e,n)=>{let t,s,o;const c=e.posMax,f=e.pos;if(f+2>=c||e.src.charAt(f)!=="^"||e.src.charAt(f+1)!=="[")return!1;const a=f+2,r=m(e,f+1);return r<0?!1:(n||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),t=e.env.footnotes.list.length,e.md.inline.parse(e.src.slice(a,r),e.md,e.env,o=[]),s=e.push("footnoteRef","",0),s.meta={id:t},e.env.footnotes.list[t]={content:e.src.slice(a,r),tokens:o}),e.pos=r+1,e.posMax=c,!0)},N=(e,n)=>{let t,s,o,c;const f=e.posMax,a=e.pos;if(a+3>f||!e.env.footnotes||!e.env.footnotes.refs||e.src.charAt(a)!=="["||e.src.charAt(a+1)!=="^")return!1;for(t=a+2;t<f;t++){if(e.src.charAt(t)===" "||e.src.charAt(t)===`
9
+ `)return!1;if(e.src.charAt(t)==="]")break}if(t===a+2||t>=f)return!1;t+=1;const r=e.src.slice(a+2,t-1);return typeof e.env.footnotes.refs[`:${r}`]>"u"?!1:(n||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[`:${r}`]<0?(s=e.env.footnotes.list.length,e.env.footnotes.list[s]={label:r,count:0},e.env.footnotes.refs[`:${r}`]=s):s=e.env.footnotes.refs[`:${r}`],o=e.env.footnotes.list[s].count,e.env.footnotes.list[s].count=e.env.footnotes.list[s].count+1,c=e.push("footnoteRef","",0),c.meta={id:s,subId:o,label:r}),e.pos=t,e.posMax=f,!0)},x=e=>{let n,t,s,o,c,f=!1;const a={};if(!e.env.footnotes||(e.tokens=e.tokens.filter(l=>l.type==="footnoteReferenceOpen"?(f=!0,o=[],c=l.meta.label,!1):l.type==="footnoteReferenceClose"?(f=!1,a[`:${c}`]=o,!1):(f&&o.push(l),!f)),!e.env.footnotes.list))return!1;const{list:r}=e.env.footnotes;t=new i("footnoteBlockOpen","",1),e.tokens.push(t);for(let l=0,{length:p}=r;l<p;l++){t=new i("footnoteOpen","",1),t.meta={id:l,label:r[l].label},e.tokens.push(t),r[l].tokens?(s=[],t=new i("paragraph_open","p",1),t.block=!0,s.push(t),t=new i("inline","",0),t.children=r[l].tokens,t.content=r[l].content,s.push(t),t=new i("paragraph_close","p",-1),t.block=!0,s.push(t)):r[l].label?s=a[`:${r[l].label}`]:s=[],s&&(e.tokens=e.tokens.concat(s)),e.tokens[e.tokens.length-1].type==="paragraph_close"?n=e.tokens.pop()||null:n=null;for(let u=0;u<(Number(r[l].count)>0?r[l].count:1);u++)t=new i("footnoteAnchor","",0),t.meta={id:l,subId:u,label:r[l].label},e.tokens.push(t);n&&e.tokens.push(n),t=new i("footnoteClose","",-1),e.tokens.push(t)}return t=new i("footnoteBlockClose","",-1),e.tokens.push(t),!0},B=e=>{e.renderer.rules.footnoteRef=g,e.renderer.rules.footnoteBlockOpen=I,e.renderer.rules.footnoteBlockClose=w,e.renderer.rules.footnoteOpen=M,e.renderer.rules.footnoteClose=y,e.renderer.rules.footnoteAnchor=R,e.renderer.rules.footnoteCaption=C,e.renderer.rules.footnoteAnchorName=A,e.block.ruler.before("reference","footnoteDef",S,{alt:["paragraph","reference"]}),e.inline.ruler.after("image","footnoteInline",O),e.inline.ruler.after("footnoteInline","footnoteRef",N),e.core.ruler.after("inline","footnoteTail",x)};exports.footnote=B;
10
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/plugin.ts"],"sourcesContent":["/**\n * Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.js\n */\n\nimport Token from \"markdown-it/lib/token.js\";\nimport parseLinkLabel from \"markdown-it/lib/helpers/parse_link_label.js\";\n\nimport type Renderer from \"markdown-it/lib/renderer.js\";\nimport type StateBlock from \"markdown-it/lib/rules_block/state_block.js\";\nimport type StateCore from \"markdown-it/lib/rules_core/state_core.js\";\nimport type StateInline from \"markdown-it/lib/rules_inline/state_inline.js\";\nimport type { PluginSimple } from \"markdown-it\";\nimport type { RuleBlock } from \"markdown-it/lib/parser_block.js\";\nimport type { RuleInline } from \"markdown-it/lib/parser_inline.js\";\nimport type { FootNoteEnv, FootNoteToken } from \"./types.js\";\n\ninterface FootNoteStateBlock extends StateBlock {\n tokens: FootNoteToken[];\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateInline extends StateInline {\n tokens: FootNoteToken[];\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateCore extends StateCore {\n tokens: FootNoteToken[];\n env: FootNoteEnv;\n}\n\nconst getIDSuffix = (tokens: FootNoteToken[], index: number): string =>\n // add suffix when multiple id was found\n tokens[index].meta.subId > 0 ? `:${tokens[index].meta.subId}` : \"\";\n\nconst renderFootnoteAnchorName: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n _options,\n env: FootNoteEnv\n): string =>\n `${\n // prefix\n typeof env.docId === \"string\" ? `-${env.docId}-` : \"\"\n }${\n // increasing id\n (tokens[index].meta.id + 1).toString()\n }`;\n\nconst renderFootnoteCaption: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index\n): string =>\n `[${\n // number\n (tokens[index].meta.id + 1).toString()\n }${getIDSuffix(tokens, index)}]`;\n\nconst renderFootnoteRef: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n options,\n env: FootNoteEnv,\n self\n): string => {\n const id = self.rules[\"footnoteAnchorName\"]!(\n tokens,\n index,\n options,\n env,\n self\n );\n const caption = self.rules[\"footnoteCaption\"]!(\n tokens,\n index,\n options,\n env,\n self\n );\n\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 )}\" /></sup>`;\n};\n\nconst renderFootnoteBlockOpen: Renderer.RenderRule = (\n _tokens: FootNoteToken[],\n _index,\n options\n): string =>\n `${\n options.xhtmlOut\n ? '<hr class=\"footnotes-sep\" />\\n'\n : '<hr class=\"footnotes-sep\">\\n'\n }<section class=\"footnotes\">\\n<ol class=\"footnotes-list\">\\n`;\n\nconst renderFootnoteBlockClose = (): string => \"</ol>\\n</section>\\n\";\n\nconst renderFootnoteOpen: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n options,\n env: FootNoteEnv,\n self\n): string =>\n `<li id=\"footnote${self.rules[\"footnoteAnchorName\"]!(\n tokens,\n index,\n options,\n env,\n self\n )}${getIDSuffix(tokens, index)}\" class=\"footnote-item\">`;\n\nconst renderFootnoteClose = (): string => \"</li>\\n\";\n\nconst renderFootnoteAnchor: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n options,\n env: FootNoteEnv,\n self\n): string => {\n return ` <a href=\"#footnote-ref${self.rules[\"footnoteAnchorName\"]!(\n tokens,\n index,\n options,\n env,\n self\n )}${\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\n// Process footnote block definition\nconst footnoteDef: RuleBlock = (\n state: FootNoteStateBlock,\n startLine,\n endLine,\n silent\n) => {\n let pos;\n let token;\n let offset;\n let ch;\n const start = state.bMarks[startLine] + state.tShift[startLine];\n const max = state.eMarks[startLine];\n\n // line should be at least 5 chars - \"[^x]:\"\n if (start + 4 > max) return false;\n\n if (state.src.charAt(start) !== \"[\") return false;\n\n if (state.src.charAt(start + 1) !== \"^\") return false;\n\n for (pos = start + 2; pos < max; pos++) {\n if (state.src.charAt(pos) === \" \") return false;\n if (state.src.charAt(pos) === \"]\") break;\n }\n\n // no empty footnote labels\n if (pos === start + 2) return false;\n\n if (pos + 1 >= max || state.src.charAt(++pos) !== \":\") return false;\n\n if (silent) return true;\n pos += 1;\n\n if (!state.env.footnotes) state.env.footnotes = {};\n if (!state.env.footnotes.refs) state.env.footnotes.refs = {};\n const label = state.src.slice(start + 2, pos - 2);\n\n state.env.footnotes.refs[`:${label}`] = -1;\n\n token = new Token(\"footnoteReferenceOpen\", \"\", 1);\n token.meta = { label };\n token.level = state.level++;\n state.tokens.push(token);\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] +\n pos -\n (state.bMarks[startLine] + state.tShift[startLine]);\n\n offset =\n state.sCount[startLine] +\n pos -\n (state.bMarks[startLine] + state.tShift[startLine]);\n\n while (pos < max) {\n ch = state.src.charAt(pos);\n\n if (ch === \"\\t\") offset += 4 - (offset % 4);\n else if (ch === \" \") offset += 1;\n else break;\n\n pos += 1;\n }\n\n state.tShift[startLine] = pos - posAfterColon;\n state.sCount[startLine] = offset - initial;\n\n state.bMarks[startLine] = posAfterColon;\n state.blkIndent += 4;\n state.parentType = \"footnote\" as unknown as StateBlock.ParentType;\n\n if (state.sCount[startLine] < state.blkIndent)\n 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 token = new Token(\"footnoteReferenceClose\", \"\", -1);\n token.level = --state.level;\n state.tokens.push(token);\n\n return true;\n};\n\n// Process inline footnotes (^[...])\nconst footnoteInline: RuleInline = (state: FootNoteStateInline, silent) => {\n let footnoteId;\n let token;\n let tokens: Token[];\n const max = state.posMax;\n const start = state.pos;\n\n if (start + 2 >= max) return false;\n if (state.src.charAt(start) !== \"^\") return false;\n\n if (state.src.charAt(start + 1) !== \"[\") return false;\n\n const labelStart = start + 2;\n const labelEnd = 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 /*\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 if (!silent) {\n if (!state.env.footnotes) state.env.footnotes = {};\n if (!state.env.footnotes.list) state.env.footnotes.list = [];\n footnoteId = state.env.footnotes.list.length;\n\n state.md.inline.parse(\n state.src.slice(labelStart, labelEnd),\n state.md,\n state.env,\n (tokens = [])\n );\n\n token = state.push(\"footnoteRef\", \"\", 0);\n token.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: RuleInline = (state: FootNoteStateInline, silent) => {\n let pos;\n let footnoteId;\n let footnoteSubId;\n let token;\n const max = state.posMax;\n const start = state.pos;\n\n // should be at least 4 chars - \"[^x]\"\n if (start + 3 > max) return false;\n\n if (!state.env.footnotes || !state.env.footnotes.refs) return false;\n if (state.src.charAt(start) !== \"[\") return false;\n\n if (state.src.charAt(start + 1) !== \"^\") return false;\n\n for (pos = start + 2; pos < max; pos++) {\n if (state.src.charAt(pos) === \" \") return false;\n if (state.src.charAt(pos) === \"\\n\") return false;\n if (state.src.charAt(pos) === \"]\") break;\n }\n\n if (pos === start + 2) return false; // no empty footnote labels\n if (pos >= max) return false;\n\n pos += 1;\n\n const label = state.src.slice(start + 2, pos - 1);\n\n if (typeof state.env.footnotes.refs[`:${label}`] === \"undefined\")\n return false;\n\n if (!silent) {\n if (!state.env.footnotes.list) state.env.footnotes.list = [];\n\n if (state.env.footnotes.refs[`:${label}`] < 0) {\n footnoteId = state.env.footnotes.list.length;\n state.env.footnotes.list[footnoteId] = { label, count: 0 };\n state.env.footnotes.refs[`:${label}`] = footnoteId;\n } else footnoteId = state.env.footnotes.refs[`:${label}`];\n\n footnoteSubId = state.env.footnotes.list[footnoteId].count!;\n state.env.footnotes.list[footnoteId].count =\n state.env.footnotes.list[footnoteId].count! + 1;\n\n token = state.push(\"footnoteRef\", \"\", 0);\n token.meta = { id: footnoteId, subId: footnoteSubId, 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 = (state: FootNoteStateCore): boolean => {\n let lastParagraph: FootNoteToken | null;\n let token: Token;\n let tokens: Token[];\n let current: Token[];\n let currentLabel: string;\n let insideRef = false;\n const refTokens: Record<string, Token[]> = {};\n\n if (!state.env.footnotes) return false;\n\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnoteReferenceOpen\") {\n insideRef = true;\n current = [];\n currentLabel = stateToken.meta.label;\n\n return false;\n }\n if (stateToken.type === \"footnoteReferenceClose\") {\n insideRef = false;\n // prepend ':' to avoid conflict with Object.prototype members\n refTokens[`:${currentLabel}`] = current;\n\n return false;\n }\n if (insideRef) current.push(stateToken);\n\n return !insideRef;\n });\n\n if (!state.env.footnotes.list) return false;\n const { list } = state.env.footnotes;\n\n token = new Token(\"footnoteBlockOpen\", \"\", 1);\n state.tokens.push(token);\n\n for (let i = 0, { length } = list; i < length; i++) {\n token = new Token(\"footnoteOpen\", \"\", 1);\n token.meta = { id: i, label: list[i].label };\n state.tokens.push(token);\n\n if (list[i].tokens) {\n tokens = [];\n\n token = new Token(\"paragraph_open\", \"p\", 1);\n token.block = true;\n tokens.push(token);\n\n token = new Token(\"inline\", \"\", 0);\n token.children = list[i].tokens!;\n token.content = list[i].content!;\n tokens.push(token);\n\n token = new Token(\"paragraph_close\", \"p\", -1);\n token.block = true;\n tokens.push(token);\n } else if (list[i].label) tokens = refTokens[`:${list[i].label!}`];\n else tokens = [];\n\n if (tokens) state.tokens = state.tokens.concat(tokens);\n if (state.tokens[state.tokens.length - 1].type === \"paragraph_close\")\n lastParagraph = state.tokens.pop() || null;\n else lastParagraph = null;\n\n for (let j = 0; j < (Number(list[i].count) > 0 ? list[i].count! : 1); j++) {\n token = new Token(\"footnoteAnchor\", \"\", 0);\n token.meta = { id: i, subId: j, label: list[i].label };\n state.tokens.push(token);\n }\n\n if (lastParagraph) state.tokens.push(lastParagraph);\n\n token = new Token(\"footnoteClose\", \"\", -1);\n state.tokens.push(token);\n }\n\n token = new Token(\"footnoteBlockClose\", \"\", -1);\n state.tokens.push(token);\n\n return true;\n};\n\nexport const footnote: PluginSimple = (md) => {\n md.renderer.rules[\"footnoteRef\"] = renderFootnoteRef;\n md.renderer.rules[\"footnoteBlockOpen\"] = renderFootnoteBlockOpen;\n md.renderer.rules[\"footnoteBlockClose\"] = renderFootnoteBlockClose;\n md.renderer.rules[\"footnoteOpen\"] = renderFootnoteOpen;\n md.renderer.rules[\"footnoteClose\"] = renderFootnoteClose;\n md.renderer.rules[\"footnoteAnchor\"] = 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[\"footnoteCaption\"] = renderFootnoteCaption;\n md.renderer.rules[\"footnoteAnchorName\"] = 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\", \"footnoteRef\", footnoteRef);\n md.core.ruler.after(\"inline\", \"footnoteTail\", footnoteTail);\n};\n"],"names":["getIDSuffix","tokens","index","renderFootnoteAnchorName","_options","env","renderFootnoteCaption","renderFootnoteRef","options","self","id","caption","renderFootnoteBlockOpen","_tokens","_index","renderFootnoteBlockClose","renderFootnoteOpen","renderFootnoteClose","renderFootnoteAnchor","footnoteDef","state","startLine","endLine","silent","pos","token","offset","ch","start","max","label","Token","oldBMark","oldTShift","oldSCount","oldParentType","posAfterColon","initial","footnoteInline","footnoteId","labelStart","labelEnd","parseLinkLabel","footnoteRef","footnoteSubId","footnoteTail","lastParagraph","current","currentLabel","insideRef","refTokens","stateToken","list","i","length","j","footnote","md"],"mappings":"gHA+BA,MAAMA,EAAc,CAACC,EAAyBC,IAE5CD,EAAOC,GAAO,KAAK,MAAQ,EAAI,IAAID,EAAOC,GAAO,KAAK,QAAU,GAE5DC,EAAgD,CACpDF,EACAC,EACAE,EACAC,IAEA,GAEE,OAAOA,EAAI,OAAU,SAAW,IAAIA,EAAI,SAAW,MAGlDJ,EAAOC,GAAO,KAAK,GAAK,GAAG,SAAS,IAGnCI,EAA6C,CACjDL,EACAC,IAEA,KAEGD,EAAOC,GAAO,KAAK,GAAK,GAAG,aAC3BF,EAAYC,EAAQC,CAAK,KAExBK,EAAyC,CAC7CN,EACAC,EACAM,EACAH,EACAI,IACW,CACX,MAAMC,EAAKD,EAAK,MAAM,mBACpBR,EACAC,EACAM,EACAH,EACAI,CACF,EACME,EAAUF,EAAK,MAAM,gBACzBR,EACAC,EACAM,EACAH,EACAI,CACF,EAEA,MAAO,+CAA+CC,MAAOC,mDAAyDD,IAAKV,EACzHC,EACAC,CACF,aACF,EAEMU,EAA+C,CACnDC,EACAC,EACAN,IAEA,GACEA,EAAQ,SACJ;AAAA,EACA;AAAA;AAAA;AAAA,EAGFO,EAA2B,IAAc;AAAA;AAAA,EAEzCC,EAA0C,CAC9Cf,EACAC,EACAM,EACAH,EACAI,IAEA,mBAAmBA,EAAK,MAAM,mBAC5BR,EACAC,EACAM,EACAH,EACAI,CACF,IAAIT,EAAYC,EAAQC,CAAK,4BAEzBe,E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AEA,OAAAA,EAAQ,IAAIM,EAAM,qBAAsB,GAAI,EAAE,EAC9CX,EAAM,OAAO,KAAKK,CAAK,EAEhB,EACT,EAEa+B,EAA0BC,GAAO,CAC5CA,EAAG,SAAS,MAAM,YAAiBlD,EACnCkD,EAAG,SAAS,MAAM,kBAAuB7C,EACzC6C,EAAG,SAAS,MAAM,mBAAwB1C,EAC1C0C,EAAG,SAAS,MAAM,aAAkBzC,EACpCyC,EAAG,SAAS,MAAM,cAAmBxC,EACrCwC,EAAG,SAAS,MAAM,eAAoBvC,EAItCuC,EAAG,SAAS,MAAM,gBAAqBnD,EACvCmD,EAAG,SAAS,MAAM,mBAAwBtD,EAE1CsD,EAAG,MAAM,MAAM,OAAO,YAAa,cAAetC,EAAa,CAC7D,IAAK,CAAC,YAAa,WAAW,CAChC,CAAC,EACDsC,EAAG,OAAO,MAAM,MAAM,QAAS,iBAAkBnB,CAAc,EAC/DmB,EAAG,OAAO,MAAM,MAAM,iBAAkB,cAAed,CAAW,EAClEc,EAAG,KAAK,MAAM,MAAM,SAAU,eAAgBZ,CAAY,CAC5D"}
@@ -0,0 +1,31 @@
1
+ import { PluginSimple } from 'markdown-it';
2
+ import Token from 'markdown-it/lib/token.js';
3
+
4
+ /**
5
+ * Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.js
6
+ */
7
+
8
+ declare const footnote: PluginSimple;
9
+
10
+ interface FootNoteToken extends Token {
11
+ meta: {
12
+ id: number;
13
+ subId: number;
14
+ label: string;
15
+ };
16
+ }
17
+ interface FootNoteEnv extends Record<any, any> {
18
+ docId?: string;
19
+ footnotes: {
20
+ label?: string;
21
+ refs?: Record<string, number>;
22
+ list?: {
23
+ label?: string;
24
+ count?: number;
25
+ content?: string;
26
+ tokens?: Token[] | null;
27
+ }[];
28
+ };
29
+ }
30
+
31
+ export { FootNoteEnv, FootNoteToken, footnote };
@@ -0,0 +1,31 @@
1
+ import { PluginSimple } from 'markdown-it';
2
+ import Token from 'markdown-it/lib/token.js';
3
+
4
+ /**
5
+ * Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.js
6
+ */
7
+
8
+ declare const footnote: PluginSimple;
9
+
10
+ interface FootNoteToken extends Token {
11
+ meta: {
12
+ id: number;
13
+ subId: number;
14
+ label: string;
15
+ };
16
+ }
17
+ interface FootNoteEnv extends Record<any, any> {
18
+ docId?: string;
19
+ footnotes: {
20
+ label?: string;
21
+ refs?: Record<string, number>;
22
+ list?: {
23
+ label?: string;
24
+ count?: number;
25
+ content?: string;
26
+ tokens?: Token[] | null;
27
+ }[];
28
+ };
29
+ }
30
+
31
+ export { FootNoteEnv, FootNoteToken, footnote };
package/lib/index.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { PluginSimple } from 'markdown-it';
2
+ import Token from 'markdown-it/lib/token.js';
3
+
4
+ /**
5
+ * Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.js
6
+ */
7
+
8
+ declare const footnote: PluginSimple;
9
+
10
+ interface FootNoteToken extends Token {
11
+ meta: {
12
+ id: number;
13
+ subId: number;
14
+ label: string;
15
+ };
16
+ }
17
+ interface FootNoteEnv extends Record<any, any> {
18
+ docId?: string;
19
+ footnotes: {
20
+ label?: string;
21
+ refs?: Record<string, number>;
22
+ list?: {
23
+ label?: string;
24
+ count?: number;
25
+ content?: string;
26
+ tokens?: Token[] | null;
27
+ }[];
28
+ };
29
+ }
30
+
31
+ export { FootNoteEnv, FootNoteToken, footnote };
package/lib/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import i from"markdown-it/lib/token.js";import $ from"markdown-it/lib/helpers/parse_link_label.js";const h=(e,n)=>e[n].meta.subId>0?`:${e[n].meta.subId}`:"",A=(e,n,t,s)=>`${typeof s.docId=="string"?`-${s.docId}-`:""}${(e[n].meta.id+1).toString()}`,C=(e,n)=>`[${(e[n].meta.id+1).toString()}${h(e,n)}]`,g=(e,n,t,s,o)=>{const c=o.rules.footnoteAnchorName(e,n,t,s,o),f=o.rules.footnoteCaption(e,n,t,s,o);return`<sup class="footnote-ref"><a href="#footnote${c}">${f}</a><a class="footnote-anchor" id="footnote-ref${c}${h(e,n)}" /></sup>`},I=(e,n,t)=>`${t.xhtmlOut?`<hr class="footnotes-sep" />
2
+ `:`<hr class="footnotes-sep">
3
+ `}<section class="footnotes">
4
+ <ol class="footnotes-list">
5
+ `,w=()=>`</ol>
6
+ </section>
7
+ `,M=(e,n,t,s,o)=>`<li id="footnote${o.rules.footnoteAnchorName(e,n,t,s,o)}${h(e,n)}" class="footnote-item">`,y=()=>`</li>
8
+ `,R=(e,n,t,s,o)=>` <a href="#footnote-ref${o.rules.footnoteAnchorName(e,n,t,s,o)}${h(e,n)}" class="footnote-backref">↩︎</a>`,S=(e,n,t,s)=>{let o,c,f,a;const r=e.bMarks[n]+e.tShift[n],l=e.eMarks[n];if(r+4>l||e.src.charAt(r)!=="["||e.src.charAt(r+1)!=="^")return!1;for(o=r+2;o<l;o++){if(e.src.charAt(o)===" ")return!1;if(e.src.charAt(o)==="]")break}if(o===r+2||o+1>=l||e.src.charAt(++o)!==":")return!1;if(s)return!0;o+=1,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={});const p=e.src.slice(r+2,o-2);e.env.footnotes.refs[`:${p}`]=-1,c=new i("footnoteReferenceOpen","",1),c.meta={label:p},c.level=e.level++,e.tokens.push(c);const u=e.bMarks[n],b=e.tShift[n],d=e.sCount[n],v=e.parentType,k=o,m=e.sCount[n]+o-(e.bMarks[n]+e.tShift[n]);for(f=e.sCount[n]+o-(e.bMarks[n]+e.tShift[n]);o<l;){if(a=e.src.charAt(o),a===" ")f+=4-f%4;else if(a===" ")f+=1;else break;o+=1}return e.tShift[n]=o-k,e.sCount[n]=f-m,e.bMarks[n]=k,e.blkIndent+=4,e.parentType="footnote",e.sCount[n]<e.blkIndent&&(e.sCount[n]+=e.blkIndent),e.md.block.tokenize(e,n,t),e.parentType=v,e.blkIndent-=4,e.tShift[n]=b,e.sCount[n]=d,e.bMarks[n]=u,c=new i("footnoteReferenceClose","",-1),c.level=--e.level,e.tokens.push(c),!0},O=(e,n)=>{let t,s,o;const c=e.posMax,f=e.pos;if(f+2>=c||e.src.charAt(f)!=="^"||e.src.charAt(f+1)!=="[")return!1;const a=f+2,r=$(e,f+1);return r<0?!1:(n||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),t=e.env.footnotes.list.length,e.md.inline.parse(e.src.slice(a,r),e.md,e.env,o=[]),s=e.push("footnoteRef","",0),s.meta={id:t},e.env.footnotes.list[t]={content:e.src.slice(a,r),tokens:o}),e.pos=r+1,e.posMax=c,!0)},x=(e,n)=>{let t,s,o,c;const f=e.posMax,a=e.pos;if(a+3>f||!e.env.footnotes||!e.env.footnotes.refs||e.src.charAt(a)!=="["||e.src.charAt(a+1)!=="^")return!1;for(t=a+2;t<f;t++){if(e.src.charAt(t)===" "||e.src.charAt(t)===`
9
+ `)return!1;if(e.src.charAt(t)==="]")break}if(t===a+2||t>=f)return!1;t+=1;const r=e.src.slice(a+2,t-1);return typeof e.env.footnotes.refs[`:${r}`]>"u"?!1:(n||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[`:${r}`]<0?(s=e.env.footnotes.list.length,e.env.footnotes.list[s]={label:r,count:0},e.env.footnotes.refs[`:${r}`]=s):s=e.env.footnotes.refs[`:${r}`],o=e.env.footnotes.list[s].count,e.env.footnotes.list[s].count=e.env.footnotes.list[s].count+1,c=e.push("footnoteRef","",0),c.meta={id:s,subId:o,label:r}),e.pos=t,e.posMax=f,!0)},N=e=>{let n,t,s,o,c,f=!1;const a={};if(!e.env.footnotes||(e.tokens=e.tokens.filter(l=>l.type==="footnoteReferenceOpen"?(f=!0,o=[],c=l.meta.label,!1):l.type==="footnoteReferenceClose"?(f=!1,a[`:${c}`]=o,!1):(f&&o.push(l),!f)),!e.env.footnotes.list))return!1;const{list:r}=e.env.footnotes;t=new i("footnoteBlockOpen","",1),e.tokens.push(t);for(let l=0,{length:p}=r;l<p;l++){t=new i("footnoteOpen","",1),t.meta={id:l,label:r[l].label},e.tokens.push(t),r[l].tokens?(s=[],t=new i("paragraph_open","p",1),t.block=!0,s.push(t),t=new i("inline","",0),t.children=r[l].tokens,t.content=r[l].content,s.push(t),t=new i("paragraph_close","p",-1),t.block=!0,s.push(t)):r[l].label?s=a[`:${r[l].label}`]:s=[],s&&(e.tokens=e.tokens.concat(s)),e.tokens[e.tokens.length-1].type==="paragraph_close"?n=e.tokens.pop()||null:n=null;for(let u=0;u<(Number(r[l].count)>0?r[l].count:1);u++)t=new i("footnoteAnchor","",0),t.meta={id:l,subId:u,label:r[l].label},e.tokens.push(t);n&&e.tokens.push(n),t=new i("footnoteClose","",-1),e.tokens.push(t)}return t=new i("footnoteBlockClose","",-1),e.tokens.push(t),!0},B=e=>{e.renderer.rules.footnoteRef=g,e.renderer.rules.footnoteBlockOpen=I,e.renderer.rules.footnoteBlockClose=w,e.renderer.rules.footnoteOpen=M,e.renderer.rules.footnoteClose=y,e.renderer.rules.footnoteAnchor=R,e.renderer.rules.footnoteCaption=C,e.renderer.rules.footnoteAnchorName=A,e.block.ruler.before("reference","footnoteDef",S,{alt:["paragraph","reference"]}),e.inline.ruler.after("image","footnoteInline",O),e.inline.ruler.after("footnoteInline","footnoteRef",x),e.core.ruler.after("inline","footnoteTail",N)};export{B as footnote};
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/plugin.ts"],"sourcesContent":["/**\n * Forked from https://github.com/markdown-it/markdown-it-footnote/blob/master/index.js\n */\n\nimport Token from \"markdown-it/lib/token.js\";\nimport parseLinkLabel from \"markdown-it/lib/helpers/parse_link_label.js\";\n\nimport type Renderer from \"markdown-it/lib/renderer.js\";\nimport type StateBlock from \"markdown-it/lib/rules_block/state_block.js\";\nimport type StateCore from \"markdown-it/lib/rules_core/state_core.js\";\nimport type StateInline from \"markdown-it/lib/rules_inline/state_inline.js\";\nimport type { PluginSimple } from \"markdown-it\";\nimport type { RuleBlock } from \"markdown-it/lib/parser_block.js\";\nimport type { RuleInline } from \"markdown-it/lib/parser_inline.js\";\nimport type { FootNoteEnv, FootNoteToken } from \"./types.js\";\n\ninterface FootNoteStateBlock extends StateBlock {\n tokens: FootNoteToken[];\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateInline extends StateInline {\n tokens: FootNoteToken[];\n env: FootNoteEnv;\n}\n\ninterface FootNoteStateCore extends StateCore {\n tokens: FootNoteToken[];\n env: FootNoteEnv;\n}\n\nconst getIDSuffix = (tokens: FootNoteToken[], index: number): string =>\n // add suffix when multiple id was found\n tokens[index].meta.subId > 0 ? `:${tokens[index].meta.subId}` : \"\";\n\nconst renderFootnoteAnchorName: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n _options,\n env: FootNoteEnv\n): string =>\n `${\n // prefix\n typeof env.docId === \"string\" ? `-${env.docId}-` : \"\"\n }${\n // increasing id\n (tokens[index].meta.id + 1).toString()\n }`;\n\nconst renderFootnoteCaption: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index\n): string =>\n `[${\n // number\n (tokens[index].meta.id + 1).toString()\n }${getIDSuffix(tokens, index)}]`;\n\nconst renderFootnoteRef: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n options,\n env: FootNoteEnv,\n self\n): string => {\n const id = self.rules[\"footnoteAnchorName\"]!(\n tokens,\n index,\n options,\n env,\n self\n );\n const caption = self.rules[\"footnoteCaption\"]!(\n tokens,\n index,\n options,\n env,\n self\n );\n\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 )}\" /></sup>`;\n};\n\nconst renderFootnoteBlockOpen: Renderer.RenderRule = (\n _tokens: FootNoteToken[],\n _index,\n options\n): string =>\n `${\n options.xhtmlOut\n ? '<hr class=\"footnotes-sep\" />\\n'\n : '<hr class=\"footnotes-sep\">\\n'\n }<section class=\"footnotes\">\\n<ol class=\"footnotes-list\">\\n`;\n\nconst renderFootnoteBlockClose = (): string => \"</ol>\\n</section>\\n\";\n\nconst renderFootnoteOpen: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n options,\n env: FootNoteEnv,\n self\n): string =>\n `<li id=\"footnote${self.rules[\"footnoteAnchorName\"]!(\n tokens,\n index,\n options,\n env,\n self\n )}${getIDSuffix(tokens, index)}\" class=\"footnote-item\">`;\n\nconst renderFootnoteClose = (): string => \"</li>\\n\";\n\nconst renderFootnoteAnchor: Renderer.RenderRule = (\n tokens: FootNoteToken[],\n index,\n options,\n env: FootNoteEnv,\n self\n): string => {\n return ` <a href=\"#footnote-ref${self.rules[\"footnoteAnchorName\"]!(\n tokens,\n index,\n options,\n env,\n self\n )}${\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\n// Process footnote block definition\nconst footnoteDef: RuleBlock = (\n state: FootNoteStateBlock,\n startLine,\n endLine,\n silent\n) => {\n let pos;\n let token;\n let offset;\n let ch;\n const start = state.bMarks[startLine] + state.tShift[startLine];\n const max = state.eMarks[startLine];\n\n // line should be at least 5 chars - \"[^x]:\"\n if (start + 4 > max) return false;\n\n if (state.src.charAt(start) !== \"[\") return false;\n\n if (state.src.charAt(start + 1) !== \"^\") return false;\n\n for (pos = start + 2; pos < max; pos++) {\n if (state.src.charAt(pos) === \" \") return false;\n if (state.src.charAt(pos) === \"]\") break;\n }\n\n // no empty footnote labels\n if (pos === start + 2) return false;\n\n if (pos + 1 >= max || state.src.charAt(++pos) !== \":\") return false;\n\n if (silent) return true;\n pos += 1;\n\n if (!state.env.footnotes) state.env.footnotes = {};\n if (!state.env.footnotes.refs) state.env.footnotes.refs = {};\n const label = state.src.slice(start + 2, pos - 2);\n\n state.env.footnotes.refs[`:${label}`] = -1;\n\n token = new Token(\"footnoteReferenceOpen\", \"\", 1);\n token.meta = { label };\n token.level = state.level++;\n state.tokens.push(token);\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] +\n pos -\n (state.bMarks[startLine] + state.tShift[startLine]);\n\n offset =\n state.sCount[startLine] +\n pos -\n (state.bMarks[startLine] + state.tShift[startLine]);\n\n while (pos < max) {\n ch = state.src.charAt(pos);\n\n if (ch === \"\\t\") offset += 4 - (offset % 4);\n else if (ch === \" \") offset += 1;\n else break;\n\n pos += 1;\n }\n\n state.tShift[startLine] = pos - posAfterColon;\n state.sCount[startLine] = offset - initial;\n\n state.bMarks[startLine] = posAfterColon;\n state.blkIndent += 4;\n state.parentType = \"footnote\" as unknown as StateBlock.ParentType;\n\n if (state.sCount[startLine] < state.blkIndent)\n 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 token = new Token(\"footnoteReferenceClose\", \"\", -1);\n token.level = --state.level;\n state.tokens.push(token);\n\n return true;\n};\n\n// Process inline footnotes (^[...])\nconst footnoteInline: RuleInline = (state: FootNoteStateInline, silent) => {\n let footnoteId;\n let token;\n let tokens: Token[];\n const max = state.posMax;\n const start = state.pos;\n\n if (start + 2 >= max) return false;\n if (state.src.charAt(start) !== \"^\") return false;\n\n if (state.src.charAt(start + 1) !== \"[\") return false;\n\n const labelStart = start + 2;\n const labelEnd = 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 /*\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 if (!silent) {\n if (!state.env.footnotes) state.env.footnotes = {};\n if (!state.env.footnotes.list) state.env.footnotes.list = [];\n footnoteId = state.env.footnotes.list.length;\n\n state.md.inline.parse(\n state.src.slice(labelStart, labelEnd),\n state.md,\n state.env,\n (tokens = [])\n );\n\n token = state.push(\"footnoteRef\", \"\", 0);\n token.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: RuleInline = (state: FootNoteStateInline, silent) => {\n let pos;\n let footnoteId;\n let footnoteSubId;\n let token;\n const max = state.posMax;\n const start = state.pos;\n\n // should be at least 4 chars - \"[^x]\"\n if (start + 3 > max) return false;\n\n if (!state.env.footnotes || !state.env.footnotes.refs) return false;\n if (state.src.charAt(start) !== \"[\") return false;\n\n if (state.src.charAt(start + 1) !== \"^\") return false;\n\n for (pos = start + 2; pos < max; pos++) {\n if (state.src.charAt(pos) === \" \") return false;\n if (state.src.charAt(pos) === \"\\n\") return false;\n if (state.src.charAt(pos) === \"]\") break;\n }\n\n if (pos === start + 2) return false; // no empty footnote labels\n if (pos >= max) return false;\n\n pos += 1;\n\n const label = state.src.slice(start + 2, pos - 1);\n\n if (typeof state.env.footnotes.refs[`:${label}`] === \"undefined\")\n return false;\n\n if (!silent) {\n if (!state.env.footnotes.list) state.env.footnotes.list = [];\n\n if (state.env.footnotes.refs[`:${label}`] < 0) {\n footnoteId = state.env.footnotes.list.length;\n state.env.footnotes.list[footnoteId] = { label, count: 0 };\n state.env.footnotes.refs[`:${label}`] = footnoteId;\n } else footnoteId = state.env.footnotes.refs[`:${label}`];\n\n footnoteSubId = state.env.footnotes.list[footnoteId].count!;\n state.env.footnotes.list[footnoteId].count =\n state.env.footnotes.list[footnoteId].count! + 1;\n\n token = state.push(\"footnoteRef\", \"\", 0);\n token.meta = { id: footnoteId, subId: footnoteSubId, 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 = (state: FootNoteStateCore): boolean => {\n let lastParagraph: FootNoteToken | null;\n let token: Token;\n let tokens: Token[];\n let current: Token[];\n let currentLabel: string;\n let insideRef = false;\n const refTokens: Record<string, Token[]> = {};\n\n if (!state.env.footnotes) return false;\n\n state.tokens = state.tokens.filter((stateToken) => {\n if (stateToken.type === \"footnoteReferenceOpen\") {\n insideRef = true;\n current = [];\n currentLabel = stateToken.meta.label;\n\n return false;\n }\n if (stateToken.type === \"footnoteReferenceClose\") {\n insideRef = false;\n // prepend ':' to avoid conflict with Object.prototype members\n refTokens[`:${currentLabel}`] = current;\n\n return false;\n }\n if (insideRef) current.push(stateToken);\n\n return !insideRef;\n });\n\n if (!state.env.footnotes.list) return false;\n const { list } = state.env.footnotes;\n\n token = new Token(\"footnoteBlockOpen\", \"\", 1);\n state.tokens.push(token);\n\n for (let i = 0, { length } = list; i < length; i++) {\n token = new Token(\"footnoteOpen\", \"\", 1);\n token.meta = { id: i, label: list[i].label };\n state.tokens.push(token);\n\n if (list[i].tokens) {\n tokens = [];\n\n token = new Token(\"paragraph_open\", \"p\", 1);\n token.block = true;\n tokens.push(token);\n\n token = new Token(\"inline\", \"\", 0);\n token.children = list[i].tokens!;\n token.content = list[i].content!;\n tokens.push(token);\n\n token = new Token(\"paragraph_close\", \"p\", -1);\n token.block = true;\n tokens.push(token);\n } else if (list[i].label) tokens = refTokens[`:${list[i].label!}`];\n else tokens = [];\n\n if (tokens) state.tokens = state.tokens.concat(tokens);\n if (state.tokens[state.tokens.length - 1].type === \"paragraph_close\")\n lastParagraph = state.tokens.pop() || null;\n else lastParagraph = null;\n\n for (let j = 0; j < (Number(list[i].count) > 0 ? list[i].count! : 1); j++) {\n token = new Token(\"footnoteAnchor\", \"\", 0);\n token.meta = { id: i, subId: j, label: list[i].label };\n state.tokens.push(token);\n }\n\n if (lastParagraph) state.tokens.push(lastParagraph);\n\n token = new Token(\"footnoteClose\", \"\", -1);\n state.tokens.push(token);\n }\n\n token = new Token(\"footnoteBlockClose\", \"\", -1);\n state.tokens.push(token);\n\n return true;\n};\n\nexport const footnote: PluginSimple = (md) => {\n md.renderer.rules[\"footnoteRef\"] = renderFootnoteRef;\n md.renderer.rules[\"footnoteBlockOpen\"] = renderFootnoteBlockOpen;\n md.renderer.rules[\"footnoteBlockClose\"] = renderFootnoteBlockClose;\n md.renderer.rules[\"footnoteOpen\"] = renderFootnoteOpen;\n md.renderer.rules[\"footnoteClose\"] = renderFootnoteClose;\n md.renderer.rules[\"footnoteAnchor\"] = 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[\"footnoteCaption\"] = renderFootnoteCaption;\n md.renderer.rules[\"footnoteAnchorName\"] = 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\", \"footnoteRef\", footnoteRef);\n md.core.ruler.after(\"inline\", \"footnoteTail\", footnoteTail);\n};\n"],"names":["getIDSuffix","tokens","index","renderFootnoteAnchorName","_options","env","renderFootnoteCaption","renderFootnoteRef","options","self","id","caption","renderFootnoteBlockOpen","_tokens","_index","renderFootnoteBlockClose","renderFootnoteOpen","renderFootnoteClose","renderFootnoteAnchor","footnoteDef","state","startLine","endLine","silent","pos","token","offset","ch","start","max","label","Token","oldBMark","oldTShift","oldSCount","oldParentType","posAfterColon","initial","footnoteInline","footnoteId","labelStart","labelEnd","parseLinkLabel","footnoteRef","footnoteSubId","footnoteTail","lastParagraph","current","currentLabel","insideRef","refTokens","stateToken","list","i","length","j","footnote","md"],"mappings":"mGA+BA,MAAMA,EAAc,CAACC,EAAyBC,IAE5CD,EAAOC,GAAO,KAAK,MAAQ,EAAI,IAAID,EAAOC,GAAO,KAAK,QAAU,GAE5DC,EAAgD,CACpDF,EAC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C,YAAa,WAAW,CAChC,CAAC,EACDsC,EAAG,OAAO,MAAM,MAAM,QAAS,iBAAkBnB,CAAc,EAC/DmB,EAAG,OAAO,MAAM,MAAM,iBAAkB,cAAed,CAAW,EAClEc,EAAG,KAAK,MAAM,MAAM,SAAU,eAAgBZ,CAAY,CAC5D"}
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@mdit/plugin-footnote",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "footnote plugin for MarkdownIt",
5
+ "keywords": [
6
+ "markdownit",
7
+ "markdown-it",
8
+ "markdown-it-plugin",
9
+ "footnote"
10
+ ],
11
+ "homepage": "https://github.com/Mister-Hope//mdit-plugins/packages/footnote#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/Mister-Hope//mdit-plugins/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/Mister-Hope//mdit-plugins.git",
18
+ "directory": "packages/footnote"
19
+ },
20
+ "license": "MIT",
21
+ "author": {
22
+ "name": "Mr.Hope",
23
+ "email": "mister-hope@outlook.com",
24
+ "url": "https://mrhope.site"
25
+ },
26
+ "main": "lib/index.cjs",
27
+ "types": "lib/index.d.ts",
28
+ "exports": {
29
+ ".": "./lib/index.mjs",
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "lib"
34
+ ],
35
+ "dependencies": {
36
+ "@types/markdown-it": "^12.2.3",
37
+ "markdown-it": "^13.0.1"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "build": "rollup -c rollup.config.ts --configPlugin esbuild",
44
+ "clean": "rimraf ./lib"
45
+ }
46
+ }