@mdit/plugin-attrs 0.21.0 → 0.22.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/lib/browser.js +2 -2
- package/lib/browser.js.map +1 -1
- package/lib/index.d.ts +8 -5
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/lib/browser.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const
|
|
2
|
-
{.a} softbreak then curly in start`,tests:[{shift:0,type:"inline",children:[{position:-2,type:"softbreak"},{position:-1,type:"text",content:
|
|
1
|
+
const u=(e,t)=>{t&&e.forEach(([s,n])=>{switch(s){case"class":t.attrJoin("class",n);break;case"css-module":t.attrJoin("css-module",n);break;default:t.attrPush([s,n])}})},_=".",x="#",v=/[^\t\n\f />"'=]/,O=" ",E="=",d=(e,t,{left:s,right:n,allowed:o})=>{let i="",l="",r=!0,c=!1;const f=[];for(let h=t+s.length;h<e.length;h++){if(e.slice(h,h+n.length)===n){i!==""&&f.push([i,l]);break}const a=e.charAt(h);if(a===E&&r){r=!1;continue}if(a===_&&i===""){e.charAt(h+1)===_?(i="css-module",h++):i="class",r=!1;continue}if(a===x&&i===""){i="id",r=!1;continue}if(a==='"'&&l===""&&!c){c=!0;continue}if(a==='"'&&c){c=!1;continue}if(a===O&&!c){if(i==="")continue;f.push([i,l]),i="",l="",r=!0;continue}if(!(r&&a.search(v)===-1)){if(r){i+=a;continue}l+=a}}return o.length?f.filter(([h])=>o.some(a=>a instanceof RegExp?a.test(h):a===h)):f},y=({left:e,right:t},s)=>{if(!["start","end","only"].includes(s))throw new Error(`Invalid 'where' parameter: ${s}. Expected 'start', 'end', or 'only'.`);return n=>{const o=e.length,i=t.length,l=o+1+i,r=o+1;if(!n||typeof n!="string"||n.length<l)return!1;const c=p=>[_,x].includes(p.charAt(o))?p.length>=l+1:p.length>=l;let f,h,a,m;return s==="start"?(a=n.slice(0,o),f=a===e?0:-1,h=f===-1?-1:n.indexOf(t,r),m=n.charAt(h+i),m&&t.includes(m)&&(h=-1)):s==="end"?(f=n.lastIndexOf(e),h=f===-1?-1:n.indexOf(t,f+r),h=h===n.length-i?h:-1):(a=n.slice(0,o),f=a===e?0:-1,a=n.slice(n.length-i),h=a===t?n.length-i:-1),f!==-1&&h!==-1&&c(n.substring(f,h+i))}},g=(e,t)=>{const s=e[t];if(s.type==="softbreak")return null;if(s.nesting===0)return s;const n=s.level,o=s.type.replace("_close","_open");for(;t>=0;){const i=e[t];if(i.type===o&&i.level===n)return i;t--}/* istanbul ignore next -- @preserve */return null},b=e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),w=(e,t,s)=>{const n=b(t),o=b(s),i=e.search(new RegExp(`[ \\n]?${n}[^${n}${o}]+${o}$`));return i!==-1?e.slice(0,i):e},$=(e,t)=>t>=0?e[t]:e[e.length+t],C=e=>Array.isArray(e)&&!!e.length&&e.every(t=>typeof t=="function"),I=e=>Array.isArray(e)&&!!e.length&&e.every(t=>typeof t=="object"),k=(e,t,s)=>{const n={match:!1,position:null},o=s.shift!==void 0?t+s.shift:s.position;if(s.shift!==void 0&&o<0)return n;const i=$(e,o);if(!i)return n;for(const l of Object.keys(s)){if(l==="shift"||l==="position")continue;if(i[l]===void 0)return n;if(l==="children"&&I(s.children)){if(i.children?.length===0)return n;let c;const f=s.children,h=i.children;if(f.every(a=>a.position!==void 0)){if(c=f.every(a=>k(h,a.position,a).match),c){const a=f[f.length-1]?.position??0;n.position=a>=0?a:h.length+a}}else for(let a=0;a<h.length;a++)if(c=f.every(m=>k(h,a,m).match),c){n.position=a;break}if(c===!1)return n;continue}const r=s[l];switch(typeof r){case"boolean":case"number":case"string":{if(i[l]!==r)return n;break}case"function":{if(!r(i[l]))return n;break}default:{if(C(r)){if(!r.every(c=>c(i[l])))return n;break}throw new Error(`Unknown type of pattern test (key: ${l}). Test should be of type boolean, number, string, function or array of functions.`)}}}return n.match=!0,n},S=e=>({name:"end of block",tests:[{shift:0,type:"inline",children:[{position:-1,content:y(e,"end"),type:t=>t!=="code_inline"&&t!=="math_inline"}]}],transform:(t,s,n)=>{const o=t[s].children[n],{content:i}=o,l=i.lastIndexOf(e.left),r=d(i,l,e);let c=s+1;for(;t[c+1]&&t[c+1].nesting===-1;)c++;const f=g(t,c);u(r,f);const h=i.slice(0,l),a=h[h.length-1]===" ";o.content=a?h.slice(0,-1):h}}),T=e=>({name:"code-block",tests:[{shift:0,block:!0,info:y(e,"end")}],transform:(t,s)=>{const n=t[s];let o="";const i=/{(?:[\d,-]+)}/.exec(n.info);i&&(n.info=n.info.replace(i[0],""),o=i[0]);const l=n.info.lastIndexOf(e.left),r=d(n.info,l,e);u(r,n);const c=w(n.info,e.left,e.right);n.info=`${c} ${o}`.trim()}}),D=e=>[{name:"inline nesting self-close",tests:[{shift:0,type:"inline",children:[{shift:-1,type:t=>t==="image"||t==="code_inline"},{shift:0,type:"text",content:y(e,"start")}]}],transform:(t,s,n)=>{const o=e.right.length,i=t[s].children[n],l=i.content.indexOf(e.right),r=t[s].children[n-1],c=d(i.content,0,e);u(c,r),i.content.length===l+o?t[s].children.splice(n,1):i.content=i.content.slice(l+o)}},{name:"inline attributes",tests:[{shift:0,type:"inline",children:[{shift:-1,nesting:-1},{shift:0,type:"text",content:y(e,"start")}]}],transform:(t,s,n)=>{const o=t[s].children[n],{content:i}=o,l=d(i,0,e),r=g(t[s].children,n-1);u(l,r);const c=i.indexOf(e.right)+e.right.length;o.content=i.slice(c)}}],K=e=>[{name:"list softbreak",tests:[{shift:-2,type:"list_item_open"},{shift:0,type:"inline",children:[{position:-2,type:"softbreak"},{position:-1,type:"text",content:y(e,"only")}]}],transform:(t,s,n)=>{const o=t[s].children[n],i=d(o.content,0,e);let l=s-2;for(;t[l-1]&&t[l-1].type!=="ordered_list_open"&&t[l-1].type!=="bullet_list_open";)l--;u(i,t[l-1]),t[s].children=t[s].children.slice(0,-2)}},{name:"list double softbreak",tests:[{shift:0,type:t=>t==="bullet_list_close"||t==="ordered_list_close"},{shift:1,type:"paragraph_open"},{shift:2,type:"inline",content:y(e,"only"),children:t=>t.length===1},{shift:3,type:"paragraph_close"}],transform:(t,s)=>{const n=t[s+2],o=d(n.content,0,e),i=g(t,s);u(o,i),t.splice(s+1,3)}},{name:"list item end",tests:[{shift:-2,type:"list_item_open"},{shift:0,type:"inline",children:[{position:-1,type:"text",content:y(e,"end")}]}],transform:(t,s,n)=>{const o=t[s].children[n],{content:i}=o,l=i.lastIndexOf(e.left),r=d(i,l,e);u(r,t[s-2]);const c=i.slice(0,l),f=c[c.length-1]===" ";o.content=f?c.slice(0,-1):c}}],L=e=>({name:`
|
|
2
|
+
{.a} softbreak then curly in start`,tests:[{shift:0,type:"inline",children:[{position:-2,type:"softbreak"},{position:-1,type:"text",content:y(e,"only")}]}],transform:(t,s,n)=>{const o=t[s].children[n],i=d(o.content,0,e);let l=s+1;for(;t[l+1]&&t[l+1].nesting===-1;)l++;const r=g(t,l);u(i,r),t[s].children=t[s].children.slice(0,-2)}}),M=e=>({name:"horizontal rule",tests:[{shift:0,type:"paragraph_open"},{shift:1,type:"inline",children:t=>t.length===1,content:t=>new RegExp(`^ {0,3}[-*_]{3,} ?${b(e.left)}[^${b(e.right)}]`).test(t)},{shift:2,type:"paragraph_close"}],transform:(t,s)=>{const n=t[s];n.type="hr",n.tag="hr",n.nesting=0;const o=t[s+1],{content:i}=o,l=i.lastIndexOf(e.left),r=d(i,l,e);u(r,n),n.markup=i,t.splice(s+1,2)}}),A=e=>{e.hidden=!0,e.children?.forEach(t=>{t.content="",A(t)})},P=(e,t,s,n,o,i)=>{let l=n-(o>0?o:1);for(let r=t,c=i;r<s&&c>1;r++)if(e[r].type==="tr_open"){const f=e[r];f.meta??={},f.meta.columnCount&&(l-=1),f.meta.columnCount=l,c--}},j=(e,t,s)=>{const n=e[t].meta?.columnCount;if(n)for(let o=t,i=0;o<s;o++){const l=e[o];if(l.type==="td_open")i+=1;else if(l.type==="tr_close")break;i>n&&!l.hidden&&A(l)}},N=(e,t,s,n,o,i)=>{const l=[],r=e[t];let c=t+3,f=n;for(let p=t;p>i;p--)if(e[p].type==="tr_open"){f=e[p].meta?.columnCount??f;break}else e[p].type==="td_open"&&l.unshift(p);for(let p=t+2;p<s;p++)if(e[p].type==="tr_close"){c=p;break}else e[p].type==="td_open"&&l.push(p);const h=l.indexOf(t),a=Math.min(o,f-h);o>a&&r.attrSet("colspan",a.toString());const m=l.slice(f+1-n-a)[0];for(let p=m;p<c;p++)e[p].hidden||A(e[p])},B=e=>[{name:"table",tests:[{shift:0,type:"table_close"},{shift:1,type:"paragraph_open"},{shift:2,type:"inline",content:y(e,"only")}],transform:(t,s)=>{const n=t[s+2],o=g(t,s),i=d(n.content,0,e);u(i,o),t.splice(s+1,3)}},{name:"table cell attributes",tests:[{shift:-1,type:t=>t==="td_open"||t==="th_open"},{shift:0,type:"inline",children:[{shift:0,type:"text",content:y(e,"end")}]}],transform:(t,s,n)=>{const o=t[s].children[n],i=t[s-1],{content:l}=o,r=l.lastIndexOf(e.left),c=d(l,r,e);u(c,i),o.content=l.substring(0,r).trim()}},{name:"table thead metadata",tests:[{shift:0,type:"tr_close"},{shift:1,type:"thead_close"},{shift:2,type:"tbody_open"}],transform:(t,s)=>{const n=g(t,s),o=t[s-1];let i=0,l=s-1;for(;l>0;){const c=t[l];if(c===n){const f=t[l-1];f.meta={...f.meta,columnCount:i};break}c.level===o.level&&c.type===o.type&&i++,l--}const r=t[s+2];r.meta={...r.meta,columnCount:i}}},{name:"table tbody calculate",tests:[{shift:0,type:"tbody_close",hidden:!1}],transform:(t,s)=>{let n=s-2;for(;n>0&&(n--,t[n].type!=="tbody_open"););const o=Number(t[n].meta?.columnCount??0);if(o<2)return;const i=t[s].level+2;for(let l=n;l<s;l++){if(t[l].level>i)continue;const r=t[l],c=r.hidden?0:Number(r.attrGet("rowspan")),f=r.hidden?0:Number(r.attrGet("colspan"));c>1&&P(t,l,s,o,f,c),r.type==="tr_open"&&j(t,l,s),f>1&&N(t,l,s,o,f,n)}}}],R=["fence","inline","table","list","hr","softbreak","block"],F=e=>{const t=e.rule===!1?[]:Array.isArray(e.rule)?e.rule.filter(n=>R.includes(n)):R,s=[];return t.includes("fence")&&s.push(T(e)),t.includes("inline")&&s.push(...D(e)),t.includes("table")&&s.push(...B(e)),t.includes("list")&&s.push(...K(e)),t.includes("softbreak")&&s.push(L(e)),t.includes("hr")&&s.push(M(e)),t.includes("block")&&s.push(S(e)),s},G=(e,{left:t="{",right:s="}",allowed:n=[],rule:o="all"}={})=>{const i=F({left:t,right:s,allowed:n,rule:o}),l=({tokens:r})=>{for(let c=0;c<r.length;c++)for(let f=0;f<i.length;f++){const h=i[f];let a=null;h.tests.every(m=>{const p=k(r,c,m);return p.position!==null&&({position:a}=p),p.match})&&(h.transform(r,c,a),(h.name==="inline attributes"||h.name==="inline nesting self-close")&&f--)}};e.core.ruler.before("linkify","attrs",l)};export{G as attrs};
|
|
3
3
|
//# sourceMappingURL=browser.js.map
|
package/lib/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sources":["../../helper/lib/index.js","../src/attrs.ts","../src/helper.ts","../src/rules/rules.ts","../src/utils.ts","../src/rules/test.ts","../src/plugin.ts"],"sourcesContent":["const l=e=>{const n=e.split(`\n`),p=n.reduce((r,c)=>{for(let t=0;t<c.length;t++)if(c[t]!==\" \"&&c[t]!==\"\t\")return Math.min(t,r);return r},1/0);return p<1/0?n.map(r=>r.slice(p)).join(`\n`):e},a=e=>e.replace(/&/gu,\"&\").replace(/</gu,\"<\").replace(/>/gu,\">\").replace(/\"/gu,\""\").replace(/'/gu,\"'\"),g=e=>e.replace(/[-/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\"),u=/\\r\\n?|\\n/g,s=/\\\\([ \\\\!\"#$%&'()*+,./:;<=>?@[\\]^_`{|}~-])/gu;export{u as NEWLINE_RE,s as UNESCAPE_RE,l as dedent,a as escapeHtml,g as escapeRegExp};\n//# sourceMappingURL=index.js.map\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\n\nexport type Attr = [key: string, value: string];\n\n// not tab, line feed, form feed, space, solidus, greater than sign, quotation mark, apostrophe and equals sign\nexport const ALLOWED_KEY_CHARS = /[^\\t\\n\\f />\"'=]/;\nexport const PAIR_SEPARATOR = \" \";\nexport const KEY_SEPARATOR = \"=\";\nexport const CLASS_MARKER = \".\";\nexport const ID_MARKER = \"#\";\n\nexport const getAttrs = (\n str: string,\n start: number,\n { left, right, allowed }: Required<Omit<MarkdownItAttrsOptions, \"rule\">>,\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside {}\n // start + left delimiter length to avoid beginning {\n // breaks when } is found or end of string\n for (let index = start + left.length; index < str.length; index++) {\n if (str.slice(index, index + right.length) === right) {\n if (key !== \"\") attrs.push([key, value]);\n break;\n }\n\n const char = str.charAt(index);\n\n // switch to reading value if equal sign\n if (char === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (char === CLASS_MARKER && key === \"\") {\n if (str.charAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (char === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (char === '\"' && value === \"\") {\n valueInsideQuotes = true;\n continue;\n }\n\n if (char === '\"' && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (char === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\")\n // beginning or ending space: { .red } vs {.red}\n continue;\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && char.search(ALLOWED_KEY_CHARS) === -1) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += char;\n continue;\n }\n\n value += char;\n }\n\n return allowed.length\n ? attrs.filter(([attr]) =>\n allowed.some((item) =>\n item instanceof RegExp ? item.test(attr) : item === attr,\n ),\n )\n : attrs;\n};\n\nexport const addAttrs = (attrs: Attr[], token: Token | null): void => {\n if (token)\n attrs.forEach((attrItem) => {\n const [key, value] = attrItem;\n\n if (key === \"class\") token.attrJoin(\"class\", value);\n else if (key === \"css-module\") token.attrJoin(\"css-module\", value);\n else token.attrPush(attrItem);\n });\n};\n","import { escapeRegExp } from \"@mdit/helper\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nexport const hasDelimiters =\n (\n where: \"start\" | \"end\" | \"only\",\n left: string,\n right: string,\n ): ((content: string) => boolean) =>\n (content: string): boolean => {\n const leftLength = left.length;\n const rightLength = right.length;\n // we need minimum three chars, for example {b}\n const minCurlyLength = leftLength + 1 + rightLength;\n\n if (\n !content ||\n typeof content !== \"string\" ||\n content.length < minCurlyLength\n )\n return false;\n\n const validCurlyLength = (curly: string): boolean => {\n const isClass = curly.charAt(leftLength) === \".\";\n const isId = curly.charAt(leftLength) === \"#\";\n\n return isClass || isId\n ? curly.length >= minCurlyLength + 1\n : curly.length >= minCurlyLength;\n };\n\n let start, end, slice, nextChar;\n const rightDelimiterMinimumShift = minCurlyLength - rightLength;\n\n switch (where) {\n case \"start\":\n // first char should be {, } found in char 2 or more\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n end =\n start === -1\n ? -1\n : content.indexOf(right, rightDelimiterMinimumShift);\n // check if next character is not one of the delimiters\n nextChar = content.charAt(end + rightLength);\n if (nextChar && right.includes(nextChar)) end = -1;\n break;\n\n case \"end\":\n // last char should be }\n start = content.lastIndexOf(left);\n end =\n start === -1\n ? -1\n : content.indexOf(right, start + rightDelimiterMinimumShift);\n end = end === content.length - rightLength ? end : -1;\n break;\n\n case \"only\":\n // '{.a}'\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n slice = content.slice(content.length - rightLength);\n end = slice === right ? content.length - rightLength : -1;\n break;\n }\n\n return (\n start !== -1 &&\n end !== -1 &&\n validCurlyLength(content.substring(start, end + rightLength))\n );\n };\n\nexport const removeDelimiter = (\n str: string,\n left: string,\n right: string,\n): string => {\n const start = escapeRegExp(left);\n const end = escapeRegExp(right);\n const pos = str.search(\n new RegExp(`[ \\\\n]?${start}[^${start}${end}]+${end}$`),\n );\n\n return pos !== -1 ? str.slice(0, pos) : str;\n};\n\nexport const getMatchingOpeningToken = (\n tokens: Token[],\n index: number,\n): Token | null => {\n if (tokens[index].type === \"softbreak\") return null;\n\n // non closing blocks, example img\n if (tokens[index].nesting === 0) return tokens[index];\n\n const level = tokens[index].level;\n const type = tokens[index].type.replace(\"_close\", \"_open\");\n\n for (; index >= 0; --index)\n if (tokens[index].type === type && tokens[index].level === level)\n return tokens[index];\n\n return null;\n};\n","import { escapeRegExp } from \"@mdit/helper\";\n\nimport type { Rule } from \"./types.js\";\nimport { addAttrs, getAttrs } from \"../attrs.js\";\nimport {\n getMatchingOpeningToken,\n hasDelimiters,\n removeDelimiter,\n} from \"../helper.js\";\nimport type {\n MarkdownItAttrRuleName,\n MarkdownItAttrsOptions,\n} from \"../options.js\";\n\nconst getFenceRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n\n // fenced code blocks\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: hasDelimiters(\"end\", options.left, options.right),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n let lineNumber = \"\";\n\n // special handler for VuePress line number\n const results = /{(?:[\\d,-]+)}/.exec(token.info);\n\n if (results) {\n token.info = token.info.replace(results[0], \"\");\n lineNumber = results[0];\n }\n\n const start = token.info.lastIndexOf(options.left);\n const attrs = getAttrs(token.info, start, options);\n\n addAttrs(attrs, token);\n token.info = `${removeDelimiter(\n token.info,\n options.left,\n options.right,\n )} ${lineNumber}`;\n },\n});\n\nconst getInlineRules = (options: Required<MarkdownItAttrsOptions>): Rule[] => [\n /**\n * bla `click()`{.c} {.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n {\n name: \"inline nesting 0\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: hasDelimiters(\"start\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n\n const endChar = token.content.indexOf(options.right);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const attrToken = tokens[index].children![childIndex - 1];\n const attrs = getAttrs(token.content, 0, options);\n\n addAttrs(attrs, attrToken);\n if (token.content.length === endChar + options.right.length)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!.splice(childIndex, 1);\n else token.content = token.content.slice(endChar + options.right.length);\n },\n },\n\n /**\n * *emphasis*{.with attrs=1}\n */\n {\n name: \"inline attributes\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n nesting: -1, // closing inline tag, </em>{.a}\n },\n {\n shift: 0,\n type: \"text\",\n content: hasDelimiters(\"start\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const attrs = getAttrs(content, 0, options);\n const openingToken = getMatchingOpeningToken(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!,\n childIndex - 1,\n );\n\n addAttrs(attrs, openingToken);\n token.content = content.slice(\n content.indexOf(options.right) + options.right.length,\n );\n },\n },\n];\n\nconst getTableRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * | h1 |\n * | -- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: hasDelimiters(\"only\", options.left, options.right),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const tableOpen = getMatchingOpeningToken(tokens, index);\n const attrs = getAttrs(token.content, 0, options);\n\n // add attributes\n addAttrs(attrs, tableOpen);\n // remove <p>{.c}</p>\n tokens.splice(index + 1, 3);\n },\n});\n\nconst getListRules = (options: Required<MarkdownItAttrsOptions>): Rule[] => [\n /**\n * - item\n * {.a}\n */\n {\n name: \"list softbreak\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: hasDelimiters(\"only\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, indx, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[indx].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n let ii = indx - 2;\n\n while (\n tokens[ii - 1] &&\n tokens[ii - 1].type !== \"ordered_list_open\" &&\n tokens[ii - 1].type !== \"bullet_list_open\"\n )\n ii--;\n\n addAttrs(attrs, tokens[ii - 1]);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[indx].children = tokens[indx].children!.slice(0, -2);\n },\n },\n\n /**\n * - nested list\n * - with double \\n\n * {.a} <-- apply to nested ul\n *\n * {.b} <-- apply to root <ul>\n */\n {\n name: \"list double softbreak\",\n tests: [\n {\n // let this token be i = 0 so that we can erase\n // the <p>{.a}</p> tokens below\n shift: 0,\n type: (type) =>\n type === \"bullet_list_close\" || type === \"ordered_list_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: hasDelimiters(\"only\", options.left, options.right),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const attrs = getAttrs(token.content, 0, options);\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n addAttrs(attrs, openingToken);\n tokens.splice(index + 1, 3);\n },\n },\n\n /**\n * - end of {.list-item}\n */\n {\n name: \"list item end\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n type: \"text\",\n content: hasDelimiters(\"end\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const attrs = getAttrs(\n content,\n content.lastIndexOf(options.left),\n options,\n );\n\n addAttrs(attrs, tokens[index - 2]);\n\n const trimmed = content.slice(0, content.lastIndexOf(options.left));\n\n token.content =\n trimmed[trimmed.length - 1] === \" \" ? trimmed.slice(0, -1) : trimmed;\n },\n },\n];\n\nconst getSoftBreakRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * something with softbreak\n * {.cls}\n */\n\n name: \"\\n{.a} softbreak then curly in start\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: hasDelimiters(\"only\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n\n // find last closing tag\n let ii = index + 1;\n\n while (tokens[ii + 1] && tokens[ii + 1].nesting === -1) ii++;\n\n const openingToken = getMatchingOpeningToken(tokens, ii);\n\n addAttrs(attrs, openingToken);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children = tokens[index].children!.slice(0, -2);\n },\n});\n\nconst getHrRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * horizontal rule --- {#id}\n */\n name: \"horizontal rule\",\n tests: [\n {\n shift: 0,\n type: \"paragraph_open\",\n },\n {\n shift: 1,\n type: \"inline\",\n children: (children) => children.length === 1,\n content: (content) =>\n new RegExp(\n `^ {0,3}[-*_]{3,} ?${escapeRegExp(options.left)}[^${escapeRegExp(\n options.right,\n )}]`,\n ).test(content),\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n const { content } = tokens[index + 1];\n const start = content.lastIndexOf(options.left);\n const attrs = getAttrs(content, start, options);\n\n addAttrs(attrs, token);\n token.markup = content;\n tokens.splice(index + 1, 2);\n },\n});\n\nconst getBlockRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * end of {.block}\n */\n\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: hasDelimiters(\"end\", options.left, options.right),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, indx, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[indx].children![childIndex];\n const { content } = token;\n const attrs = getAttrs(content, content.lastIndexOf(options.left), options);\n let ii = indx + 1;\n\n while (tokens[ii + 1] && tokens[ii + 1].nesting === -1) ii++;\n\n const openingToken = getMatchingOpeningToken(tokens, ii);\n\n addAttrs(attrs, openingToken);\n\n const trimmed = content.slice(0, content.lastIndexOf(options.left));\n\n token.content =\n trimmed[trimmed.length - 1] === \" \" ? trimmed.slice(0, -1) : trimmed;\n },\n});\n\nconst availableRules: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const getRules = (options: Required<MarkdownItAttrsOptions>): Rule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => availableRules.includes(item))\n : availableRules;\n\n const rules: Rule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(getFenceRule(options));\n if (enabledRules.includes(\"inline\")) rules.push(...getInlineRules(options));\n if (enabledRules.includes(\"list\")) rules.push(...getListRules(options));\n if (enabledRules.includes(\"table\")) rules.push(getTableRule(options));\n if (enabledRules.includes(\"softbreak\")) rules.push(getSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(getHrRule(options));\n if (enabledRules.includes(\"block\")) rules.push(getBlockRule(options));\n\n return rules;\n};\n","/**\n * Get amount item of array. Supports negative amount, where -1 is last\n * element in array.\n */\nexport const getElements = <T>(arr: T[], amount: number): T =>\n amount >= 0 ? arr[amount] : arr[arr.length + amount];\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const isArrayOfFunctions = (arr: unknown): arr is Function[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"function\");\n\nexport const isArrayOfObjects = (arr: unknown): arr is object[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"object\");\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { RuleSet } from \"./types.js\";\nimport { getElements, isArrayOfFunctions, isArrayOfObjects } from \"../utils.js\";\n\n/**\n * Test if rule matches token stream.\n *\n */\nexport const testRule = (\n tokens: Token[],\n index: number,\n rule: RuleSet,\n): { match: boolean; position: null | number } => {\n const res = {\n match: false,\n position: null as number | null, // position of child\n };\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const ii = rule.shift !== undefined ? index + rule.shift : rule.position!;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (rule.shift !== undefined && ii < 0) return res;\n\n // supports negative ii\n const token = getElements(tokens, ii);\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (token === undefined) return res;\n\n for (const key of Object.keys(rule) as (keyof typeof rule)[]) {\n if (key === \"shift\" || key === \"position\") continue;\n\n if (token[key as keyof Token] === undefined) return res;\n\n if (key === \"children\" && isArrayOfObjects(rule.children)) {\n if (token.children?.length === 0) return res;\n\n let match;\n const childTests = rule.children;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const children = token.children!;\n\n if (childTests.every((tt) => tt.position !== undefined)) {\n // positions instead of shifts, do not loop all children\n match = childTests.every(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (tt) => testRule(children, tt.position!, tt).match,\n );\n\n if (match) {\n // we may need position of child in transform\n const j = childTests[childTests.length - 1]?.position ?? 0;\n\n res.position = j >= 0 ? j : children.length + j;\n }\n } else {\n for (let j = 0; j < children.length; j++) {\n match = childTests.every((tt) => testRule(children, j, tt).match);\n\n if (match) {\n res.position = j;\n // all tests true, continue with next key of pattern t\n break;\n }\n }\n }\n\n if (match === false) return res;\n\n continue;\n }\n\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n if (token[key] !== ruleDetail) return res;\n\n break;\n\n case \"function\":\n // @ts-expect-error: ruleDetail is a function\n if (!ruleDetail(token[key])) return res;\n\n break;\n\n case \"object\":\n if (isArrayOfFunctions(ruleDetail)) {\n const r = ruleDetail.every((tt) =>\n (tt as (key: unknown) => boolean)(token[key]),\n );\n\n if (!r) return res;\n\n break;\n }\n\n continue;\n\n // fall through for objects !== arrays of functions\n default:\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string, function or array of functions.`,\n );\n }\n }\n\n // no tests returned false -> all tests returns true\n res.match = true;\n\n return res;\n};\n","/**\n * Forked and modified from https://github.com/arve0/markdown-it-attrs/\n */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport { getRules, testRule } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = getRules({\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = ({ tokens }) => {\n for (let index = 0; index < tokens.length; index++)\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n\n const match = pattern.tests.every((t) => {\n const result = testRule(tokens, index, t);\n\n if (result.position !== null) ({ position } = result);\n\n return result.match;\n });\n\n if (match) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n pattern.transform(tokens, index, position!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting 0\"\n )\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"names":["g","ALLOWED_KEY_CHARS","PAIR_SEPARATOR","KEY_SEPARATOR","CLASS_MARKER","ID_MARKER","getAttrs","str","start","left","right","allowed","key","value","parsingKey","valueInsideQuotes","attrs","index","char","attr","item","addAttrs","token","attrItem","hasDelimiters","where","content","leftLength","rightLength","minCurlyLength","validCurlyLength","curly","isClass","isId","end","slice","nextChar","rightDelimiterMinimumShift","removeDelimiter","escapeRegExp","pos","getMatchingOpeningToken","tokens","level","type","getFenceRule","options","lineNumber","results","getInlineRules","childIndex","endChar","attrToken","openingToken","getTableRule","tableOpen","getListRules","indx","ii","children","trimmed","getSoftBreakRule","getHrRule","getBlockRule","availableRules","getRules","enabledRules","rules","getElements","arr","amount","isArrayOfFunctions","isArrayOfObjects","testRule","rule","res","match","childTests","tt","j","ruleDetail","md","attrsRule","ruleIndex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,OAAO+D,EAEpC,MAEF,IAAK,SACH,GAAIJ,EAAmBS,CAAU,EAAG,CAKlC,GAAI,CAJMA,EAAW,MAAOF,GACzBA,EAAiCxD,EAAMV,CAAG,CAAC,CAC9C,EAEQ,OAAO+D,EAEf,KACF,CAEA,SAGF,QACE,MAAM,IAAI,MACR,sCAAsC/D,CAAG,oFAC3C,CACJ,CACF,CAGA,OAAA+D,EAAI,MAAQ,GAELA,CACT,ECzGa3D,EAAmD,CAC9DiE,EACA,CAAE,KAAAxE,EAAO,IAAK,MAAAC,EAAQ,IAAK,QAAAC,EAAU,CAAA,EAAI,KAAA+D,EAAO,KAAM,EAAI,CAAA,IACvD,CACH,MAAMP,EAAQF,EAAS,CACrB,KAAAxD,EACA,MAAAC,EACA,QAAAC,EACA,KAAA+D,CACF,CAAC,EAEKQ,EAAsB,CAAC,CAAE,OAAAxC,CAAO,IAAM,CAC1C,QAASzB,EAAQ,EAAGA,EAAQyB,EAAO,OAAQzB,IACzC,QAASkE,EAAY,EAAGA,EAAYhB,EAAM,OAAQgB,IAAa,CAC7D,MAAMC,EAAUjB,EAAMgB,CAAS,EAE/B,IAAIE,EAA0B,KAEhBD,EAAQ,MAAM,MAAOE,GAAM,CACvC,MAAMC,EAASd,EAAS/B,EAAQzB,EAAOqE,CAAC,EAExC,OAAIC,EAAO,WAAa,OAAO,CAAE,SAAAF,CAAS,EAAIE,GAEvCA,EAAO,KAChB,CAAC,IAICH,EAAQ,UAAU1C,EAAQzB,EAAOoE,CAAS,GAGxCD,EAAQ,OAAS,qBACjBA,EAAQ,OAAS,qBAGjBD,IAEN,CACJ,EAEAF,EAAG,KAAK,MAAM,OAAO,UAAW,QAASC,CAAS,CACpD"}
|
|
1
|
+
{"version":3,"file":"browser.js","sources":["../src/helper/addAttrs.ts","../src/helper/constants.ts","../src/helper/getAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../../helper/lib/index.js","../src/helper/removeDelimiter.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { Attr } from \"./types.js\";\n\nexport const addAttrs = (attrs: Attr[], token: Token | null): void => {\n if (!token) return;\n\n attrs.forEach(([key, value]) => {\n switch (key) {\n case \"class\":\n token.attrJoin(\"class\", value);\n break;\n case \"css-module\":\n token.attrJoin(\"css-module\", value);\n break;\n default:\n token.attrPush([key, value]);\n }\n });\n};\n","export const CLASS_MARKER = \".\";\nexport const ID_MARKER = \"#\";\nexport const ALLOWED_KEY_CHARS = /[^\\t\\n\\f />\"'=]/;\nexport const PAIR_SEPARATOR = \" \";\nexport const KEY_SEPARATOR = \"=\";\n","import {\n ALLOWED_KEY_CHARS,\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n} from \"./constants.js\";\nimport type { Attr, DelimiterConfig } from \"./types.js\";\n\nexport const getAttrs = (\n str: string,\n start: number,\n { left, right, allowed }: DelimiterConfig,\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside {}\n // start + left delimiter length to avoid beginning {\n // breaks when } is found or end of string\n for (let index = start + left.length; index < str.length; index++) {\n if (str.slice(index, index + right.length) === right) {\n if (key !== \"\") attrs.push([key, value]);\n break;\n }\n\n const char = str.charAt(index);\n\n // switch to reading value if equal sign\n if (char === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (char === CLASS_MARKER && key === \"\") {\n if (str.charAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (char === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (char === '\"' && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (char === '\"' && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (char === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\")\n // beginning or ending space: { .red } vs {.red}\n continue;\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && char.search(ALLOWED_KEY_CHARS) === -1) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += char;\n continue;\n }\n\n value += char;\n }\n\n return allowed.length\n ? attrs.filter(([attr]) =>\n allowed.some((item) =>\n item instanceof RegExp ? item.test(attr) : item === attr,\n ),\n )\n : attrs;\n};\n","import { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\n\nexport type DelimiterChecker = (content: string) => boolean;\n\nexport const getDelimiterChecker = (\n { left, right }: Required<DelimiterConfig>,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where)) {\n throw new Error(\n `Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`,\n );\n }\n\n return (content: string): boolean => {\n const leftLength = left.length;\n const rightLength = right.length;\n // we need minimum three chars, for example {b}\n const minCurlyLength = leftLength + 1 + rightLength;\n const rightDelimiterMinimumShift = leftLength + 1;\n\n // perform a quick check\n if (\n !content ||\n typeof content !== \"string\" ||\n content.length < minCurlyLength\n )\n return false;\n\n const validCurlyLength = (curly: string): boolean =>\n [CLASS_MARKER, ID_MARKER].includes(curly.charAt(leftLength))\n ? curly.length >= minCurlyLength + 1\n : curly.length >= minCurlyLength;\n\n let start: number;\n let end: number;\n let slice: string;\n let nextChar: string;\n\n if (where === \"start\") {\n // first char should be {, } found in char 2 or more\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n end =\n start === -1 ? -1 : content.indexOf(right, rightDelimiterMinimumShift);\n // check if next character is not one of the delimiters\n nextChar = content.charAt(end + rightLength);\n if (nextChar && right.includes(nextChar)) end = -1;\n } else if (where === \"end\") {\n // last char should be }\n start = content.lastIndexOf(left);\n end =\n start === -1\n ? -1\n : content.indexOf(right, start + rightDelimiterMinimumShift);\n end = end === content.length - rightLength ? end : -1;\n } else {\n // '{.a}'\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n slice = content.slice(content.length - rightLength);\n end = slice === right ? content.length - rightLength : -1;\n }\n\n return (\n start !== -1 &&\n end !== -1 &&\n validCurlyLength(content.substring(start, end + rightLength))\n );\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (\n tokens: Token[],\n index: number,\n): Token | null => {\n const token = tokens[index];\n\n if (token.type === \"softbreak\") return null;\n\n // non closing blocks, example img\n if (token.nesting === 0) return token;\n\n const level = token.level;\n const type = token.type.replace(\"_close\", \"_open\");\n\n while (index >= 0) {\n const currentToken = tokens[index];\n\n if (currentToken.type === type && currentToken.level === level)\n return currentToken;\n\n index--;\n }\n\n /* istanbul ignore next -- @preserve */\n return null;\n};\n","const l=e=>{const n=e.split(`\n`),p=n.reduce((r,c)=>{for(let t=0;t<c.length;t++)if(c[t]!==\" \"&&c[t]!==\"\t\")return Math.min(t,r);return r},1/0);return p<1/0?n.map(r=>r.slice(p)).join(`\n`):e},a=e=>e.replace(/&/gu,\"&\").replace(/</gu,\"<\").replace(/>/gu,\">\").replace(/\"/gu,\""\").replace(/'/gu,\"'\"),g=e=>e.replace(/[-/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\"),u=/\\r\\n?|\\n/g,s=/\\\\([ \\\\!\"#$%&'()*+,./:;<=>?@[\\]^_`{|}~-])/gu;export{u as NEWLINE_RE,s as UNESCAPE_RE,l as dedent,a as escapeHtml,g as escapeRegExp};\n//# sourceMappingURL=index.js.map\n","import { escapeRegExp } from \"@mdit/helper\";\n\nexport const removeDelimiter = (\n str: string,\n left: string,\n right: string,\n): string => {\n const start = escapeRegExp(left);\n const end = escapeRegExp(right);\n const pos = str.search(\n new RegExp(`[ \\\\n]?${start}[^${start}${end}]+${end}$`),\n );\n\n return pos !== -1 ? str.slice(0, pos) : str;\n};\n","/**\n * Get index item of array. Supports negative index, where -1 is last\n * element in array.\n */\nexport const getArrayItem = <T>(arr: T[], index: number): T =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const isArrayOfFunctions = (arr: unknown): arr is Function[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"function\");\n\nexport const isArrayOfObjects = (arr: unknown): arr is object[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"object\");\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet, TestFunction } from \"../rules/types.js\";\nimport {\n getArrayItem,\n isArrayOfFunctions,\n isArrayOfObjects,\n} from \"../utils.js\";\n\nexport interface TestRuleResult {\n /** whether rule matches token stream */\n match: boolean;\n /** position of token */\n position: null | number;\n}\n\n/**\n * Test if rule matches token stream.\n *\n */\nexport const testRule = (\n tokens: Token[],\n index: number,\n rule: AttrRuleSet,\n): TestRuleResult => {\n const result: TestRuleResult = {\n match: false,\n position: null,\n };\n\n const tokenIndex =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n rule.shift !== undefined ? index + rule.shift : rule.position!;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (rule.shift !== undefined && tokenIndex < 0) return result;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!token) return result;\n\n for (const key of Object.keys(rule) as (keyof typeof rule)[]) {\n if (key === \"shift\" || key === \"position\") continue;\n\n if (token[key as keyof Token] === undefined) return result;\n\n if (key === \"children\" && isArrayOfObjects(rule.children)) {\n if (token.children?.length === 0) return result;\n\n let match;\n const childTests = rule.children;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const children = token.children!;\n\n if (childTests.every((childTest) => childTest.position !== undefined)) {\n // positions instead of shifts, do not loop all children\n match = childTests.every(\n (childTest) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n testRule(children, childTest.position!, childTest).match,\n );\n\n if (match) {\n // we may need position of child in transform\n const position = childTests[childTests.length - 1]?.position ?? 0;\n\n result.position =\n position >= 0 ? position : children.length + position;\n }\n } else {\n for (let token = 0; token < children.length; token++) {\n match = childTests.every(\n (childTest) => testRule(children, token, childTest).match,\n );\n\n if (match) {\n result.position = token;\n // all tests true, continue with next key of pattern t\n break;\n }\n }\n }\n\n if (match === false) return result;\n\n continue;\n }\n\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return result;\n\n break;\n }\n\n case \"function\": {\n if (!(ruleDetail as TestFunction)(token[key])) return result;\n\n break;\n }\n\n // fall through for objects !== arrays of functions\n default: {\n if (isArrayOfFunctions(ruleDetail)) {\n if (\n !(ruleDetail as TestFunction[]).every((ruleItem) =>\n ruleItem(token[key]),\n )\n )\n return result;\n\n break;\n }\n\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string, function or array of functions.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n result.match = true;\n\n return result;\n};\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getBlockRule = (options: Required<DelimiterConfig>): AttrRule =>\n /**\n * end of {.block}\n */\n ({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: getDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n\n // Extract attributes from the content\n const attrStartIndex = content.lastIndexOf(options.left);\n const attrs = getAttrs(content, attrStartIndex, options);\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (\n tokens[closingTokenIndex + 1] &&\n tokens[closingTokenIndex + 1].nesting === -1\n ) {\n closingTokenIndex++;\n }\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(attrs, openingToken);\n\n // Remove the attribute syntax from content\n const contentWithoutAttributes = content.slice(0, attrStartIndex);\n const hasTrailingSpace =\n contentWithoutAttributes[contentWithoutAttributes.length - 1] === \" \";\n\n token.content = hasTrailingSpace\n ? contentWithoutAttributes.slice(0, -1)\n : contentWithoutAttributes;\n },\n });\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n removeDelimiter,\n} from \"../helper/index.js\";\n\nexport const getFenceRule = (options: Required<DelimiterConfig>): AttrRule =>\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n ({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: getDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n let lineNumbers = \"\";\n\n // Special handler for VuePress line numbers syntax\n const lineNumberMatch = /{(?:[\\d,-]+)}/.exec(token.info);\n\n if (lineNumberMatch) {\n token.info = token.info.replace(lineNumberMatch[0], \"\");\n lineNumbers = lineNumberMatch[0];\n }\n\n // Extract attributes from the token info\n const attributeStartIndex = token.info.lastIndexOf(options.left);\n const attributes = getAttrs(token.info, attributeStartIndex, options);\n\n // Apply attributes to the current token\n addAttrs(attributes, token);\n\n // Remove attribute syntax from info and restore line numbers\n const infoWithoutAttributes = removeDelimiter(\n token.info,\n options.left,\n options.right,\n );\n\n token.info = `${infoWithoutAttributes} ${lineNumbers}`.trim();\n },\n });\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getInlineRules = (\n options: Required<DelimiterConfig>,\n): AttrRule[] => [\n /**\n * bla `click()`{.c} {.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n {\n name: \"inline nesting self-close\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: getDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n const rightDelimiterLength = options.right.length;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n\n const attrEndIndex = token.content.indexOf(options.right);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const targetToken = tokens[index].children![childIndex - 1];\n const attrs = getAttrs(token.content, 0, options);\n\n // Apply attributes to the target token\n addAttrs(attrs, targetToken);\n\n // Remove or update token content based on remaining content\n if (token.content.length === attrEndIndex + rightDelimiterLength) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!.splice(childIndex, 1);\n } else {\n token.content = token.content.slice(\n attrEndIndex + rightDelimiterLength,\n );\n }\n },\n },\n\n /**\n * *emphasis*{.with attrs=1}\n */\n {\n name: \"inline attributes\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n nesting: -1, // closing inline tag, </em>{.a}\n },\n {\n shift: 0,\n type: \"text\",\n content: getDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const currentToken = tokens[index].children![childIndex];\n const { content } = currentToken;\n\n // Extract attributes from the content\n const attributes = getAttrs(content, 0, options);\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!,\n childIndex - 1,\n );\n\n // Apply attributes to the opening token\n addAttrs(attributes, openingToken);\n\n // Remove attribute syntax from content\n const attributeEndIndex =\n content.indexOf(options.right) + options.right.length;\n\n currentToken.content = content.slice(attributeEndIndex);\n },\n },\n];\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getListRules = (\n options: Required<DelimiterConfig>,\n): AttrRule[] => [\n /**\n * - item\n * {.a}\n */\n {\n name: \"list softbreak\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: getDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1] &&\n tokens[listOpenIndex - 1].type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n ) {\n listOpenIndex--;\n }\n\n // Apply attributes to the list opening token\n addAttrs(attrs, tokens[listOpenIndex - 1]);\n\n // Remove the attribute tokens from children\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children = tokens[index].children!.slice(0, -2);\n },\n },\n\n /**\n * - nested list\n * - with double \\n\n * {.a} <-- apply to nested ul\n *\n * {.b} <-- apply to root <ul>\n */\n {\n name: \"list double softbreak\",\n tests: [\n {\n // let this token be i = 0 so that we can erase\n // the <p>{.a}</p> tokens below\n shift: 0,\n type: (type) =>\n type === \"bullet_list_close\" || type === \"ordered_list_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: getDelimiterChecker(options, \"only\"),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const attrs = getAttrs(token.content, 0, options);\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(attrs, openingToken);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n },\n\n /**\n * - end of {.list-item}\n */\n {\n name: \"list item end\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n type: \"text\",\n content: getDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n\n // Extract attributes from the content\n const attrStartIndex = content.lastIndexOf(options.left);\n const attrs = getAttrs(content, attrStartIndex, options);\n\n // Apply attributes to the list item opening token\n addAttrs(attrs, tokens[index - 2]);\n\n // Remove attribute syntax from content\n const contentWithoutAttributes = content.slice(0, attrStartIndex);\n const hasTrailingSpace =\n contentWithoutAttributes[contentWithoutAttributes.length - 1] === \" \";\n\n token.content = hasTrailingSpace\n ? contentWithoutAttributes.slice(0, -1)\n : contentWithoutAttributes;\n },\n },\n];\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getSoftBreakRule = (\n options: Required<DelimiterConfig>,\n): AttrRule => ({\n /**\n * something with softbreak\n * {.cls}\n */\n\n name: \"\\n{.a} softbreak then curly in start\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: getDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (\n tokens[closingTokenIndex + 1] &&\n tokens[closingTokenIndex + 1].nesting === -1\n ) {\n closingTokenIndex++;\n }\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(attrs, openingToken);\n\n // Remove the softbreak and attribute tokens\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children = tokens[index].children!.slice(0, -2);\n },\n});\n","import { escapeRegExp } from \"@mdit/helper\";\n\nimport type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getAttrs } from \"../helper/index.js\";\n\nexport const getHrRule = (options: Required<DelimiterConfig>): AttrRule => ({\n /**\n * horizontal rule --- {#id}\n */\n name: \"horizontal rule\",\n tests: [\n {\n shift: 0,\n type: \"paragraph_open\",\n },\n {\n shift: 1,\n type: \"inline\",\n children: (children) => children.length === 1,\n content: (content) =>\n new RegExp(\n `^ {0,3}[-*_]{3,} ?${escapeRegExp(options.left)}[^${escapeRegExp(\n options.right,\n )}]`,\n ).test(content),\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n const attributeStartIndex = content.lastIndexOf(options.left);\n const attributes = getAttrs(content, attributeStartIndex, options);\n\n // Apply attributes to the hr token\n addAttrs(attributes, token);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n});\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\ninterface TokenWithColumnCount extends Token {\n meta:\n | {\n columnCount?: number;\n [key: string]: unknown;\n }\n | undefined;\n}\n\n/**\n * Hidden table's cells and them inline children,\n * specially cast inline's content as empty\n * to prevent that escapes the table's box model\n */\nconst hideTokenContent = (token: Token): void => {\n token.hidden = true;\n token.children?.forEach((childToken) => {\n childToken.content = \"\";\n hideTokenContent(childToken);\n });\n};\n\n/**\n * Handle rowspan logic for table cells\n */\nconst handleRowspan = (\n tokens: Token[],\n startIndex: number,\n endIndex: number,\n columnCount: number,\n colspan: number,\n rowspan: number,\n): void => {\n let adjustedColumnCount = columnCount - (colspan > 0 ? colspan : 1);\n\n for (\n let tokenIndex = startIndex, remainingRows = rowspan;\n tokenIndex < endIndex && remainingRows > 1;\n tokenIndex++\n ) {\n if (tokens[tokenIndex].type === \"tr_open\") {\n const trOpenToken = tokens[tokenIndex] as TokenWithColumnCount;\n\n trOpenToken.meta ??= {};\n\n if (trOpenToken.meta.columnCount) {\n adjustedColumnCount -= 1;\n }\n\n trOpenToken.meta.columnCount = adjustedColumnCount;\n remainingRows--;\n }\n }\n};\n\n/**\n * Handle table row processing\n */\nconst handleTableRow = (\n tokens: Token[],\n startIndex: number,\n endIndex: number,\n): void => {\n const token = tokens[startIndex] as TokenWithColumnCount;\n const expectedColumnCount = token.meta?.columnCount;\n\n if (!expectedColumnCount) return;\n\n // hide extra table cells in the row\n for (let index = startIndex, cellCount = 0; index < endIndex; index++) {\n const currentToken = tokens[index];\n\n // Count table cells in the row\n if (currentToken.type === \"td_open\") {\n cellCount += 1;\n }\n // break at end of table row\n else if (currentToken.type === \"tr_close\") {\n break;\n }\n\n // hide extra table cells\n if (cellCount > expectedColumnCount && !currentToken.hidden) {\n hideTokenContent(currentToken);\n }\n }\n};\n\n/**\n * Handle colspan logic for table cells\n */\nconst handleColspan = (\n tokens: Token[],\n startIndex: number,\n endIndex: number,\n columnCount: number,\n colspan: number,\n tbodyOpenIndex: number,\n): void => {\n const cellIndices: number[] = [];\n const startToken = tokens[startIndex];\n\n let end = startIndex + 3;\n let colspanNum = columnCount;\n\n // Find previous row children indices\n for (let tokenIndex = startIndex; tokenIndex > tbodyOpenIndex; tokenIndex--) {\n if (tokens[tokenIndex].type === \"tr_open\") {\n colspanNum =\n (tokens[tokenIndex] as TokenWithColumnCount).meta?.columnCount ??\n colspanNum;\n break;\n } else if (tokens[tokenIndex].type === \"td_open\") {\n cellIndices.unshift(tokenIndex);\n }\n }\n\n // Find current row children indices\n for (let index = startIndex + 2; index < endIndex; index++) {\n if (tokens[index].type === \"tr_close\") {\n end = index;\n break;\n } else if (tokens[index].type === \"td_open\") {\n cellIndices.push(index);\n }\n }\n\n const cellOffset = cellIndices.indexOf(startIndex);\n\n const realColspan = Math.min(colspan, colspanNum - cellOffset);\n\n if (colspan > realColspan) {\n startToken.attrSet(\"colspan\", realColspan.toString());\n }\n\n const hiddenStartIndex = cellIndices.slice(\n colspanNum + 1 - columnCount - realColspan,\n )[0];\n\n for (let index = hiddenStartIndex; index < end; index++) {\n if (!tokens[index].hidden) hideTokenContent(tokens[index]);\n }\n};\n\nexport const getTableRules = (\n options: Required<DelimiterConfig>,\n): AttrRule[] => [\n {\n /**\n * | h1 |\n * | -- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: getDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n const attrs = getAttrs(token.content, 0, options);\n\n // Apply attributes to the table opening token\n addAttrs(attrs, tableOpeningToken);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n },\n /**\n * Handle table cell attributes: title {.class}\n * This rule processes attributes within table cell text content\n */\n {\n name: \"table cell attributes\",\n tests: [\n {\n shift: -1,\n type: (type) => type === \"td_open\" || type === \"th_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: 0,\n type: \"text\",\n content: getDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n\n // Find last attribute syntax in the content\n const attrStartIndex = content.lastIndexOf(options.left);\n\n // Extract attributes from the content\n const attributes = getAttrs(content, attrStartIndex, options);\n\n // Apply attributes to the table cell token\n addAttrs(attributes, cellOpenToken);\n\n // Remove attribute syntax from content\n token.content = content.substring(0, attrStartIndex).trim();\n },\n },\n {\n /**\n * | A | B |\n * | -- | -- |\n * | 1 | 2 |\n *\n * | C | D |\n * | -- | -- |\n *\n * only `| A | B |` sets the columnCount metadata\n */\n name: \"table thead metadata\",\n tests: [\n {\n shift: 0,\n type: \"tr_close\",\n },\n {\n shift: 1,\n type: \"thead_close\",\n },\n {\n shift: 2,\n type: \"tbody_open\",\n },\n ],\n\n transform: (tokens, index): void => {\n const trOpenToken = getMatchingOpeningToken(tokens, index);\n const thCloseToken = tokens[index - 1];\n let columnCount = 0;\n let currentIndex = index - 1;\n\n // Find the matching tr_open token and count columns\n while (currentIndex > 0) {\n const currentToken = tokens[currentIndex];\n\n if (currentToken === trOpenToken) {\n const tHeadOpenToken = tokens[\n currentIndex - 1\n ] as TokenWithColumnCount;\n\n tHeadOpenToken.meta = {\n ...tHeadOpenToken.meta,\n columnCount,\n };\n break;\n }\n\n // Count th_close tokens at the same level\n if (\n currentToken.level === thCloseToken.level &&\n currentToken.type === thCloseToken.type\n ) {\n columnCount++;\n }\n\n currentIndex--;\n }\n\n // Apply metadata to tbody_open token\n const tbodyOpenToken = tokens[index + 2] as TokenWithColumnCount;\n\n tbodyOpenToken.meta = {\n ...tbodyOpenToken.meta,\n columnCount,\n };\n },\n },\n {\n /**\n * | A | B | C | D |\n * | -- | -- | -- | -- |\n * | 1 | 11 | 111 | 1111 {rowspan=3} |\n * | 2 {colspan=2 rowspan=2} | 22 | 222 | 2222 |\n * | 3 | 33 | 333 | 3333 |\n */\n name: \"table tbody calculate\",\n tests: [\n {\n shift: 0,\n type: \"tbody_close\",\n hidden: false,\n },\n ],\n transform: (tokens, index): void => {\n // Find the tbody_open token index\n let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex > 0) {\n tbodyOpenIndex--;\n if (tokens[tbodyOpenIndex].type === \"tbody_open\") break;\n }\n\n const columnCount = Number(\n (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta?.columnCount ?? 0,\n );\n\n if (columnCount < 2) return;\n\n const maxLevel = tokens[index].level + 2;\n\n for (\n let currentIndex = tbodyOpenIndex;\n currentIndex < index;\n currentIndex++\n ) {\n if (tokens[currentIndex].level > maxLevel) continue;\n\n const token = tokens[currentIndex];\n const rowspan = token.hidden ? 0 : Number(token.attrGet(\"rowspan\"));\n const colspan = token.hidden ? 0 : Number(token.attrGet(\"colspan\"));\n\n if (rowspan > 1) {\n handleRowspan(\n tokens,\n currentIndex,\n index,\n columnCount,\n colspan,\n rowspan,\n );\n }\n\n if (token.type === \"tr_open\") {\n handleTableRow(tokens, currentIndex, index);\n }\n\n if (colspan > 1) {\n handleColspan(\n tokens,\n currentIndex,\n index,\n columnCount,\n colspan,\n tbodyOpenIndex,\n );\n }\n }\n },\n },\n];\n","import type { AttrRule } from \"./types.js\";\nimport type {\n MarkdownItAttrRuleName,\n MarkdownItAttrsOptions,\n} from \"../options.js\";\nimport { getBlockRule } from \"./block.js\";\nimport { getFenceRule } from \"./fence.js\";\nimport { getHrRule } from \"./hr.js\";\nimport { getInlineRules } from \"./inline.js\";\nimport { getListRules } from \"./list.js\";\nimport { getSoftBreakRule } from \"./softbreak.js\";\nimport { getTableRules } from \"./table.js\";\n\nconst AVAILABLE_RULES: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const getRules = (\n options: Required<MarkdownItAttrsOptions>,\n): AttrRule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => AVAILABLE_RULES.includes(item))\n : AVAILABLE_RULES;\n\n const rules: AttrRule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(getFenceRule(options));\n if (enabledRules.includes(\"inline\")) rules.push(...getInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...getTableRules(options));\n if (enabledRules.includes(\"list\")) rules.push(...getListRules(options));\n if (enabledRules.includes(\"softbreak\")) rules.push(getSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(getHrRule(options));\n if (enabledRules.includes(\"block\")) rules.push(getBlockRule(options));\n\n return rules;\n};\n","/**\n * Forked and modified from https://github.com/arve0/markdown-it-attrs/\n */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { testRule } from \"./helper/index.js\";\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport { getRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = getRules({\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = ({ tokens }) => {\n for (let index = 0; index < tokens.length; index++)\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n\n const match = pattern.tests.every((t) => {\n const result = testRule(tokens, index, t);\n\n if (result.position !== null) ({ position } = result);\n\n return result.match;\n });\n\n if (match) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n pattern.transform(tokens, index, position!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting self-close\"\n )\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"names":["addAttrs","attrs","token","key","value","CLASS_MARKER","ID_MARKER","ALLOWED_KEY_CHARS","PAIR_SEPARATOR","KEY_SEPARATOR","getAttrs","str","start","left","right","allowed","parsingKey","valueInsideQuotes","index","char","attr","item","getDelimiterChecker","where","content","leftLength","rightLength","minCurlyLength","rightDelimiterMinimumShift","validCurlyLength","curly","end","slice","nextChar","getMatchingOpeningToken","tokens","level","type","currentToken","g","removeDelimiter","escapeRegExp","pos","getArrayItem","arr","isArrayOfFunctions","isArrayOfObjects","testRule","rule","result","tokenIndex","match","childTests","children","childTest","position","ruleDetail","ruleItem","getBlockRule","options","childIndex","attrStartIndex","closingTokenIndex","openingToken","contentWithoutAttributes","hasTrailingSpace","getFenceRule","lineNumbers","lineNumberMatch","attributeStartIndex","attributes","infoWithoutAttributes","getInlineRules","rightDelimiterLength","attrEndIndex","targetToken","attributeEndIndex","getListRules","listOpenIndex","getSoftBreakRule","getHrRule","inlineToken","hideTokenContent","childToken","handleRowspan","startIndex","endIndex","columnCount","colspan","rowspan","adjustedColumnCount","remainingRows","trOpenToken","handleTableRow","expectedColumnCount","cellCount","handleColspan","tbodyOpenIndex","cellIndices","startToken","colspanNum","cellOffset","realColspan","hiddenStartIndex","getTableRules","tableOpeningToken","cellOpenToken","thCloseToken","currentIndex","tHeadOpenToken","tbodyOpenToken","maxLevel","AVAILABLE_RULES","getRules","enabledRules","rules","md","attrsRule","ruleIndex","pattern","t"],"mappings":"AAIO,MAAMA,EAAW,CAACC,EAAeC,IAA8B,CAC/DA,GAELD,EAAM,QAAQ,CAAC,CAACE,EAAKC,CAAK,IAAM,CAC9B,OAAQD,GACN,IAAK,QACHD,EAAM,SAAS,QAASE,CAAK,EAC7B,MACF,IAAK,aACHF,EAAM,SAAS,aAAcE,CAAK,EAClC,MACF,QACEF,EAAM,SAAS,CAACC,EAAKC,CAAK,CAAC,CAC/B,CACF,CAAC,CACH,ECnBaC,EAAe,IACfC,EAAY,IACZC,EAAoB,kBACpBC,EAAiB,IACjBC,EAAgB,ICKhBC,EAAW,CACtBC,EACAC,EACA,CAAE,KAAAC,EAAM,MAAAC,EAAO,QAAAC,CAAQ,IACZ,CACX,IAAIZ,EAAM,GACNC,EAAQ,GACRY,EAAa,GACbC,EAAoB,GAExB,MAAMhB,EAAgB,CAAA,EAKtB,QAASiB,EAAQN,EAAQC,EAAK,OAAQK,EAAQP,EAAI,OAAQO,IAAS,CACjE,GAAIP,EAAI,MAAMO,EAAOA,EAAQJ,EAAM,MAAM,IAAMA,EAAO,CAChDX,IAAQ,IAAIF,EAAM,KAAK,CAACE,EAAKC,CAAK,CAAC,EACvC,KACF,CAEA,MAAMe,EAAOR,EAAI,OAAOO,CAAK,EAG7B,GAAIC,IAASV,GAAiBO,EAAY,CACxCA,EAAa,GACb,QACF,CAGA,GAAIG,IAASd,GAAgBF,IAAQ,GAAI,CACnCQ,EAAI,OAAOO,EAAQ,CAAC,IAAMb,GAC5BF,EAAM,aACNe,KAEAf,EAAM,QAGRa,EAAa,GACb,QACF,CAGA,GAAIG,IAASb,GAAaH,IAAQ,GAAI,CACpCA,EAAM,KACNa,EAAa,GACb,QACF,CAGA,GAAIG,IAAS,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EvCA,EAAO,KAChB,CAAC,IAICsE,EAAQ,UAAUpF,EAAQjB,EAAOqC,CAAS,GAGxCgE,EAAQ,OAAS,qBACjBA,EAAQ,OAAS,8BAGjBD,IAEN,CACJ,EAEAF,EAAG,KAAK,MAAM,OAAO,UAAW,QAASC,CAAS,CACpD"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { PluginWithOptions } from 'markdown-it';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
interface MarkdownItAttrsOptions {
|
|
3
|
+
interface DelimiterConfig {
|
|
5
4
|
/**
|
|
6
5
|
* left delimiter
|
|
7
6
|
*
|
|
@@ -9,7 +8,7 @@ interface MarkdownItAttrsOptions {
|
|
|
9
8
|
*
|
|
10
9
|
* @default '{'
|
|
11
10
|
*/
|
|
12
|
-
left
|
|
11
|
+
left: string;
|
|
13
12
|
/**
|
|
14
13
|
* right delimiter
|
|
15
14
|
*
|
|
@@ -17,7 +16,7 @@ interface MarkdownItAttrsOptions {
|
|
|
17
16
|
*
|
|
18
17
|
* @default '}'
|
|
19
18
|
*/
|
|
20
|
-
right
|
|
19
|
+
right: string;
|
|
21
20
|
/**
|
|
22
21
|
* allowed attributes
|
|
23
22
|
*
|
|
@@ -29,7 +28,11 @@ interface MarkdownItAttrsOptions {
|
|
|
29
28
|
*
|
|
30
29
|
* @default []
|
|
31
30
|
*/
|
|
32
|
-
allowed
|
|
31
|
+
allowed: (string | RegExp)[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type MarkdownItAttrRuleName = "fence" | "inline" | "table" | "list" | "hr" | "softbreak" | "block";
|
|
35
|
+
interface MarkdownItAttrsOptions extends Partial<DelimiterConfig> {
|
|
33
36
|
/**
|
|
34
37
|
* Rules to enable
|
|
35
38
|
*
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{escapeRegExp as b}from"@mdit/helper";const
|
|
2
|
-
{.a} softbreak then curly in start`,tests:[{shift:0,type:"inline",children:[{position:-2,type:"softbreak"},{position:-1,type:"text",content:
|
|
1
|
+
import{escapeRegExp as b}from"@mdit/helper";const u=(e,t)=>{t&&e.forEach(([s,n])=>{switch(s){case"class":t.attrJoin("class",n);break;case"css-module":t.attrJoin("css-module",n);break;default:t.attrPush([s,n])}})},_=".",x="#",v=/[^\t\n\f />"'=]/,O=" ",E="=",d=(e,t,{left:s,right:n,allowed:o})=>{let i="",l="",r=!0,c=!1;const f=[];for(let h=t+s.length;h<e.length;h++){if(e.slice(h,h+n.length)===n){i!==""&&f.push([i,l]);break}const a=e.charAt(h);if(a===E&&r){r=!1;continue}if(a===_&&i===""){e.charAt(h+1)===_?(i="css-module",h++):i="class",r=!1;continue}if(a===x&&i===""){i="id",r=!1;continue}if(a==='"'&&l===""&&!c){c=!0;continue}if(a==='"'&&c){c=!1;continue}if(a===O&&!c){if(i==="")continue;f.push([i,l]),i="",l="",r=!0;continue}if(!(r&&a.search(v)===-1)){if(r){i+=a;continue}l+=a}}return o.length?f.filter(([h])=>o.some(a=>a instanceof RegExp?a.test(h):a===h)):f},y=({left:e,right:t},s)=>{if(!["start","end","only"].includes(s))throw new Error(`Invalid 'where' parameter: ${s}. Expected 'start', 'end', or 'only'.`);return n=>{const o=e.length,i=t.length,l=o+1+i,r=o+1;if(!n||typeof n!="string"||n.length<l)return!1;const c=p=>[_,x].includes(p.charAt(o))?p.length>=l+1:p.length>=l;let f,h,a,m;return s==="start"?(a=n.slice(0,o),f=a===e?0:-1,h=f===-1?-1:n.indexOf(t,r),m=n.charAt(h+i),m&&t.includes(m)&&(h=-1)):s==="end"?(f=n.lastIndexOf(e),h=f===-1?-1:n.indexOf(t,f+r),h=h===n.length-i?h:-1):(a=n.slice(0,o),f=a===e?0:-1,a=n.slice(n.length-i),h=a===t?n.length-i:-1),f!==-1&&h!==-1&&c(n.substring(f,h+i))}},g=(e,t)=>{const s=e[t];if(s.type==="softbreak")return null;if(s.nesting===0)return s;const n=s.level,o=s.type.replace("_close","_open");for(;t>=0;){const i=e[t];if(i.type===o&&i.level===n)return i;t--}/* istanbul ignore next -- @preserve */return null},w=(e,t,s)=>{const n=b(t),o=b(s),i=e.search(new RegExp(`[ \\n]?${n}[^${n}${o}]+${o}$`));return i!==-1?e.slice(0,i):e},C=(e,t)=>t>=0?e[t]:e[e.length+t],I=e=>Array.isArray(e)&&!!e.length&&e.every(t=>typeof t=="function"),$=e=>Array.isArray(e)&&!!e.length&&e.every(t=>typeof t=="object"),k=(e,t,s)=>{const n={match:!1,position:null},o=s.shift!==void 0?t+s.shift:s.position;if(s.shift!==void 0&&o<0)return n;const i=C(e,o);if(!i)return n;for(const l of Object.keys(s)){if(l==="shift"||l==="position")continue;if(i[l]===void 0)return n;if(l==="children"&&$(s.children)){if(i.children?.length===0)return n;let c;const f=s.children,h=i.children;if(f.every(a=>a.position!==void 0)){if(c=f.every(a=>k(h,a.position,a).match),c){const a=f[f.length-1]?.position??0;n.position=a>=0?a:h.length+a}}else for(let a=0;a<h.length;a++)if(c=f.every(m=>k(h,a,m).match),c){n.position=a;break}if(c===!1)return n;continue}const r=s[l];switch(typeof r){case"boolean":case"number":case"string":{if(i[l]!==r)return n;break}case"function":{if(!r(i[l]))return n;break}default:{if(I(r)){if(!r.every(c=>c(i[l])))return n;break}throw new Error(`Unknown type of pattern test (key: ${l}). Test should be of type boolean, number, string, function or array of functions.`)}}}return n.match=!0,n},S=e=>({name:"end of block",tests:[{shift:0,type:"inline",children:[{position:-1,content:y(e,"end"),type:t=>t!=="code_inline"&&t!=="math_inline"}]}],transform:(t,s,n)=>{const o=t[s].children[n],{content:i}=o,l=i.lastIndexOf(e.left),r=d(i,l,e);let c=s+1;for(;t[c+1]&&t[c+1].nesting===-1;)c++;const f=g(t,c);u(r,f);const h=i.slice(0,l),a=h[h.length-1]===" ";o.content=a?h.slice(0,-1):h}}),T=e=>({name:"code-block",tests:[{shift:0,block:!0,info:y(e,"end")}],transform:(t,s)=>{const n=t[s];let o="";const i=/{(?:[\d,-]+)}/.exec(n.info);i&&(n.info=n.info.replace(i[0],""),o=i[0]);const l=n.info.lastIndexOf(e.left),r=d(n.info,l,e);u(r,n);const c=w(n.info,e.left,e.right);n.info=`${c} ${o}`.trim()}}),D=e=>[{name:"inline nesting self-close",tests:[{shift:0,type:"inline",children:[{shift:-1,type:t=>t==="image"||t==="code_inline"},{shift:0,type:"text",content:y(e,"start")}]}],transform:(t,s,n)=>{const o=e.right.length,i=t[s].children[n],l=i.content.indexOf(e.right),r=t[s].children[n-1],c=d(i.content,0,e);u(c,r),i.content.length===l+o?t[s].children.splice(n,1):i.content=i.content.slice(l+o)}},{name:"inline attributes",tests:[{shift:0,type:"inline",children:[{shift:-1,nesting:-1},{shift:0,type:"text",content:y(e,"start")}]}],transform:(t,s,n)=>{const o=t[s].children[n],{content:i}=o,l=d(i,0,e),r=g(t[s].children,n-1);u(l,r);const c=i.indexOf(e.right)+e.right.length;o.content=i.slice(c)}}],K=e=>[{name:"list softbreak",tests:[{shift:-2,type:"list_item_open"},{shift:0,type:"inline",children:[{position:-2,type:"softbreak"},{position:-1,type:"text",content:y(e,"only")}]}],transform:(t,s,n)=>{const o=t[s].children[n],i=d(o.content,0,e);let l=s-2;for(;t[l-1]&&t[l-1].type!=="ordered_list_open"&&t[l-1].type!=="bullet_list_open";)l--;u(i,t[l-1]),t[s].children=t[s].children.slice(0,-2)}},{name:"list double softbreak",tests:[{shift:0,type:t=>t==="bullet_list_close"||t==="ordered_list_close"},{shift:1,type:"paragraph_open"},{shift:2,type:"inline",content:y(e,"only"),children:t=>t.length===1},{shift:3,type:"paragraph_close"}],transform:(t,s)=>{const n=t[s+2],o=d(n.content,0,e),i=g(t,s);u(o,i),t.splice(s+1,3)}},{name:"list item end",tests:[{shift:-2,type:"list_item_open"},{shift:0,type:"inline",children:[{position:-1,type:"text",content:y(e,"end")}]}],transform:(t,s,n)=>{const o=t[s].children[n],{content:i}=o,l=i.lastIndexOf(e.left),r=d(i,l,e);u(r,t[s-2]);const c=i.slice(0,l),f=c[c.length-1]===" ";o.content=f?c.slice(0,-1):c}}],L=e=>({name:`
|
|
2
|
+
{.a} softbreak then curly in start`,tests:[{shift:0,type:"inline",children:[{position:-2,type:"softbreak"},{position:-1,type:"text",content:y(e,"only")}]}],transform:(t,s,n)=>{const o=t[s].children[n],i=d(o.content,0,e);let l=s+1;for(;t[l+1]&&t[l+1].nesting===-1;)l++;const r=g(t,l);u(i,r),t[s].children=t[s].children.slice(0,-2)}}),M=e=>({name:"horizontal rule",tests:[{shift:0,type:"paragraph_open"},{shift:1,type:"inline",children:t=>t.length===1,content:t=>new RegExp(`^ {0,3}[-*_]{3,} ?${b(e.left)}[^${b(e.right)}]`).test(t)},{shift:2,type:"paragraph_close"}],transform:(t,s)=>{const n=t[s];n.type="hr",n.tag="hr",n.nesting=0;const o=t[s+1],{content:i}=o,l=i.lastIndexOf(e.left),r=d(i,l,e);u(r,n),n.markup=i,t.splice(s+1,2)}}),A=e=>{e.hidden=!0,e.children?.forEach(t=>{t.content="",A(t)})},P=(e,t,s,n,o,i)=>{let l=n-(o>0?o:1);for(let r=t,c=i;r<s&&c>1;r++)if(e[r].type==="tr_open"){const f=e[r];f.meta??={},f.meta.columnCount&&(l-=1),f.meta.columnCount=l,c--}},j=(e,t,s)=>{const n=e[t].meta?.columnCount;if(n)for(let o=t,i=0;o<s;o++){const l=e[o];if(l.type==="td_open")i+=1;else if(l.type==="tr_close")break;i>n&&!l.hidden&&A(l)}},N=(e,t,s,n,o,i)=>{const l=[],r=e[t];let c=t+3,f=n;for(let p=t;p>i;p--)if(e[p].type==="tr_open"){f=e[p].meta?.columnCount??f;break}else e[p].type==="td_open"&&l.unshift(p);for(let p=t+2;p<s;p++)if(e[p].type==="tr_close"){c=p;break}else e[p].type==="td_open"&&l.push(p);const h=l.indexOf(t),a=Math.min(o,f-h);o>a&&r.attrSet("colspan",a.toString());const m=l.slice(f+1-n-a)[0];for(let p=m;p<c;p++)e[p].hidden||A(e[p])},B=e=>[{name:"table",tests:[{shift:0,type:"table_close"},{shift:1,type:"paragraph_open"},{shift:2,type:"inline",content:y(e,"only")}],transform:(t,s)=>{const n=t[s+2],o=g(t,s),i=d(n.content,0,e);u(i,o),t.splice(s+1,3)}},{name:"table cell attributes",tests:[{shift:-1,type:t=>t==="td_open"||t==="th_open"},{shift:0,type:"inline",children:[{shift:0,type:"text",content:y(e,"end")}]}],transform:(t,s,n)=>{const o=t[s].children[n],i=t[s-1],{content:l}=o,r=l.lastIndexOf(e.left),c=d(l,r,e);u(c,i),o.content=l.substring(0,r).trim()}},{name:"table thead metadata",tests:[{shift:0,type:"tr_close"},{shift:1,type:"thead_close"},{shift:2,type:"tbody_open"}],transform:(t,s)=>{const n=g(t,s),o=t[s-1];let i=0,l=s-1;for(;l>0;){const c=t[l];if(c===n){const f=t[l-1];f.meta={...f.meta,columnCount:i};break}c.level===o.level&&c.type===o.type&&i++,l--}const r=t[s+2];r.meta={...r.meta,columnCount:i}}},{name:"table tbody calculate",tests:[{shift:0,type:"tbody_close",hidden:!1}],transform:(t,s)=>{let n=s-2;for(;n>0&&(n--,t[n].type!=="tbody_open"););const o=Number(t[n].meta?.columnCount??0);if(o<2)return;const i=t[s].level+2;for(let l=n;l<s;l++){if(t[l].level>i)continue;const r=t[l],c=r.hidden?0:Number(r.attrGet("rowspan")),f=r.hidden?0:Number(r.attrGet("colspan"));c>1&&P(t,l,s,o,f,c),r.type==="tr_open"&&j(t,l,s),f>1&&N(t,l,s,o,f,n)}}}],R=["fence","inline","table","list","hr","softbreak","block"],F=e=>{const t=e.rule===!1?[]:Array.isArray(e.rule)?e.rule.filter(n=>R.includes(n)):R,s=[];return t.includes("fence")&&s.push(T(e)),t.includes("inline")&&s.push(...D(e)),t.includes("table")&&s.push(...B(e)),t.includes("list")&&s.push(...K(e)),t.includes("softbreak")&&s.push(L(e)),t.includes("hr")&&s.push(M(e)),t.includes("block")&&s.push(S(e)),s},G=(e,{left:t="{",right:s="}",allowed:n=[],rule:o="all"}={})=>{const i=F({left:t,right:s,allowed:n,rule:o}),l=({tokens:r})=>{for(let c=0;c<r.length;c++)for(let f=0;f<i.length;f++){const h=i[f];let a=null;h.tests.every(m=>{const p=k(r,c,m);return p.position!==null&&({position:a}=p),p.match})&&(h.transform(r,c,a),(h.name==="inline attributes"||h.name==="inline nesting self-close")&&f--)}};e.core.ruler.before("linkify","attrs",l)};export{G as attrs};
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/attrs.ts","../src/helper.ts","../src/rules/rules.ts","../src/utils.ts","../src/rules/test.ts","../src/plugin.ts"],"sourcesContent":["import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\n\nexport type Attr = [key: string, value: string];\n\n// not tab, line feed, form feed, space, solidus, greater than sign, quotation mark, apostrophe and equals sign\nexport const ALLOWED_KEY_CHARS = /[^\\t\\n\\f />\"'=]/;\nexport const PAIR_SEPARATOR = \" \";\nexport const KEY_SEPARATOR = \"=\";\nexport const CLASS_MARKER = \".\";\nexport const ID_MARKER = \"#\";\n\nexport const getAttrs = (\n str: string,\n start: number,\n { left, right, allowed }: Required<Omit<MarkdownItAttrsOptions, \"rule\">>,\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside {}\n // start + left delimiter length to avoid beginning {\n // breaks when } is found or end of string\n for (let index = start + left.length; index < str.length; index++) {\n if (str.slice(index, index + right.length) === right) {\n if (key !== \"\") attrs.push([key, value]);\n break;\n }\n\n const char = str.charAt(index);\n\n // switch to reading value if equal sign\n if (char === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (char === CLASS_MARKER && key === \"\") {\n if (str.charAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (char === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (char === '\"' && value === \"\") {\n valueInsideQuotes = true;\n continue;\n }\n\n if (char === '\"' && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (char === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\")\n // beginning or ending space: { .red } vs {.red}\n continue;\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && char.search(ALLOWED_KEY_CHARS) === -1) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += char;\n continue;\n }\n\n value += char;\n }\n\n return allowed.length\n ? attrs.filter(([attr]) =>\n allowed.some((item) =>\n item instanceof RegExp ? item.test(attr) : item === attr,\n ),\n )\n : attrs;\n};\n\nexport const addAttrs = (attrs: Attr[], token: Token | null): void => {\n if (token)\n attrs.forEach((attrItem) => {\n const [key, value] = attrItem;\n\n if (key === \"class\") token.attrJoin(\"class\", value);\n else if (key === \"css-module\") token.attrJoin(\"css-module\", value);\n else token.attrPush(attrItem);\n });\n};\n","import { escapeRegExp } from \"@mdit/helper\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nexport const hasDelimiters =\n (\n where: \"start\" | \"end\" | \"only\",\n left: string,\n right: string,\n ): ((content: string) => boolean) =>\n (content: string): boolean => {\n const leftLength = left.length;\n const rightLength = right.length;\n // we need minimum three chars, for example {b}\n const minCurlyLength = leftLength + 1 + rightLength;\n\n if (\n !content ||\n typeof content !== \"string\" ||\n content.length < minCurlyLength\n )\n return false;\n\n const validCurlyLength = (curly: string): boolean => {\n const isClass = curly.charAt(leftLength) === \".\";\n const isId = curly.charAt(leftLength) === \"#\";\n\n return isClass || isId\n ? curly.length >= minCurlyLength + 1\n : curly.length >= minCurlyLength;\n };\n\n let start, end, slice, nextChar;\n const rightDelimiterMinimumShift = minCurlyLength - rightLength;\n\n switch (where) {\n case \"start\":\n // first char should be {, } found in char 2 or more\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n end =\n start === -1\n ? -1\n : content.indexOf(right, rightDelimiterMinimumShift);\n // check if next character is not one of the delimiters\n nextChar = content.charAt(end + rightLength);\n if (nextChar && right.includes(nextChar)) end = -1;\n break;\n\n case \"end\":\n // last char should be }\n start = content.lastIndexOf(left);\n end =\n start === -1\n ? -1\n : content.indexOf(right, start + rightDelimiterMinimumShift);\n end = end === content.length - rightLength ? end : -1;\n break;\n\n case \"only\":\n // '{.a}'\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n slice = content.slice(content.length - rightLength);\n end = slice === right ? content.length - rightLength : -1;\n break;\n }\n\n return (\n start !== -1 &&\n end !== -1 &&\n validCurlyLength(content.substring(start, end + rightLength))\n );\n };\n\nexport const removeDelimiter = (\n str: string,\n left: string,\n right: string,\n): string => {\n const start = escapeRegExp(left);\n const end = escapeRegExp(right);\n const pos = str.search(\n new RegExp(`[ \\\\n]?${start}[^${start}${end}]+${end}$`),\n );\n\n return pos !== -1 ? str.slice(0, pos) : str;\n};\n\nexport const getMatchingOpeningToken = (\n tokens: Token[],\n index: number,\n): Token | null => {\n if (tokens[index].type === \"softbreak\") return null;\n\n // non closing blocks, example img\n if (tokens[index].nesting === 0) return tokens[index];\n\n const level = tokens[index].level;\n const type = tokens[index].type.replace(\"_close\", \"_open\");\n\n for (; index >= 0; --index)\n if (tokens[index].type === type && tokens[index].level === level)\n return tokens[index];\n\n return null;\n};\n","import { escapeRegExp } from \"@mdit/helper\";\n\nimport type { Rule } from \"./types.js\";\nimport { addAttrs, getAttrs } from \"../attrs.js\";\nimport {\n getMatchingOpeningToken,\n hasDelimiters,\n removeDelimiter,\n} from \"../helper.js\";\nimport type {\n MarkdownItAttrRuleName,\n MarkdownItAttrsOptions,\n} from \"../options.js\";\n\nconst getFenceRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n\n // fenced code blocks\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: hasDelimiters(\"end\", options.left, options.right),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n let lineNumber = \"\";\n\n // special handler for VuePress line number\n const results = /{(?:[\\d,-]+)}/.exec(token.info);\n\n if (results) {\n token.info = token.info.replace(results[0], \"\");\n lineNumber = results[0];\n }\n\n const start = token.info.lastIndexOf(options.left);\n const attrs = getAttrs(token.info, start, options);\n\n addAttrs(attrs, token);\n token.info = `${removeDelimiter(\n token.info,\n options.left,\n options.right,\n )} ${lineNumber}`;\n },\n});\n\nconst getInlineRules = (options: Required<MarkdownItAttrsOptions>): Rule[] => [\n /**\n * bla `click()`{.c} {.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n {\n name: \"inline nesting 0\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: hasDelimiters(\"start\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n\n const endChar = token.content.indexOf(options.right);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const attrToken = tokens[index].children![childIndex - 1];\n const attrs = getAttrs(token.content, 0, options);\n\n addAttrs(attrs, attrToken);\n if (token.content.length === endChar + options.right.length)\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!.splice(childIndex, 1);\n else token.content = token.content.slice(endChar + options.right.length);\n },\n },\n\n /**\n * *emphasis*{.with attrs=1}\n */\n {\n name: \"inline attributes\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n nesting: -1, // closing inline tag, </em>{.a}\n },\n {\n shift: 0,\n type: \"text\",\n content: hasDelimiters(\"start\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const attrs = getAttrs(content, 0, options);\n const openingToken = getMatchingOpeningToken(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!,\n childIndex - 1,\n );\n\n addAttrs(attrs, openingToken);\n token.content = content.slice(\n content.indexOf(options.right) + options.right.length,\n );\n },\n },\n];\n\nconst getTableRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * | h1 |\n * | -- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: hasDelimiters(\"only\", options.left, options.right),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const tableOpen = getMatchingOpeningToken(tokens, index);\n const attrs = getAttrs(token.content, 0, options);\n\n // add attributes\n addAttrs(attrs, tableOpen);\n // remove <p>{.c}</p>\n tokens.splice(index + 1, 3);\n },\n});\n\nconst getListRules = (options: Required<MarkdownItAttrsOptions>): Rule[] => [\n /**\n * - item\n * {.a}\n */\n {\n name: \"list softbreak\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: hasDelimiters(\"only\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, indx, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[indx].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n let ii = indx - 2;\n\n while (\n tokens[ii - 1] &&\n tokens[ii - 1].type !== \"ordered_list_open\" &&\n tokens[ii - 1].type !== \"bullet_list_open\"\n )\n ii--;\n\n addAttrs(attrs, tokens[ii - 1]);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[indx].children = tokens[indx].children!.slice(0, -2);\n },\n },\n\n /**\n * - nested list\n * - with double \\n\n * {.a} <-- apply to nested ul\n *\n * {.b} <-- apply to root <ul>\n */\n {\n name: \"list double softbreak\",\n tests: [\n {\n // let this token be i = 0 so that we can erase\n // the <p>{.a}</p> tokens below\n shift: 0,\n type: (type) =>\n type === \"bullet_list_close\" || type === \"ordered_list_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: hasDelimiters(\"only\", options.left, options.right),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const attrs = getAttrs(token.content, 0, options);\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n addAttrs(attrs, openingToken);\n tokens.splice(index + 1, 3);\n },\n },\n\n /**\n * - end of {.list-item}\n */\n {\n name: \"list item end\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n type: \"text\",\n content: hasDelimiters(\"end\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const attrs = getAttrs(\n content,\n content.lastIndexOf(options.left),\n options,\n );\n\n addAttrs(attrs, tokens[index - 2]);\n\n const trimmed = content.slice(0, content.lastIndexOf(options.left));\n\n token.content =\n trimmed[trimmed.length - 1] === \" \" ? trimmed.slice(0, -1) : trimmed;\n },\n },\n];\n\nconst getSoftBreakRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * something with softbreak\n * {.cls}\n */\n\n name: \"\\n{.a} softbreak then curly in start\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: hasDelimiters(\"only\", options.left, options.right),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n\n // find last closing tag\n let ii = index + 1;\n\n while (tokens[ii + 1] && tokens[ii + 1].nesting === -1) ii++;\n\n const openingToken = getMatchingOpeningToken(tokens, ii);\n\n addAttrs(attrs, openingToken);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children = tokens[index].children!.slice(0, -2);\n },\n});\n\nconst getHrRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * horizontal rule --- {#id}\n */\n name: \"horizontal rule\",\n tests: [\n {\n shift: 0,\n type: \"paragraph_open\",\n },\n {\n shift: 1,\n type: \"inline\",\n children: (children) => children.length === 1,\n content: (content) =>\n new RegExp(\n `^ {0,3}[-*_]{3,} ?${escapeRegExp(options.left)}[^${escapeRegExp(\n options.right,\n )}]`,\n ).test(content),\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n const { content } = tokens[index + 1];\n const start = content.lastIndexOf(options.left);\n const attrs = getAttrs(content, start, options);\n\n addAttrs(attrs, token);\n token.markup = content;\n tokens.splice(index + 1, 2);\n },\n});\n\nconst getBlockRule = (options: Required<MarkdownItAttrsOptions>): Rule => ({\n /**\n * end of {.block}\n */\n\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: hasDelimiters(\"end\", options.left, options.right),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, indx, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[indx].children![childIndex];\n const { content } = token;\n const attrs = getAttrs(content, content.lastIndexOf(options.left), options);\n let ii = indx + 1;\n\n while (tokens[ii + 1] && tokens[ii + 1].nesting === -1) ii++;\n\n const openingToken = getMatchingOpeningToken(tokens, ii);\n\n addAttrs(attrs, openingToken);\n\n const trimmed = content.slice(0, content.lastIndexOf(options.left));\n\n token.content =\n trimmed[trimmed.length - 1] === \" \" ? trimmed.slice(0, -1) : trimmed;\n },\n});\n\nconst availableRules: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const getRules = (options: Required<MarkdownItAttrsOptions>): Rule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => availableRules.includes(item))\n : availableRules;\n\n const rules: Rule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(getFenceRule(options));\n if (enabledRules.includes(\"inline\")) rules.push(...getInlineRules(options));\n if (enabledRules.includes(\"list\")) rules.push(...getListRules(options));\n if (enabledRules.includes(\"table\")) rules.push(getTableRule(options));\n if (enabledRules.includes(\"softbreak\")) rules.push(getSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(getHrRule(options));\n if (enabledRules.includes(\"block\")) rules.push(getBlockRule(options));\n\n return rules;\n};\n","/**\n * Get amount item of array. Supports negative amount, where -1 is last\n * element in array.\n */\nexport const getElements = <T>(arr: T[], amount: number): T =>\n amount >= 0 ? arr[amount] : arr[arr.length + amount];\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const isArrayOfFunctions = (arr: unknown): arr is Function[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"function\");\n\nexport const isArrayOfObjects = (arr: unknown): arr is object[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"object\");\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { RuleSet } from \"./types.js\";\nimport { getElements, isArrayOfFunctions, isArrayOfObjects } from \"../utils.js\";\n\n/**\n * Test if rule matches token stream.\n *\n */\nexport const testRule = (\n tokens: Token[],\n index: number,\n rule: RuleSet,\n): { match: boolean; position: null | number } => {\n const res = {\n match: false,\n position: null as number | null, // position of child\n };\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const ii = rule.shift !== undefined ? index + rule.shift : rule.position!;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (rule.shift !== undefined && ii < 0) return res;\n\n // supports negative ii\n const token = getElements(tokens, ii);\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (token === undefined) return res;\n\n for (const key of Object.keys(rule) as (keyof typeof rule)[]) {\n if (key === \"shift\" || key === \"position\") continue;\n\n if (token[key as keyof Token] === undefined) return res;\n\n if (key === \"children\" && isArrayOfObjects(rule.children)) {\n if (token.children?.length === 0) return res;\n\n let match;\n const childTests = rule.children;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const children = token.children!;\n\n if (childTests.every((tt) => tt.position !== undefined)) {\n // positions instead of shifts, do not loop all children\n match = childTests.every(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n (tt) => testRule(children, tt.position!, tt).match,\n );\n\n if (match) {\n // we may need position of child in transform\n const j = childTests[childTests.length - 1]?.position ?? 0;\n\n res.position = j >= 0 ? j : children.length + j;\n }\n } else {\n for (let j = 0; j < children.length; j++) {\n match = childTests.every((tt) => testRule(children, j, tt).match);\n\n if (match) {\n res.position = j;\n // all tests true, continue with next key of pattern t\n break;\n }\n }\n }\n\n if (match === false) return res;\n\n continue;\n }\n\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n if (token[key] !== ruleDetail) return res;\n\n break;\n\n case \"function\":\n // @ts-expect-error: ruleDetail is a function\n if (!ruleDetail(token[key])) return res;\n\n break;\n\n case \"object\":\n if (isArrayOfFunctions(ruleDetail)) {\n const r = ruleDetail.every((tt) =>\n (tt as (key: unknown) => boolean)(token[key]),\n );\n\n if (!r) return res;\n\n break;\n }\n\n continue;\n\n // fall through for objects !== arrays of functions\n default:\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string, function or array of functions.`,\n );\n }\n }\n\n // no tests returned false -> all tests returns true\n res.match = true;\n\n return res;\n};\n","/**\n * Forked and modified from https://github.com/arve0/markdown-it-attrs/\n */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport { getRules, testRule } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = getRules({\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = ({ tokens }) => {\n for (let index = 0; index < tokens.length; index++)\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n\n const match = pattern.tests.every((t) => {\n const result = testRule(tokens, index, t);\n\n if (result.position !== null) ({ position } = result);\n\n return result.match;\n });\n\n if (match) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n pattern.transform(tokens, index, position!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting 0\"\n )\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"names":["ALLOWED_KEY_CHARS","PAIR_SEPARATOR","KEY_SEPARATOR","CLASS_MARKER","ID_MARKER","getAttrs","str","start","left","right","allowed","key","value","parsingKey","valueInsideQuotes","attrs","index","char","attr","item","addAttrs","token","attrItem","hasDelimiters","where","content","leftLength","rightLength","minCurlyLength","validCurlyLength","curly","isClass","isId","end","slice","nextChar","rightDelimiterMinimumShift","removeDelimiter","escapeRegExp","pos","getMatchingOpeningToken","tokens","level","type","getFenceRule","options","lineNumber","results","getInlineRules","childIndex","endChar","attrToken","openingToken","getTableRule","tableOpen","getListRules","indx","ii","children","trimmed","getSoftBreakRule","getHrRule","getBlockRule","availableRules","getRules","enabledRules","rules","getElements","arr","amount","isArrayOfFunctions","isArrayOfObjects","testRule","rule","res","match","childTests","tt","j","ruleDetail","md","attrsRule","ruleIndex","pattern","position","t","result"],"mappings":"4CAOa,MAAAA,EAAoB,kBACpBC,EAAiB,IACjBC,EAAgB,IAChBC,EAAe,IACfC,EAAY,IAEZC,EAAW,CACtBC,EACAC,EACA,CAAE,KAAAC,EAAM,MAAAC,EAAO,QAAAC,CAAQ,IACZ,CACX,IAAIC,EAAM,GACNC,EAAQ,GACRC,EAAa,GACbC,EAAoB,GAExB,MAAMC,EAAgB,CAAA,EAKtB,QAASC,EAAQT,EAAQC,EAAK,OAAQQ,EAAQV,EAAI,OAAQU,IAAS,CACjE,GAAIV,EAAI,MAAMU,EAAOA,EAAQP,EAAM,MAAM,IAAMA,EAAO,CAChDE,IAAQ,IAAII,EAAM,KAAK,CAACJ,EAAKC,CAAK,CAAC,EACvC,KACF,CAEA,MAAMK,EAAOX,EAAI,OAAOU,CAAK,EAG7B,GAAIC,IAASf,GAAiBW,EAAY,CACxCA,EAAa,GACb,QACF,CAGA,GAAII,IAASd,GAAgBQ,IAAQ,GAAI,CACnCL,EAAI,OAAOU,EAAQ,CAAC,IAAMb,GAC5BQ,EAAM,aACNK,KAEAL,EAAM,QAGRE,EAAa,GACb,QACF,CAGA,GAAII,IAASb,GAAaO,IAAQ,GAAI,CACpCA,EAAM,KACNE,EAAa,GACb,QACF,CAGA,GAAII,IAAS,KAAOL,IAAU,GAAI,CAChCE,E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,KAChB,CAAC,IAICH,EAAQ,UAAU1C,EAAQzB,EAAOoE,CAAS,GAGxCD,EAAQ,OAAS,qBACjBA,EAAQ,OAAS,qBAGjBD,IAEN,CACJ,EAEAF,EAAG,KAAK,MAAM,OAAO,UAAW,QAASC,CAAS,CACpD"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/helper/addAttrs.ts","../src/helper/constants.ts","../src/helper/getAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/helper/removeDelimiter.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { Attr } from \"./types.js\";\n\nexport const addAttrs = (attrs: Attr[], token: Token | null): void => {\n if (!token) return;\n\n attrs.forEach(([key, value]) => {\n switch (key) {\n case \"class\":\n token.attrJoin(\"class\", value);\n break;\n case \"css-module\":\n token.attrJoin(\"css-module\", value);\n break;\n default:\n token.attrPush([key, value]);\n }\n });\n};\n","export const CLASS_MARKER = \".\";\nexport const ID_MARKER = \"#\";\nexport const ALLOWED_KEY_CHARS = /[^\\t\\n\\f />\"'=]/;\nexport const PAIR_SEPARATOR = \" \";\nexport const KEY_SEPARATOR = \"=\";\n","import {\n ALLOWED_KEY_CHARS,\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n} from \"./constants.js\";\nimport type { Attr, DelimiterConfig } from \"./types.js\";\n\nexport const getAttrs = (\n str: string,\n start: number,\n { left, right, allowed }: DelimiterConfig,\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside {}\n // start + left delimiter length to avoid beginning {\n // breaks when } is found or end of string\n for (let index = start + left.length; index < str.length; index++) {\n if (str.slice(index, index + right.length) === right) {\n if (key !== \"\") attrs.push([key, value]);\n break;\n }\n\n const char = str.charAt(index);\n\n // switch to reading value if equal sign\n if (char === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (char === CLASS_MARKER && key === \"\") {\n if (str.charAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (char === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (char === '\"' && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (char === '\"' && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (char === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\")\n // beginning or ending space: { .red } vs {.red}\n continue;\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && char.search(ALLOWED_KEY_CHARS) === -1) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += char;\n continue;\n }\n\n value += char;\n }\n\n return allowed.length\n ? attrs.filter(([attr]) =>\n allowed.some((item) =>\n item instanceof RegExp ? item.test(attr) : item === attr,\n ),\n )\n : attrs;\n};\n","import { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\n\nexport type DelimiterChecker = (content: string) => boolean;\n\nexport const getDelimiterChecker = (\n { left, right }: Required<DelimiterConfig>,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where)) {\n throw new Error(\n `Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`,\n );\n }\n\n return (content: string): boolean => {\n const leftLength = left.length;\n const rightLength = right.length;\n // we need minimum three chars, for example {b}\n const minCurlyLength = leftLength + 1 + rightLength;\n const rightDelimiterMinimumShift = leftLength + 1;\n\n // perform a quick check\n if (\n !content ||\n typeof content !== \"string\" ||\n content.length < minCurlyLength\n )\n return false;\n\n const validCurlyLength = (curly: string): boolean =>\n [CLASS_MARKER, ID_MARKER].includes(curly.charAt(leftLength))\n ? curly.length >= minCurlyLength + 1\n : curly.length >= minCurlyLength;\n\n let start: number;\n let end: number;\n let slice: string;\n let nextChar: string;\n\n if (where === \"start\") {\n // first char should be {, } found in char 2 or more\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n end =\n start === -1 ? -1 : content.indexOf(right, rightDelimiterMinimumShift);\n // check if next character is not one of the delimiters\n nextChar = content.charAt(end + rightLength);\n if (nextChar && right.includes(nextChar)) end = -1;\n } else if (where === \"end\") {\n // last char should be }\n start = content.lastIndexOf(left);\n end =\n start === -1\n ? -1\n : content.indexOf(right, start + rightDelimiterMinimumShift);\n end = end === content.length - rightLength ? end : -1;\n } else {\n // '{.a}'\n slice = content.slice(0, leftLength);\n start = slice === left ? 0 : -1;\n slice = content.slice(content.length - rightLength);\n end = slice === right ? content.length - rightLength : -1;\n }\n\n return (\n start !== -1 &&\n end !== -1 &&\n validCurlyLength(content.substring(start, end + rightLength))\n );\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (\n tokens: Token[],\n index: number,\n): Token | null => {\n const token = tokens[index];\n\n if (token.type === \"softbreak\") return null;\n\n // non closing blocks, example img\n if (token.nesting === 0) return token;\n\n const level = token.level;\n const type = token.type.replace(\"_close\", \"_open\");\n\n while (index >= 0) {\n const currentToken = tokens[index];\n\n if (currentToken.type === type && currentToken.level === level)\n return currentToken;\n\n index--;\n }\n\n /* istanbul ignore next -- @preserve */\n return null;\n};\n","import { escapeRegExp } from \"@mdit/helper\";\n\nexport const removeDelimiter = (\n str: string,\n left: string,\n right: string,\n): string => {\n const start = escapeRegExp(left);\n const end = escapeRegExp(right);\n const pos = str.search(\n new RegExp(`[ \\\\n]?${start}[^${start}${end}]+${end}$`),\n );\n\n return pos !== -1 ? str.slice(0, pos) : str;\n};\n","/**\n * Get index item of array. Supports negative index, where -1 is last\n * element in array.\n */\nexport const getArrayItem = <T>(arr: T[], index: number): T =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const isArrayOfFunctions = (arr: unknown): arr is Function[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"function\");\n\nexport const isArrayOfObjects = (arr: unknown): arr is object[] =>\n Array.isArray(arr) &&\n Boolean(arr.length) &&\n arr.every((item) => typeof item === \"object\");\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet, TestFunction } from \"../rules/types.js\";\nimport {\n getArrayItem,\n isArrayOfFunctions,\n isArrayOfObjects,\n} from \"../utils.js\";\n\nexport interface TestRuleResult {\n /** whether rule matches token stream */\n match: boolean;\n /** position of token */\n position: null | number;\n}\n\n/**\n * Test if rule matches token stream.\n *\n */\nexport const testRule = (\n tokens: Token[],\n index: number,\n rule: AttrRuleSet,\n): TestRuleResult => {\n const result: TestRuleResult = {\n match: false,\n position: null,\n };\n\n const tokenIndex =\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n rule.shift !== undefined ? index + rule.shift : rule.position!;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (rule.shift !== undefined && tokenIndex < 0) return result;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!token) return result;\n\n for (const key of Object.keys(rule) as (keyof typeof rule)[]) {\n if (key === \"shift\" || key === \"position\") continue;\n\n if (token[key as keyof Token] === undefined) return result;\n\n if (key === \"children\" && isArrayOfObjects(rule.children)) {\n if (token.children?.length === 0) return result;\n\n let match;\n const childTests = rule.children;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const children = token.children!;\n\n if (childTests.every((childTest) => childTest.position !== undefined)) {\n // positions instead of shifts, do not loop all children\n match = childTests.every(\n (childTest) =>\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n testRule(children, childTest.position!, childTest).match,\n );\n\n if (match) {\n // we may need position of child in transform\n const position = childTests[childTests.length - 1]?.position ?? 0;\n\n result.position =\n position >= 0 ? position : children.length + position;\n }\n } else {\n for (let token = 0; token < children.length; token++) {\n match = childTests.every(\n (childTest) => testRule(children, token, childTest).match,\n );\n\n if (match) {\n result.position = token;\n // all tests true, continue with next key of pattern t\n break;\n }\n }\n }\n\n if (match === false) return result;\n\n continue;\n }\n\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return result;\n\n break;\n }\n\n case \"function\": {\n if (!(ruleDetail as TestFunction)(token[key])) return result;\n\n break;\n }\n\n // fall through for objects !== arrays of functions\n default: {\n if (isArrayOfFunctions(ruleDetail)) {\n if (\n !(ruleDetail as TestFunction[]).every((ruleItem) =>\n ruleItem(token[key]),\n )\n )\n return result;\n\n break;\n }\n\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string, function or array of functions.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n result.match = true;\n\n return result;\n};\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getBlockRule = (options: Required<DelimiterConfig>): AttrRule =>\n /**\n * end of {.block}\n */\n ({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: getDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n\n // Extract attributes from the content\n const attrStartIndex = content.lastIndexOf(options.left);\n const attrs = getAttrs(content, attrStartIndex, options);\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (\n tokens[closingTokenIndex + 1] &&\n tokens[closingTokenIndex + 1].nesting === -1\n ) {\n closingTokenIndex++;\n }\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(attrs, openingToken);\n\n // Remove the attribute syntax from content\n const contentWithoutAttributes = content.slice(0, attrStartIndex);\n const hasTrailingSpace =\n contentWithoutAttributes[contentWithoutAttributes.length - 1] === \" \";\n\n token.content = hasTrailingSpace\n ? contentWithoutAttributes.slice(0, -1)\n : contentWithoutAttributes;\n },\n });\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n removeDelimiter,\n} from \"../helper/index.js\";\n\nexport const getFenceRule = (options: Required<DelimiterConfig>): AttrRule =>\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n ({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: getDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n let lineNumbers = \"\";\n\n // Special handler for VuePress line numbers syntax\n const lineNumberMatch = /{(?:[\\d,-]+)}/.exec(token.info);\n\n if (lineNumberMatch) {\n token.info = token.info.replace(lineNumberMatch[0], \"\");\n lineNumbers = lineNumberMatch[0];\n }\n\n // Extract attributes from the token info\n const attributeStartIndex = token.info.lastIndexOf(options.left);\n const attributes = getAttrs(token.info, attributeStartIndex, options);\n\n // Apply attributes to the current token\n addAttrs(attributes, token);\n\n // Remove attribute syntax from info and restore line numbers\n const infoWithoutAttributes = removeDelimiter(\n token.info,\n options.left,\n options.right,\n );\n\n token.info = `${infoWithoutAttributes} ${lineNumbers}`.trim();\n },\n });\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getInlineRules = (\n options: Required<DelimiterConfig>,\n): AttrRule[] => [\n /**\n * bla `click()`{.c} {.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n {\n name: \"inline nesting self-close\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: getDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n const rightDelimiterLength = options.right.length;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n\n const attrEndIndex = token.content.indexOf(options.right);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const targetToken = tokens[index].children![childIndex - 1];\n const attrs = getAttrs(token.content, 0, options);\n\n // Apply attributes to the target token\n addAttrs(attrs, targetToken);\n\n // Remove or update token content based on remaining content\n if (token.content.length === attrEndIndex + rightDelimiterLength) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!.splice(childIndex, 1);\n } else {\n token.content = token.content.slice(\n attrEndIndex + rightDelimiterLength,\n );\n }\n },\n },\n\n /**\n * *emphasis*{.with attrs=1}\n */\n {\n name: \"inline attributes\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n nesting: -1, // closing inline tag, </em>{.a}\n },\n {\n shift: 0,\n type: \"text\",\n content: getDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const currentToken = tokens[index].children![childIndex];\n const { content } = currentToken;\n\n // Extract attributes from the content\n const attributes = getAttrs(content, 0, options);\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children!,\n childIndex - 1,\n );\n\n // Apply attributes to the opening token\n addAttrs(attributes, openingToken);\n\n // Remove attribute syntax from content\n const attributeEndIndex =\n content.indexOf(options.right) + options.right.length;\n\n currentToken.content = content.slice(attributeEndIndex);\n },\n },\n];\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getListRules = (\n options: Required<DelimiterConfig>,\n): AttrRule[] => [\n /**\n * - item\n * {.a}\n */\n {\n name: \"list softbreak\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: getDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1] &&\n tokens[listOpenIndex - 1].type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n ) {\n listOpenIndex--;\n }\n\n // Apply attributes to the list opening token\n addAttrs(attrs, tokens[listOpenIndex - 1]);\n\n // Remove the attribute tokens from children\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children = tokens[index].children!.slice(0, -2);\n },\n },\n\n /**\n * - nested list\n * - with double \\n\n * {.a} <-- apply to nested ul\n *\n * {.b} <-- apply to root <ul>\n */\n {\n name: \"list double softbreak\",\n tests: [\n {\n // let this token be i = 0 so that we can erase\n // the <p>{.a}</p> tokens below\n shift: 0,\n type: (type) =>\n type === \"bullet_list_close\" || type === \"ordered_list_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: getDelimiterChecker(options, \"only\"),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const attrs = getAttrs(token.content, 0, options);\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(attrs, openingToken);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n },\n\n /**\n * - end of {.list-item}\n */\n {\n name: \"list item end\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n type: \"text\",\n content: getDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n\n // Extract attributes from the content\n const attrStartIndex = content.lastIndexOf(options.left);\n const attrs = getAttrs(content, attrStartIndex, options);\n\n // Apply attributes to the list item opening token\n addAttrs(attrs, tokens[index - 2]);\n\n // Remove attribute syntax from content\n const contentWithoutAttributes = content.slice(0, attrStartIndex);\n const hasTrailingSpace =\n contentWithoutAttributes[contentWithoutAttributes.length - 1] === \" \";\n\n token.content = hasTrailingSpace\n ? contentWithoutAttributes.slice(0, -1)\n : contentWithoutAttributes;\n },\n },\n];\n","import type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\nexport const getSoftBreakRule = (\n options: Required<DelimiterConfig>,\n): AttrRule => ({\n /**\n * something with softbreak\n * {.cls}\n */\n\n name: \"\\n{.a} softbreak then curly in start\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: getDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const attrs = getAttrs(token.content, 0, options);\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (\n tokens[closingTokenIndex + 1] &&\n tokens[closingTokenIndex + 1].nesting === -1\n ) {\n closingTokenIndex++;\n }\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(attrs, openingToken);\n\n // Remove the softbreak and attribute tokens\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n tokens[index].children = tokens[index].children!.slice(0, -2);\n },\n});\n","import { escapeRegExp } from \"@mdit/helper\";\n\nimport type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getAttrs } from \"../helper/index.js\";\n\nexport const getHrRule = (options: Required<DelimiterConfig>): AttrRule => ({\n /**\n * horizontal rule --- {#id}\n */\n name: \"horizontal rule\",\n tests: [\n {\n shift: 0,\n type: \"paragraph_open\",\n },\n {\n shift: 1,\n type: \"inline\",\n children: (children) => children.length === 1,\n content: (content) =>\n new RegExp(\n `^ {0,3}[-*_]{3,} ?${escapeRegExp(options.left)}[^${escapeRegExp(\n options.right,\n )}]`,\n ).test(content),\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index];\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n const attributeStartIndex = content.lastIndexOf(options.left);\n const attributes = getAttrs(content, attributeStartIndex, options);\n\n // Apply attributes to the hr token\n addAttrs(attributes, token);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n});\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport {\n addAttrs,\n getAttrs,\n getDelimiterChecker,\n getMatchingOpeningToken,\n} from \"../helper/index.js\";\n\ninterface TokenWithColumnCount extends Token {\n meta:\n | {\n columnCount?: number;\n [key: string]: unknown;\n }\n | undefined;\n}\n\n/**\n * Hidden table's cells and them inline children,\n * specially cast inline's content as empty\n * to prevent that escapes the table's box model\n */\nconst hideTokenContent = (token: Token): void => {\n token.hidden = true;\n token.children?.forEach((childToken) => {\n childToken.content = \"\";\n hideTokenContent(childToken);\n });\n};\n\n/**\n * Handle rowspan logic for table cells\n */\nconst handleRowspan = (\n tokens: Token[],\n startIndex: number,\n endIndex: number,\n columnCount: number,\n colspan: number,\n rowspan: number,\n): void => {\n let adjustedColumnCount = columnCount - (colspan > 0 ? colspan : 1);\n\n for (\n let tokenIndex = startIndex, remainingRows = rowspan;\n tokenIndex < endIndex && remainingRows > 1;\n tokenIndex++\n ) {\n if (tokens[tokenIndex].type === \"tr_open\") {\n const trOpenToken = tokens[tokenIndex] as TokenWithColumnCount;\n\n trOpenToken.meta ??= {};\n\n if (trOpenToken.meta.columnCount) {\n adjustedColumnCount -= 1;\n }\n\n trOpenToken.meta.columnCount = adjustedColumnCount;\n remainingRows--;\n }\n }\n};\n\n/**\n * Handle table row processing\n */\nconst handleTableRow = (\n tokens: Token[],\n startIndex: number,\n endIndex: number,\n): void => {\n const token = tokens[startIndex] as TokenWithColumnCount;\n const expectedColumnCount = token.meta?.columnCount;\n\n if (!expectedColumnCount) return;\n\n // hide extra table cells in the row\n for (let index = startIndex, cellCount = 0; index < endIndex; index++) {\n const currentToken = tokens[index];\n\n // Count table cells in the row\n if (currentToken.type === \"td_open\") {\n cellCount += 1;\n }\n // break at end of table row\n else if (currentToken.type === \"tr_close\") {\n break;\n }\n\n // hide extra table cells\n if (cellCount > expectedColumnCount && !currentToken.hidden) {\n hideTokenContent(currentToken);\n }\n }\n};\n\n/**\n * Handle colspan logic for table cells\n */\nconst handleColspan = (\n tokens: Token[],\n startIndex: number,\n endIndex: number,\n columnCount: number,\n colspan: number,\n tbodyOpenIndex: number,\n): void => {\n const cellIndices: number[] = [];\n const startToken = tokens[startIndex];\n\n let end = startIndex + 3;\n let colspanNum = columnCount;\n\n // Find previous row children indices\n for (let tokenIndex = startIndex; tokenIndex > tbodyOpenIndex; tokenIndex--) {\n if (tokens[tokenIndex].type === \"tr_open\") {\n colspanNum =\n (tokens[tokenIndex] as TokenWithColumnCount).meta?.columnCount ??\n colspanNum;\n break;\n } else if (tokens[tokenIndex].type === \"td_open\") {\n cellIndices.unshift(tokenIndex);\n }\n }\n\n // Find current row children indices\n for (let index = startIndex + 2; index < endIndex; index++) {\n if (tokens[index].type === \"tr_close\") {\n end = index;\n break;\n } else if (tokens[index].type === \"td_open\") {\n cellIndices.push(index);\n }\n }\n\n const cellOffset = cellIndices.indexOf(startIndex);\n\n const realColspan = Math.min(colspan, colspanNum - cellOffset);\n\n if (colspan > realColspan) {\n startToken.attrSet(\"colspan\", realColspan.toString());\n }\n\n const hiddenStartIndex = cellIndices.slice(\n colspanNum + 1 - columnCount - realColspan,\n )[0];\n\n for (let index = hiddenStartIndex; index < end; index++) {\n if (!tokens[index].hidden) hideTokenContent(tokens[index]);\n }\n};\n\nexport const getTableRules = (\n options: Required<DelimiterConfig>,\n): AttrRule[] => [\n {\n /**\n * | h1 |\n * | -- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: getDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n const attrs = getAttrs(token.content, 0, options);\n\n // Apply attributes to the table opening token\n addAttrs(attrs, tableOpeningToken);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n },\n /**\n * Handle table cell attributes: title {.class}\n * This rule processes attributes within table cell text content\n */\n {\n name: \"table cell attributes\",\n tests: [\n {\n shift: -1,\n type: (type) => type === \"td_open\" || type === \"th_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: 0,\n type: \"text\",\n content: getDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex): void => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n\n // Find last attribute syntax in the content\n const attrStartIndex = content.lastIndexOf(options.left);\n\n // Extract attributes from the content\n const attributes = getAttrs(content, attrStartIndex, options);\n\n // Apply attributes to the table cell token\n addAttrs(attributes, cellOpenToken);\n\n // Remove attribute syntax from content\n token.content = content.substring(0, attrStartIndex).trim();\n },\n },\n {\n /**\n * | A | B |\n * | -- | -- |\n * | 1 | 2 |\n *\n * | C | D |\n * | -- | -- |\n *\n * only `| A | B |` sets the columnCount metadata\n */\n name: \"table thead metadata\",\n tests: [\n {\n shift: 0,\n type: \"tr_close\",\n },\n {\n shift: 1,\n type: \"thead_close\",\n },\n {\n shift: 2,\n type: \"tbody_open\",\n },\n ],\n\n transform: (tokens, index): void => {\n const trOpenToken = getMatchingOpeningToken(tokens, index);\n const thCloseToken = tokens[index - 1];\n let columnCount = 0;\n let currentIndex = index - 1;\n\n // Find the matching tr_open token and count columns\n while (currentIndex > 0) {\n const currentToken = tokens[currentIndex];\n\n if (currentToken === trOpenToken) {\n const tHeadOpenToken = tokens[\n currentIndex - 1\n ] as TokenWithColumnCount;\n\n tHeadOpenToken.meta = {\n ...tHeadOpenToken.meta,\n columnCount,\n };\n break;\n }\n\n // Count th_close tokens at the same level\n if (\n currentToken.level === thCloseToken.level &&\n currentToken.type === thCloseToken.type\n ) {\n columnCount++;\n }\n\n currentIndex--;\n }\n\n // Apply metadata to tbody_open token\n const tbodyOpenToken = tokens[index + 2] as TokenWithColumnCount;\n\n tbodyOpenToken.meta = {\n ...tbodyOpenToken.meta,\n columnCount,\n };\n },\n },\n {\n /**\n * | A | B | C | D |\n * | -- | -- | -- | -- |\n * | 1 | 11 | 111 | 1111 {rowspan=3} |\n * | 2 {colspan=2 rowspan=2} | 22 | 222 | 2222 |\n * | 3 | 33 | 333 | 3333 |\n */\n name: \"table tbody calculate\",\n tests: [\n {\n shift: 0,\n type: \"tbody_close\",\n hidden: false,\n },\n ],\n transform: (tokens, index): void => {\n // Find the tbody_open token index\n let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex > 0) {\n tbodyOpenIndex--;\n if (tokens[tbodyOpenIndex].type === \"tbody_open\") break;\n }\n\n const columnCount = Number(\n (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta?.columnCount ?? 0,\n );\n\n if (columnCount < 2) return;\n\n const maxLevel = tokens[index].level + 2;\n\n for (\n let currentIndex = tbodyOpenIndex;\n currentIndex < index;\n currentIndex++\n ) {\n if (tokens[currentIndex].level > maxLevel) continue;\n\n const token = tokens[currentIndex];\n const rowspan = token.hidden ? 0 : Number(token.attrGet(\"rowspan\"));\n const colspan = token.hidden ? 0 : Number(token.attrGet(\"colspan\"));\n\n if (rowspan > 1) {\n handleRowspan(\n tokens,\n currentIndex,\n index,\n columnCount,\n colspan,\n rowspan,\n );\n }\n\n if (token.type === \"tr_open\") {\n handleTableRow(tokens, currentIndex, index);\n }\n\n if (colspan > 1) {\n handleColspan(\n tokens,\n currentIndex,\n index,\n columnCount,\n colspan,\n tbodyOpenIndex,\n );\n }\n }\n },\n },\n];\n","import type { AttrRule } from \"./types.js\";\nimport type {\n MarkdownItAttrRuleName,\n MarkdownItAttrsOptions,\n} from \"../options.js\";\nimport { getBlockRule } from \"./block.js\";\nimport { getFenceRule } from \"./fence.js\";\nimport { getHrRule } from \"./hr.js\";\nimport { getInlineRules } from \"./inline.js\";\nimport { getListRules } from \"./list.js\";\nimport { getSoftBreakRule } from \"./softbreak.js\";\nimport { getTableRules } from \"./table.js\";\n\nconst AVAILABLE_RULES: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const getRules = (\n options: Required<MarkdownItAttrsOptions>,\n): AttrRule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => AVAILABLE_RULES.includes(item))\n : AVAILABLE_RULES;\n\n const rules: AttrRule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(getFenceRule(options));\n if (enabledRules.includes(\"inline\")) rules.push(...getInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...getTableRules(options));\n if (enabledRules.includes(\"list\")) rules.push(...getListRules(options));\n if (enabledRules.includes(\"softbreak\")) rules.push(getSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(getHrRule(options));\n if (enabledRules.includes(\"block\")) rules.push(getBlockRule(options));\n\n return rules;\n};\n","/**\n * Forked and modified from https://github.com/arve0/markdown-it-attrs/\n */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { testRule } from \"./helper/index.js\";\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport { getRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = getRules({\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = ({ tokens }) => {\n for (let index = 0; index < tokens.length; index++)\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n\n const match = pattern.tests.every((t) => {\n const result = testRule(tokens, index, t);\n\n if (result.position !== null) ({ position } = result);\n\n return result.match;\n });\n\n if (match) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n pattern.transform(tokens, index, position!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting self-close\"\n )\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"names":["addAttrs","attrs","token","key","value","CLASS_MARKER","ID_MARKER","ALLOWED_KEY_CHARS","PAIR_SEPARATOR","KEY_SEPARATOR","getAttrs","str","start","left","right","allowed","parsingKey","valueInsideQuotes","index","char","attr","item","getDelimiterChecker","where","content","leftLength","rightLength","minCurlyLength","rightDelimiterMinimumShift","validCurlyLength","curly","end","slice","nextChar","getMatchingOpeningToken","tokens","level","type","currentToken","removeDelimiter","escapeRegExp","pos","getArrayItem","arr","isArrayOfFunctions","isArrayOfObjects","testRule","rule","result","tokenIndex","match","childTests","children","childTest","position","ruleDetail","ruleItem","getBlockRule","options","childIndex","attrStartIndex","closingTokenIndex","openingToken","contentWithoutAttributes","hasTrailingSpace","getFenceRule","lineNumbers","lineNumberMatch","attributeStartIndex","attributes","infoWithoutAttributes","getInlineRules","rightDelimiterLength","attrEndIndex","targetToken","attributeEndIndex","getListRules","listOpenIndex","getSoftBreakRule","getHrRule","inlineToken","hideTokenContent","childToken","handleRowspan","startIndex","endIndex","columnCount","colspan","rowspan","adjustedColumnCount","remainingRows","trOpenToken","handleTableRow","expectedColumnCount","cellCount","handleColspan","tbodyOpenIndex","cellIndices","startToken","colspanNum","cellOffset","realColspan","hiddenStartIndex","getTableRules","tableOpeningToken","cellOpenToken","thCloseToken","currentIndex","tHeadOpenToken","tbodyOpenToken","maxLevel","AVAILABLE_RULES","get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AAW,QAASC,CAAS,CACpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdit/plugin-attrs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "attrs plugin for MarkdownIt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"markdown-it",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@types/markdown-it": "^14.1.2",
|
|
41
|
-
"@mdit/helper": "0.
|
|
41
|
+
"@mdit/helper": "0.22.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"markdown-it": "14.1.0",
|
|
45
|
-
"@mdit/plugin-katex": "0.
|
|
45
|
+
"@mdit/plugin-katex": "0.22.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"markdown-it": "^14.1.0"
|