@mdit/plugin-attrs 0.24.2 → 0.25.1

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.
@@ -0,0 +1,3 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.mdItPluginAttrs={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let t=e=>!(e===9||e===10||e===12||e===32||e===47||e===62||e===34||e===39||e===61),n=(e,n,r)=>{let i=``,a=``,o=!0,s=!1,c=[];for(let r=n[0];r<n[1];r++){let n=e.charCodeAt(r);if(n===61&&o){o=!1;continue}if(n===46&&i===``){e.charCodeAt(r+1)===46?(i=`css-module`,r++):i=`class`,o=!1;continue}if(n===35&&i===``){i=`id`,o=!1;continue}if(n===34&&a===``&&!s){s=!0;continue}if(n===34&&s){s=!1;continue}if(n===32&&!s){if(i===``)continue;c.push([i,a]),i=``,a=``,o=!0;continue}if(!(o&&!t(n))){if(o){i+=String.fromCharCode(n);continue}a+=String.fromCharCode(n)}}return i!==``&&c.push([i,a]),r.length>0?c.filter(([e])=>r.some(t=>t instanceof RegExp?t.test(e):t===e)):c},r=(e,t,r,i)=>{e&&n(t,r,i).forEach(([t,n])=>{switch(t){case`class`:e.attrJoin(`class`,n);break;case`css-module`:e.attrJoin(`css-module`,n);break;default:e.attrPush([t,n])}})},i=(e,t)=>{if(![`start`,`end`,`only`].includes(t))throw Error(`Invalid 'where' parameter: ${t}. Expected 'start', 'end', or 'only'.`);let n=e.left,r=e.right,i=n.length,a=r.length,o=i+1+a;return e=>{if(typeof e!=`string`||e.length<o)return!1;let s,c;if(t===`start`){if(!e.startsWith(n)||(s=i,c=e.indexOf(r,i+1),c===-1))return!1;let t=c+a;if(t<e.length&&r.includes(e.charAt(t)))return!1}else if(t===`end`){if(s=e.lastIndexOf(n),s===-1||(c=e.indexOf(r,s+i+1),s+=i,c===-1||c+a!==e.length))return!1}else{if(!e.startsWith(n)||!e.endsWith(r))return!1;s=i,c=e.length-a}let l=e.charCodeAt(s),u=c-s;return(l===46||l===35?u>=2:u>=1)?[s,c]:!1}},a=(e,t)=>{let n=e[t];if(n.type===`softbreak`)return null;if(n.nesting===0)return n;let r=n.level,i=n.type.replace(`_close`,`_open`);for(;t>=0;){let n=e[t];if(n.type===i&&n.level===r)return n;t--}return null},o=(e,t)=>t>=0?e[t]:e[e.length+t],s=(e,t,n)=>{let r={match:!1,position:null,range:null},i=typeof n.shift==`number`,a=i?t+n.shift:n.position;if(i&&a<0)return r;let c=o(e,a);if(!c)return r;let l=Object.keys(n),u=l.length;for(let e=0;e<u;e++){let t=l[e];if(t===`shift`||t===`position`)continue;if(c[t]==null)return r;if(t===`children`&&Array.isArray(n.children)){if(!c.children?.length)return r;let e=n.children,t=c.children,i,a=null;if(e.every(e=>typeof e.position==`number`)){if(i=e.every(e=>{let n=s(t,e.position,e);return n.match?(n.range&&(a=n.range),!0):!1}),i){let{position:n}=e[e.length-1];r.position=n>=0?n:t.length+n,r.range=a}}else for(let n=0;n<t.length;n++)if(i=e.every(e=>{let r=s(t,n,e);return r.match?(r.range&&(a=r.range),!0):!1}),i){r.position=n,a&&(r.range=a);break}if(i===!1)return r;continue}let i=n[t];switch(typeof i){case`boolean`:case`number`:case`string`:if(c[t]!==i)return r;break;case`function`:{let e=i(c[t]);if(!e)return r;Array.isArray(e)&&(r.range=e);break}default:throw Error(`Unknown type of pattern test (key: ${t}). Test should be of type boolean, number, string or function.`)}}return r.match=!0,r},c=e=>e,l=(e,t)=>{let n=e.utils.isSpace;return c({name:`end of block`,tests:[{shift:0,type:`inline`,children:[{position:-1,content:i(t,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(e,i,o,s)=>{let c=s[0]-t.left.length,l=e[i].children[o],{content:u}=l,d=n(u.charCodeAt(c-1)),f=i+1;for(;e[f+1]?.nesting===-1;)f++;r(a(e,f),u,s,t.allowed),l.content=u.slice(0,d?c-1:c)}})},u=(e,t)=>{let n=e.utils.isSpace;return c({name:`code-block`,tests:[{shift:0,block:!0,info:i(t,`end`)}],transform:(e,i,a,o)=>{let s=o[0]-t.left.length,c=e[i],{info:l}=c,u=n(l.charCodeAt(s-1));r(c,l,o,t.allowed),c.info=l.slice(0,u?s-1:s)}})},d=(e,t)=>{let n=e.utils.isSpace;return c({name:`end of block`,tests:[{shift:-1,type:`heading_open`},{shift:0,type:`inline`,children:[{position:-1,content:i(t,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(e,i,o,s)=>{let c=s[0]-t.left.length,l=e[i].children[o],{content:u}=l,d=n(u.charCodeAt(c-1));r(a(e,i+1),u,s,t.allowed),l.content=u.slice(0,d?c-1:c)}})},f=e=>[c({name:`inline nesting self-close`,tests:[{shift:0,type:`inline`,children:[{shift:-1,type:e=>e===`image`||e===`code_inline`},{shift:0,type:`text`,content:i(e,`start`)}]}],transform:(t,n,i,a)=>{let o=t[n].children,s=o[i],c=o[i-1],l=e.right.length+a[1];r(c,s.content,a,e.allowed),s.content.length===l?o.splice(i,1):s.content=s.content.slice(l)}}),c({name:`inline attributes`,tests:[{shift:0,type:`inline`,children:[{shift:-1,nesting:-1},{shift:0,type:`text`,content:i(e,`start`)}]}],transform:(t,n,i,o)=>{let s=t[n].children,c=s[i],{content:l}=c,u=e.right.length+o[1];r(a(s,i-1),l,o,e.allowed),c.content=l.slice(u)}})],p=(e,t)=>{let n=e.utils.isSpace,o=t.allowed;return[c({name:`list softbreak`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:i(t,`only`)}]}],transform:(e,t,n,i)=>{let a=e[t].children,s=a[n],c=t-2;for(;e[c-1]?.type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;r(e[c-1],s.content,i,o),e[t].children=a.slice(0,-2)}}),c({name:`list double softbreak`,tests:[{shift:0,type:e=>e===`bullet_list_close`||e===`ordered_list_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:i(t,`only`),children:e=>e.length===1},{shift:3,type:`paragraph_close`}],transform:(e,t,n,i)=>{let s=e[t+2];r(a(e,t),s.content,i,o),e.splice(t+1,3)}}),c({name:`list item end`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-1,type:`text`,content:i(t,`end`)}]}],transform:(e,i,a,s)=>{let c=e[i].children[a],l=c.content,u=s[0]-t.left.length,d=n(l.charCodeAt(u-1));r(e[i-2],l,s,o),c.content=l.slice(0,d?u-1:u)}})]},m=e=>c({name:`
2
+ {.a} softbreak then curly in start`,tests:[{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:i(e,`only`)}]}],transform:(t,n,i,o)=>{let s=t[n].children,c=s[i],l=n+1;for(;t[l+1]?.nesting===-1;)l++;r(a(t,l),c.content,o,e.allowed),t[n].children=s.slice(0,-2)}}),h=(e,t)=>{let n=e.utils.isSpace;return c({name:`horizontal rule`,tests:[{shift:0,type:`paragraph_open`},{shift:1,type:`inline`,children:e=>e.length===1,content:e=>{let r=0,a,o=e.charCodeAt(r++);if(o!==45&&o!==42&&o!==95)return!1;let s=1;for(;r<e.length&&(a=e.charCodeAt(r++),a===o);)s++;return s<3?!1:(n(e.charCodeAt(r-1))||r--,i(t,`end`)(e))}},{shift:2,type:`paragraph_close`}],transform:(e,n,i,a)=>{let o=e[n],{content:s}=e[n+1];o.type=`hr`,o.tag=`hr`,o.nesting=0,r(o,s,a,t.allowed),o.markup=s,e.splice(n+1,2)}})},g=(e,t)=>{let n=e.utils.isSpace,o=t.allowed;return[c({name:`table`,tests:[{shift:0,type:`table_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:i(t,`only`)}],transform:(e,t,n,i)=>{let s=e[t+2];r(a(e,t),s.content,i,o),e.splice(t+1,3)}}),c({name:`table cell attributes`,tests:[{shift:-1,type:e=>e===`td_open`||e===`th_open`},{shift:0,type:`inline`,children:[{shift:0,type:`text`,content:i(t,`end`)}]}],transform:(e,i,a,s)=>{let c=s[0]-t.left.length,l=e[i].children[a],u=e[i-1],{content:d}=l,f=n(d.charCodeAt(c-1));r(u,d,s,o),l.content=d.slice(0,f?c-1:c)}}),c({name:`table thead metadata`,tests:[{shift:0,type:`tr_close`},{shift:1,type:`thead_close`},{shift:2,type:`tbody_open`}],transform:(e,t)=>{let n=a(e,t),r=e[t-1],i=0,o=t-1;for(;o>0;){let t=e[o];if(t===n){let t=e[o-1];t.meta={...t.meta,columnCount:i};break}t.level===r.level&&t.type===r.type&&i++,o--}let s=e[t+2];s.meta={...s.meta,columnCount:i}}}),c({name:`table tbody calculate`,tests:[{shift:0,type:`tbody_close`,hidden:!1}],transform:(e,t)=>{let n=t-2;for(;n>=0&&e[n].type!==`tbody_open`;)n--;let r=e[n].meta.columnCount;if(r<2)return;let i=Array.from({length:r}).fill(0),a=[],o=n+1;for(;o<t;){let n=o,s=n+1;for(;s<t&&e[s].type!==`tr_close`;)s++;let c=[],l=n+1;for(;l<s;){let t=l+1;for(;t<s&&e[t].type!==`td_close`&&e[t].type!==`th_close`;)t++;c.push([l,t]),l=t+1}let u=0,d=0;for(;d<r;){if(i[d]>0){i[d]--,a.push(c[u]),u++,d++;continue}let t=e[c[u][0]],n=Number(t.attrGet(`colspan`))||1,o=Number(t.attrGet(`rowspan`))||1;u++;let s=0;for(let e=0;e<n;e++)if(d+e<r)if(i[d+e]===0)s++;else break;n>1&&s<n&&t.attrSet(`colspan`,String(s));for(let e=0;e<s;e++)i[d+e]=o-1;let l=s-1;if(l>0)for(let e=0;e<l;e++)a.push(c[u]),u++;d+=s}o=s+1}a.sort((e,t)=>t[0]-e[0]);for(let[t,n]of a)e.splice(t,n-t+1)}})]},_=[`fence`,`inline`,`table`,`list`,`heading`,`hr`,`softbreak`,`block`],v=(e,t)=>{let n=t.rule===!1?[]:Array.isArray(t.rule)?t.rule.filter(e=>_.includes(e)):_,r=[];return n.includes(`fence`)&&r.push(u(e,t)),n.includes(`inline`)&&r.push(...f(t)),n.includes(`table`)&&r.push(...g(e,t)),n.includes(`list`)&&r.push(...p(e,t)),n.includes(`softbreak`)&&r.push(m(t)),n.includes(`hr`)&&r.push(h(e,t)),n.includes(`block`)?r.push(l(e,t)):n.includes(`heading`)&&r.push(d(e,t)),r};e.attrs=(e,{left:t=`{`,right:n=`}`,allowed:r=[],rule:i=`all`}={})=>{let a=v(e,{left:t,right:n,allowed:r,rule:i});e.core.ruler.before(`linkify`,`attrs`,e=>{let t=e.tokens;for(let e=0;e<t.length;e++)for(let n=0;n<a.length;n++){let r=a[n],i=null,o=null;r.tests.every(n=>{let r=s(t,e,n);return r.position!=null&&({position:i}=r),r.range&&(o=r.range),r.match})&&(r.transform(t,e,i,o),(r.name===`inline attributes`||r.name===`inline nesting self-close`)&&n--)}})}});
3
+ //# sourceMappingURL=cdn.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn.umd.js","names":[],"sources":["../src/helper/constants.ts","../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.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":["/** . */\nexport const CLASS_MARKER = 46;\n/** # */\nexport const ID_MARKER = 35;\n/** space */\nexport const PAIR_SEPARATOR = 32;\n/** = */\nexport const KEY_SEPARATOR = 61;\n/** \" */\nexport const QUOTE_MARKER = 34;\n","import {\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n QUOTE_MARKER,\n} from \"./constants.js\";\nimport type { Attr } from \"./types.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nconst isAllowedKeyChar = (charCode: number): boolean =>\n !(\n (\n charCode === 9 /* \\t */ ||\n charCode === 10 /* \\n */ ||\n charCode === 12 /* \\f */ ||\n charCode === 32 /* 空格 */ ||\n charCode === 47 /* / */ ||\n charCode === 62 /* > */ ||\n charCode === 34 /* \" */ ||\n charCode === 39 /* ' */ ||\n charCode === 61\n ) /* = */\n );\n\nexport const getAttrs = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\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 marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(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 (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\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 && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport { getAttrs } from \"./getAttrs.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\nimport type { DelimiterChecker } from \"../rules/types.js\";\n\n/**\n * Get a function to check if a string matches the delimiter pattern\n * 获取一个函数来检查字符串是否匹配分隔符模式\n *\n * @param options - Delimiter configuration / 分隔符配置\n * @param where - Position for matching: start, end, or only / 匹配位置:开始、结束或仅匹配\n * @returns A function that checks if content matches the delimiter pattern / 检查内容是否匹配分隔符模式的函数\n */\nexport const createDelimiterChecker = (\n options: DelimiterConfig,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where))\n throw new Error(`Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`);\n\n // Cache frequently used values\n const left = options.left;\n const right = options.right;\n const leftLength = left.length;\n const rightLength = right.length;\n const minContentLength = leftLength + 1 + rightLength;\n\n return (content) => {\n // Quick check for minimum length requirements\n if (typeof content !== \"string\" || content.length < minContentLength) return false;\n\n let start: number;\n let end: number;\n\n if (where === \"start\") {\n // Check if content starts with left delimiter\n if (!content.startsWith(left)) return false;\n\n start = leftLength;\n end = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): 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) return currentToken;\n\n // oxlint-disable-next-line no-param-reassign\n index--;\n }\n\n /* istanbul ignore next -- @preserve */\n return null;\n};\n","/**\n * Get index item of array. Supports negative index, where -1 is last element in array.\n *\n * 获取数组中的索引项。支持负索引,其中 -1 是数组的最后一个元素。\n *\n * @param arr - Array to get item from / 要获取项的数组\n * @param index - Index of item / 项的索引\n * @returns Array item / 数组项\n */\nexport const getArrayItem = <Item>(arr: Item[], index: number): Item =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet } from \"../rules/types.js\";\nimport { getArrayItem } 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 range: [start: number, end: number] | null;\n}\n\n/**\n * Test if rule matches token stream.\n *\n * @param tokens - token stream\n * @param index - current token index\n * @param rule - rule to test\n *\n * @returns test result\n */\nexport const testRule = (tokens: Token[], index: number, rule: AttrRuleSet): TestRuleResult => {\n const testResult: TestRuleResult = {\n match: false,\n position: null,\n range: null,\n };\n const isShift = typeof rule.shift === \"number\";\n\n const tokenIndex = isShift ? index + rule.shift : rule.position;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (isShift && tokenIndex < 0) return testResult;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token) return testResult;\n\n const ruleKeys = Object.keys(rule) as (keyof typeof rule)[];\n\n const ruleKeysLength = ruleKeys.length;\n\n for (let i = 0; i < ruleKeysLength; i++) {\n const key = ruleKeys[i];\n\n if (key === \"shift\" || key === \"position\") continue;\n\n // undefined and null are treated as non-existing keys\n // oxlint-disable-next-line eqeqeq, no-undefined\n if (token[key as keyof Token] == undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => typeof childTest.position === \"number\")) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth typescript/strict-boolean-expressions\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n const ruleDetail = rule[key];\n\n // oxlint-disable-next-line typescript/switch-exhaustiveness-check\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\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 or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer KeyType) | null\n ? KeyType | TestFunction<KeyType>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项\n * 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens\n * One of shift or position must be defined\n */\nexport type AttrRuleSet = ShiftAttrRuleSet | PositionAttrRuleSet;\n\nexport interface AttrRule {\n name: string;\n tests: AttrRuleSet[];\n transform: (tokens: Token[], index: number, childIndex: number, range: DelimiterRange) => void;\n}\n\n/**\n * Define an attribute rule helper\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n *\n * @example\n * ```ts\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n * ```\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createBlockRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * end of {.block}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\n\nexport const createFenceRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n return defineAttrRule({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: createDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createHeadingRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * ## end of {#heading}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: -1,\n type: \"heading_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createInlineRules = (options: DelimiterConfig): AttrRule[] => [\n /**\n * bla `click()`{.c} ![](img.png){.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n defineAttrRule({\n name: \"inline nesting self-close\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n // oxlint-disable-next-line typescript/explicit-function-return-type\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n const targetToken = childTokens[childIndex - 1];\n const attrsEndIndex = options.right.length + range[1];\n\n // Apply attributes to the target token\n addAttrs(targetToken, token.content, range, options.allowed);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /**\n * *emphasis*{.with attrs=1}\n */\n defineAttrRule({\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: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const currentToken = childTokens[childIndex];\n const { content } = currentToken;\n const attrsEndIndex = options.right.length + range[1];\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(childTokens, childIndex - 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createListRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const allowed = options.allowed;\n\n return [\n /**\n * - item\n * {.a}\n */\n defineAttrRule({\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: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.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 defineAttrRule({\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) => 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: createDelimiterChecker(options, \"only\"),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, token.content, range, allowed);\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 defineAttrRule({\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: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const content = token.content;\n const attrStartIndex = range[0] - options.left.length;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the list item opening token\n addAttrs(tokens[index - 2], content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createSoftBreakRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\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: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Apply attributes to the opening token\n addAttrs(\n getMatchingOpeningToken(tokens, closingTokenIndex),\n token.content,\n range,\n options.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\n\nexport const createHrRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n return defineAttrRule({\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): DelimiterRange | false => {\n let pos = 0;\n let charCode;\n const markerCode = content.charCodeAt(pos++);\n\n if (\n markerCode !== 45 /** - */ &&\n markerCode !== 42 /** * */ &&\n markerCode !== 95 /** _ */\n )\n return false;\n\n let count = 1;\n\n while (pos < content.length) {\n charCode = content.charCodeAt(pos++);\n if (charCode !== markerCode) break;\n\n count++;\n }\n\n if (count < 3) return false;\n\n if (!isSpace(content.charCodeAt(pos - 1))) pos--;\n\n return createDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } 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// oxlint-disable-next-line max-lines-per-function\nexport const createTableRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const allowed = options.allowed;\n\n return [\n defineAttrRule({\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: createDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, allowed);\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 defineAttrRule({\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: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find last attribute syntax in the content\n\n // Apply attributes to the table cell token\n addAttrs(cellOpenToken, content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\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[currentIndex - 1] 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 (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\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 defineAttrRule({\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 let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\")\n tbodyOpenIndex--;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta!.columnCount!;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type { AttrRule } from \"./types.js\";\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockRule } from \"./block.js\";\nimport { createFenceRule } from \"./fence.js\";\nimport { createHeadingRule } from \"./heading.js\";\nimport { createHrRule } from \"./hr.js\";\nimport { createInlineRules } from \"./inline.js\";\nimport { createListRules } from \"./list.js\";\nimport { createSoftBreakRule } from \"./softbreak.js\";\nimport { createTableRules } from \"./table.js\";\n\nconst AVAILABLE_RULES: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"heading\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const createRules = (\n md: MarkdownIt,\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(createFenceRule(md, options));\n if (enabledRules.includes(\"inline\")) rules.push(...createInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...createTableRules(md, options));\n if (enabledRules.includes(\"list\")) rules.push(...createListRules(md, options));\n if (enabledRules.includes(\"softbreak\")) rules.push(createSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(createHrRule(md, options));\n if (enabledRules.includes(\"block\")) rules.push(createBlockRule(md, options));\n // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(createHeadingRule(md, 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 type { DelimiterRange } from \"./rules/index.js\";\nimport { createRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = createRules(md, {\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = (state) => {\n const tokens = state.tokens;\n\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 let range: DelimiterRange | null = null;\n\n // oxlint-disable-next-line no-loop-func\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position != null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\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 };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"mappings":"uRACA,ICSM,EAAoB,GACxB,EAEI,IAAa,GACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IAIN,GACX,EACA,EACA,IACW,CACX,IAAI,EAAM,GACN,EAAQ,GACR,EAAa,GACb,EAAoB,GAElB,EAAgB,EAAE,CAKxB,IAAK,IAAI,EAAQ,EAAM,GAAI,EAAQ,EAAM,GAAI,IAAS,CACpD,IAAM,EAAW,EAAI,WAAW,EAAM,CAGtC,GAAI,IAAa,IAAiB,EAAY,CAC5C,EAAa,GACb,SAIF,GAAI,IAAa,IAAgB,IAAQ,GAAI,CACvC,EAAI,WAAW,EAAQ,EAAE,GAAK,IAChC,EAAM,aACN,KAEA,EAAM,QAGR,EAAa,GACb,SAI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IAAK,QAAQ,IAAK,UAAU,EAAE,CAAE,OAAO,OAAU,EAAE,GACzD,CACH,IAAM,EAAQ,EAAY,EAAI,CAC5B,OACA,QACA,UACA,OACD,CAAC,CAsCF,EAAG,KAAK,MAAM,OAAO,UAAW,QApCH,GAAU,CACrC,IAAM,EAAS,EAAM,OAErB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAO,OAAQ,IACzC,IAAK,IAAI,EAAY,EAAG,EAAY,EAAM,OAAQ,IAAa,CAC7D,IAAM,EAAU,EAAM,GAElB,EAA0B,KAC1B,EAA+B,KAGrB,EAAQ,MAAM,MAAO,GAAS,CAC1C,IAAM,EAAS,EAAS,EAAQ,EAAO,EAAK,CAK5C,OAHI,EAAO,UAAY,OAAO,aAAe,GACzC,EAAO,QAAO,EAAQ,EAAO,OAE1B,EAAO,OACd,GAIA,EAAQ,UAAU,EAAQ,EAAO,EAAW,EAAO,EAGjD,EAAQ,OAAS,qBACjB,EAAQ,OAAS,8BAGjB,OAOyC"}
@@ -3,32 +3,32 @@ import { PluginWithOptions } from "markdown-it";
3
3
  //#region src/helper/types.d.ts
4
4
  interface DelimiterConfig {
5
5
  /**
6
- * left delimiter
7
- *
8
- * 左分隔符
9
- *
10
- * @default '{'
11
- */
6
+ * left delimiter
7
+ *
8
+ * 左分隔符
9
+ *
10
+ * @default '{'
11
+ */
12
12
  left: string;
13
13
  /**
14
- * right delimiter
15
- *
16
- * 右分隔符
17
- *
18
- * @default '}'
19
- */
14
+ * right delimiter
15
+ *
16
+ * 右分隔符
17
+ *
18
+ * @default '}'
19
+ */
20
20
  right: string;
21
21
  /**
22
- * allowed attributes
23
- *
24
- * @description An empty list means allowing all attribute
25
- *
26
- * 允许的属性
27
- *
28
- * @description 设置空数组意味着允许所有属性
29
- *
30
- * @default []
31
- */
22
+ * allowed attributes
23
+ *
24
+ * @description An empty list means allowing all attribute
25
+ *
26
+ * 允许的属性
27
+ *
28
+ * @description 设置空数组意味着允许所有属性
29
+ *
30
+ * @default []
31
+ */
32
32
  allowed: (string | RegExp)[];
33
33
  }
34
34
  //#endregion
@@ -36,12 +36,12 @@ interface DelimiterConfig {
36
36
  type MarkdownItAttrRuleName = "fence" | "inline" | "table" | "list" | "heading" | "hr" | "softbreak" | "block";
37
37
  interface MarkdownItAttrsOptions extends Partial<DelimiterConfig> {
38
38
  /**
39
- * Rules to enable
40
- *
41
- * 启用的规则
42
- *
43
- * @default "all"
44
- */
39
+ * Rules to enable
40
+ *
41
+ * 启用的规则
42
+ *
43
+ * @default "all"
44
+ */
45
45
  rule?: "all" | boolean | MarkdownItAttrRuleName[];
46
46
  }
47
47
  //#endregion
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/helper/types.ts","../src/options.ts","../src/plugin.ts"],"mappings":";;;UAEiB,eAAA;;AAAjB;;;;;;EAQE,IAAA;;;;;;;ACRF;EDiBE,KAAA;;;;ACPF;;;;;;;;EDoBE,OAAA,YAAmB,MAAA;AAAA;;;KC9BT,sBAAA;AAAA,UAUK,sBAAA,SAA+B,OAAA,CAAQ,eAAA;EDVxD;;;;;;;ECkBE,IAAA,qBAAyB,sBAAA;AAAA;;;cCRd,KAAA,EAAO,iBAAA,CAAkB,sBAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const e=e=>!(e===9||e===10||e===12||e===32||e===47||e===62||e===34||e===39||e===61),t=(t,n,r)=>{let i=``,a=``,o=!0,s=!1,c=[];for(let r=n[0];r<n[1];r++){let n=t.charCodeAt(r);if(n===61&&o){o=!1;continue}if(n===46&&i===``){t.charCodeAt(r+1)===46?(i=`css-module`,r++):i=`class`,o=!1;continue}if(n===35&&i===``){i=`id`,o=!1;continue}if(n===34&&a===``&&!s){s=!0;continue}if(n===34&&s){s=!1;continue}if(n===32&&!s){if(i===``)continue;c.push([i,a]),i=``,a=``,o=!0;continue}if(!(o&&!e(n))){if(o){i+=String.fromCharCode(n);continue}a+=String.fromCharCode(n)}}return i!==``&&c.push([i,a]),r.length>0?c.filter(([e])=>r.some(t=>t instanceof RegExp?t.test(e):t===e)):c},n=(e,n,r,i)=>{e&&t(n,r,i).forEach(([t,n])=>{switch(t){case`class`:e.attrJoin(`class`,n);break;case`css-module`:e.attrJoin(`css-module`,n);break;default:e.attrPush([t,n])}})},r=(e,t)=>{if(![`start`,`end`,`only`].includes(t))throw Error(`Invalid 'where' parameter: ${t}. Expected 'start', 'end', or 'only'.`);let n=e.left,r=e.right,i=n.length,a=r.length,o=i+1+a;return e=>{if(typeof e!=`string`||e.length<o)return!1;let s,c;if(t===`start`){if(!e.startsWith(n)||(s=i,c=e.indexOf(r,i+1),c===-1))return!1;let t=c+a;if(t<e.length&&r.includes(e.charAt(t)))return!1}else if(t===`end`){if(s=e.lastIndexOf(n),s===-1||(c=e.indexOf(r,s+i+1),s+=i,c===-1||c+a!==e.length))return!1}else{if(!e.startsWith(n)||!e.endsWith(r))return!1;s=i,c=e.length-a}let l=e.charCodeAt(s),u=c-s;return(l===46||l===35?u>=2:u>=1)?[s,c]:!1}},i=(e,t)=>{let n=e[t];if(n.type===`softbreak`)return null;if(n.nesting===0)return n;let r=n.level,i=n.type.replace(`_close`,`_open`);for(;t>=0;){let n=e[t];if(n.type===i&&n.level===r)return n;t--}return null},a=(e,t)=>t>=0?e[t]:e[e.length+t],o=(e,t,n)=>{let r={match:!1,position:null,range:null},i=typeof n.shift==`number`,s=i?t+n.shift:n.position;if(i&&s<0)return r;let c=a(e,s);if(!c)return r;let l=Object.keys(n),u=l.length;for(let e=0;e<u;e++){let t=l[e];if(t===`shift`||t===`position`)continue;if(c[t]==null)return r;if(t===`children`&&Array.isArray(n.children)){if(!c.children?.length)return r;let e=n.children,t=c.children,i,a=null;if(e.every(e=>typeof e.position==`number`)){if(i=e.every(e=>{let n=o(t,e.position,e);return n.match?(n.range&&(a=n.range),!0):!1}),i){let{position:n}=e[e.length-1];r.position=n>=0?n:t.length+n,r.range=a}}else for(let n=0;n<t.length;n++)if(i=e.every(e=>{let r=o(t,n,e);return r.match?(r.range&&(a=r.range),!0):!1}),i){r.position=n,a&&(r.range=a);break}if(i===!1)return r;continue}let i=n[t];switch(typeof i){case`boolean`:case`number`:case`string`:if(c[t]!==i)return r;break;case`function`:{let e=i(c[t]);if(!e)return r;Array.isArray(e)&&(r.range=e);break}default:throw Error(`Unknown type of pattern test (key: ${t}). Test should be of type boolean, number, string or function.`)}}return r.match=!0,r},s=e=>e,c=(e,t)=>{let a=e.utils.isSpace;return s({name:`end of block`,tests:[{shift:0,type:`inline`,children:[{position:-1,content:r(t,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(e,r,o,s)=>{let c=s[0]-t.left.length,l=e[r].children[o],{content:u}=l,d=a(u.charCodeAt(c-1)),f=r+1;for(;e[f+1]?.nesting===-1;)f++;n(i(e,f),u,s,t.allowed),l.content=u.slice(0,d?c-1:c)}})},l=(e,t)=>{let i=e.utils.isSpace;return s({name:`code-block`,tests:[{shift:0,block:!0,info:r(t,`end`)}],transform:(e,r,a,o)=>{let s=o[0]-t.left.length,c=e[r],{info:l}=c,u=i(l.charCodeAt(s-1));n(c,l,o,t.allowed),c.info=l.slice(0,u?s-1:s)}})},u=(e,t)=>{let a=e.utils.isSpace;return s({name:`end of block`,tests:[{shift:-1,type:`heading_open`},{shift:0,type:`inline`,children:[{position:-1,content:r(t,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(e,r,o,s)=>{let c=s[0]-t.left.length,l=e[r].children[o],{content:u}=l,d=a(u.charCodeAt(c-1));n(i(e,r+1),u,s,t.allowed),l.content=u.slice(0,d?c-1:c)}})},d=e=>[s({name:`inline nesting self-close`,tests:[{shift:0,type:`inline`,children:[{shift:-1,type:e=>e===`image`||e===`code_inline`},{shift:0,type:`text`,content:r(e,`start`)}]}],transform:(t,r,i,a)=>{let o=t[r].children,s=o[i],c=o[i-1],l=e.right.length+a[1];n(c,s.content,a,e.allowed),s.content.length===l?o.splice(i,1):s.content=s.content.slice(l)}}),s({name:`inline attributes`,tests:[{shift:0,type:`inline`,children:[{shift:-1,nesting:-1},{shift:0,type:`text`,content:r(e,`start`)}]}],transform:(t,r,a,o)=>{let s=t[r].children,c=s[a],{content:l}=c,u=e.right.length+o[1];n(i(s,a-1),l,o,e.allowed),c.content=l.slice(u)}})],f=(e,t)=>{let a=e.utils.isSpace,o=t.allowed;return[s({name:`list softbreak`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:r(t,`only`)}]}],transform:(e,t,r,i)=>{let a=e[t].children,s=a[r],c=t-2;for(;e[c-1]?.type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;n(e[c-1],s.content,i,o),e[t].children=a.slice(0,-2)}}),s({name:`list double softbreak`,tests:[{shift:0,type:e=>e===`bullet_list_close`||e===`ordered_list_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:r(t,`only`),children:e=>e.length===1},{shift:3,type:`paragraph_close`}],transform:(e,t,r,a)=>{let s=e[t+2];n(i(e,t),s.content,a,o),e.splice(t+1,3)}}),s({name:`list item end`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-1,type:`text`,content:r(t,`end`)}]}],transform:(e,r,i,s)=>{let c=e[r].children[i],l=c.content,u=s[0]-t.left.length,d=a(l.charCodeAt(u-1));n(e[r-2],l,s,o),c.content=l.slice(0,d?u-1:u)}})]},p=e=>s({name:`
2
+ {.a} softbreak then curly in start`,tests:[{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:r(e,`only`)}]}],transform:(t,r,a,o)=>{let s=t[r].children,c=s[a],l=r+1;for(;t[l+1]?.nesting===-1;)l++;n(i(t,l),c.content,o,e.allowed),t[r].children=s.slice(0,-2)}}),m=(e,t)=>{let i=e.utils.isSpace;return s({name:`horizontal rule`,tests:[{shift:0,type:`paragraph_open`},{shift:1,type:`inline`,children:e=>e.length===1,content:e=>{let n=0,a,o=e.charCodeAt(n++);if(o!==45&&o!==42&&o!==95)return!1;let s=1;for(;n<e.length&&(a=e.charCodeAt(n++),a===o);)s++;return s<3?!1:(i(e.charCodeAt(n-1))||n--,r(t,`end`)(e))}},{shift:2,type:`paragraph_close`}],transform:(e,r,i,a)=>{let o=e[r],{content:s}=e[r+1];o.type=`hr`,o.tag=`hr`,o.nesting=0,n(o,s,a,t.allowed),o.markup=s,e.splice(r+1,2)}})},h=(e,t)=>{let a=e.utils.isSpace,o=t.allowed;return[s({name:`table`,tests:[{shift:0,type:`table_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:r(t,`only`)}],transform:(e,t,r,a)=>{let s=e[t+2];n(i(e,t),s.content,a,o),e.splice(t+1,3)}}),s({name:`table cell attributes`,tests:[{shift:-1,type:e=>e===`td_open`||e===`th_open`},{shift:0,type:`inline`,children:[{shift:0,type:`text`,content:r(t,`end`)}]}],transform:(e,r,i,s)=>{let c=s[0]-t.left.length,l=e[r].children[i],u=e[r-1],{content:d}=l,f=a(d.charCodeAt(c-1));n(u,d,s,o),l.content=d.slice(0,f?c-1:c)}}),s({name:`table thead metadata`,tests:[{shift:0,type:`tr_close`},{shift:1,type:`thead_close`},{shift:2,type:`tbody_open`}],transform:(e,t)=>{let n=i(e,t),r=e[t-1],a=0,o=t-1;for(;o>0;){let t=e[o];if(t===n){let t=e[o-1];t.meta={...t.meta,columnCount:a};break}t.level===r.level&&t.type===r.type&&a++,o--}let s=e[t+2];s.meta={...s.meta,columnCount:a}}}),s({name:`table tbody calculate`,tests:[{shift:0,type:`tbody_close`,hidden:!1}],transform:(e,t)=>{let n=t-2;for(;n>=0&&e[n].type!==`tbody_open`;)n--;let r=e[n].meta.columnCount;if(r<2)return;let i=Array.from({length:r}).fill(0),a=[],o=n+1;for(;o<t;){let n=o,s=n+1;for(;s<t&&e[s].type!==`tr_close`;)s++;let c=[],l=n+1;for(;l<s;){let t=l+1;for(;t<s&&e[t].type!==`td_close`&&e[t].type!==`th_close`;)t++;c.push([l,t]),l=t+1}let u=0,d=0;for(;d<r;){if(i[d]>0){i[d]--,a.push(c[u]),u++,d++;continue}let t=e[c[u][0]],n=Number(t.attrGet(`colspan`))||1,o=Number(t.attrGet(`rowspan`))||1;u++;let s=0;for(let e=0;e<n;e++)if(d+e<r)if(i[d+e]===0)s++;else break;n>1&&s<n&&t.attrSet(`colspan`,String(s));for(let e=0;e<s;e++)i[d+e]=o-1;let l=s-1;if(l>0)for(let e=0;e<l;e++)a.push(c[u]),u++;d+=s}o=s+1}a.sort((e,t)=>t[0]-e[0]);for(let[t,n]of a)e.splice(t,n-t+1)}})]},g=[`fence`,`inline`,`table`,`list`,`heading`,`hr`,`softbreak`,`block`],_=(e,t)=>{let n=t.rule===!1?[]:Array.isArray(t.rule)?t.rule.filter(e=>g.includes(e)):g,r=[];return n.includes(`fence`)&&r.push(l(e,t)),n.includes(`inline`)&&r.push(...d(t)),n.includes(`table`)&&r.push(...h(e,t)),n.includes(`list`)&&r.push(...f(e,t)),n.includes(`softbreak`)&&r.push(p(t)),n.includes(`hr`)&&r.push(m(e,t)),n.includes(`block`)?r.push(c(e,t)):n.includes(`heading`)&&r.push(u(e,t)),r},v=(e,{left:t=`{`,right:n=`}`,allowed:r=[],rule:i=`all`}={})=>{let a=_(e,{left:t,right:n,allowed:r,rule:i});e.core.ruler.before(`linkify`,`attrs`,e=>{let t=e.tokens;for(let e=0;e<t.length;e++)for(let n=0;n<a.length;n++){let r=a[n],i=null,s=null;r.tests.every(n=>{let r=o(t,e,n);return r.position!=null&&({position:i}=r),r.range&&(s=r.range),r.match})&&(r.transform(t,e,i,s),(r.name===`inline attributes`||r.name===`inline nesting self-close`)&&n--)}})};export{v as attrs};
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/helper/constants.ts","../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.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":["/** . */\nexport const CLASS_MARKER = 46;\n/** # */\nexport const ID_MARKER = 35;\n/** space */\nexport const PAIR_SEPARATOR = 32;\n/** = */\nexport const KEY_SEPARATOR = 61;\n/** \" */\nexport const QUOTE_MARKER = 34;\n","import {\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n QUOTE_MARKER,\n} from \"./constants.js\";\nimport type { Attr } from \"./types.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nconst isAllowedKeyChar = (charCode: number): boolean =>\n !(\n (\n charCode === 9 /* \\t */ ||\n charCode === 10 /* \\n */ ||\n charCode === 12 /* \\f */ ||\n charCode === 32 /* 空格 */ ||\n charCode === 47 /* / */ ||\n charCode === 62 /* > */ ||\n charCode === 34 /* \" */ ||\n charCode === 39 /* ' */ ||\n charCode === 61\n ) /* = */\n );\n\nexport const getAttrs = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\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 marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(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 (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\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 && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport { getAttrs } from \"./getAttrs.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\nimport type { DelimiterChecker } from \"../rules/types.js\";\n\n/**\n * Get a function to check if a string matches the delimiter pattern\n * 获取一个函数来检查字符串是否匹配分隔符模式\n *\n * @param options - Delimiter configuration / 分隔符配置\n * @param where - Position for matching: start, end, or only / 匹配位置:开始、结束或仅匹配\n * @returns A function that checks if content matches the delimiter pattern / 检查内容是否匹配分隔符模式的函数\n */\nexport const createDelimiterChecker = (\n options: DelimiterConfig,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where))\n throw new Error(`Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`);\n\n // Cache frequently used values\n const left = options.left;\n const right = options.right;\n const leftLength = left.length;\n const rightLength = right.length;\n const minContentLength = leftLength + 1 + rightLength;\n\n return (content) => {\n // Quick check for minimum length requirements\n if (typeof content !== \"string\" || content.length < minContentLength) return false;\n\n let start: number;\n let end: number;\n\n if (where === \"start\") {\n // Check if content starts with left delimiter\n if (!content.startsWith(left)) return false;\n\n start = leftLength;\n end = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): 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) return currentToken;\n\n // oxlint-disable-next-line no-param-reassign\n index--;\n }\n\n /* istanbul ignore next -- @preserve */\n return null;\n};\n","/**\n * Get index item of array. Supports negative index, where -1 is last element in array.\n *\n * 获取数组中的索引项。支持负索引,其中 -1 是数组的最后一个元素。\n *\n * @param arr - Array to get item from / 要获取项的数组\n * @param index - Index of item / 项的索引\n * @returns Array item / 数组项\n */\nexport const getArrayItem = <Item>(arr: Item[], index: number): Item =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet } from \"../rules/types.js\";\nimport { getArrayItem } 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 range: [start: number, end: number] | null;\n}\n\n/**\n * Test if rule matches token stream.\n *\n * @param tokens - token stream\n * @param index - current token index\n * @param rule - rule to test\n *\n * @returns test result\n */\nexport const testRule = (tokens: Token[], index: number, rule: AttrRuleSet): TestRuleResult => {\n const testResult: TestRuleResult = {\n match: false,\n position: null,\n range: null,\n };\n const isShift = typeof rule.shift === \"number\";\n\n const tokenIndex = isShift ? index + rule.shift : rule.position;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (isShift && tokenIndex < 0) return testResult;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token) return testResult;\n\n const ruleKeys = Object.keys(rule) as (keyof typeof rule)[];\n\n const ruleKeysLength = ruleKeys.length;\n\n for (let i = 0; i < ruleKeysLength; i++) {\n const key = ruleKeys[i];\n\n if (key === \"shift\" || key === \"position\") continue;\n\n // undefined and null are treated as non-existing keys\n // oxlint-disable-next-line eqeqeq, no-undefined\n if (token[key as keyof Token] == undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => typeof childTest.position === \"number\")) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth typescript/strict-boolean-expressions\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n const ruleDetail = rule[key];\n\n // oxlint-disable-next-line typescript/switch-exhaustiveness-check\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\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 or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer KeyType) | null\n ? KeyType | TestFunction<KeyType>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项\n * 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens\n * One of shift or position must be defined\n */\nexport type AttrRuleSet = ShiftAttrRuleSet | PositionAttrRuleSet;\n\nexport interface AttrRule {\n name: string;\n tests: AttrRuleSet[];\n transform: (tokens: Token[], index: number, childIndex: number, range: DelimiterRange) => void;\n}\n\n/**\n * Define an attribute rule helper\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n *\n * @example\n * ```ts\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n * ```\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createBlockRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * end of {.block}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\n\nexport const createFenceRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n return defineAttrRule({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: createDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createHeadingRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * ## end of {#heading}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: -1,\n type: \"heading_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createInlineRules = (options: DelimiterConfig): AttrRule[] => [\n /**\n * bla `click()`{.c} ![](img.png){.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n defineAttrRule({\n name: \"inline nesting self-close\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n // oxlint-disable-next-line typescript/explicit-function-return-type\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n const targetToken = childTokens[childIndex - 1];\n const attrsEndIndex = options.right.length + range[1];\n\n // Apply attributes to the target token\n addAttrs(targetToken, token.content, range, options.allowed);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /**\n * *emphasis*{.with attrs=1}\n */\n defineAttrRule({\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: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const currentToken = childTokens[childIndex];\n const { content } = currentToken;\n const attrsEndIndex = options.right.length + range[1];\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(childTokens, childIndex - 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createListRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const allowed = options.allowed;\n\n return [\n /**\n * - item\n * {.a}\n */\n defineAttrRule({\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: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.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 defineAttrRule({\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) => 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: createDelimiterChecker(options, \"only\"),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, token.content, range, allowed);\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 defineAttrRule({\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: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const content = token.content;\n const attrStartIndex = range[0] - options.left.length;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the list item opening token\n addAttrs(tokens[index - 2], content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const createSoftBreakRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\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: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Apply attributes to the opening token\n addAttrs(\n getMatchingOpeningToken(tokens, closingTokenIndex),\n token.content,\n range,\n options.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\n\nexport const createHrRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n return defineAttrRule({\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): DelimiterRange | false => {\n let pos = 0;\n let charCode;\n const markerCode = content.charCodeAt(pos++);\n\n if (\n markerCode !== 45 /** - */ &&\n markerCode !== 42 /** * */ &&\n markerCode !== 95 /** _ */\n )\n return false;\n\n let count = 1;\n\n while (pos < content.length) {\n charCode = content.charCodeAt(pos++);\n if (charCode !== markerCode) break;\n\n count++;\n }\n\n if (count < 3) return false;\n\n if (!isSpace(content.charCodeAt(pos - 1))) pos--;\n\n return createDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } 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// oxlint-disable-next-line max-lines-per-function\nexport const createTableRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const allowed = options.allowed;\n\n return [\n defineAttrRule({\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: createDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, allowed);\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 defineAttrRule({\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: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find last attribute syntax in the content\n\n // Apply attributes to the table cell token\n addAttrs(cellOpenToken, content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\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[currentIndex - 1] 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 (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\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 defineAttrRule({\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 let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\")\n tbodyOpenIndex--;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta!.columnCount!;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type { AttrRule } from \"./types.js\";\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockRule } from \"./block.js\";\nimport { createFenceRule } from \"./fence.js\";\nimport { createHeadingRule } from \"./heading.js\";\nimport { createHrRule } from \"./hr.js\";\nimport { createInlineRules } from \"./inline.js\";\nimport { createListRules } from \"./list.js\";\nimport { createSoftBreakRule } from \"./softbreak.js\";\nimport { createTableRules } from \"./table.js\";\n\nconst AVAILABLE_RULES: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"heading\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const createRules = (\n md: MarkdownIt,\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(createFenceRule(md, options));\n if (enabledRules.includes(\"inline\")) rules.push(...createInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...createTableRules(md, options));\n if (enabledRules.includes(\"list\")) rules.push(...createListRules(md, options));\n if (enabledRules.includes(\"softbreak\")) rules.push(createSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(createHrRule(md, options));\n if (enabledRules.includes(\"block\")) rules.push(createBlockRule(md, options));\n // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(createHeadingRule(md, 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 type { DelimiterRange } from \"./rules/index.js\";\nimport { createRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = createRules(md, {\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = (state) => {\n const tokens = state.tokens;\n\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 let range: DelimiterRange | null = null;\n\n // oxlint-disable-next-line no-loop-func\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position != null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\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 };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"mapp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
4
  "description": "attrs plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "attrs",
@@ -23,15 +23,16 @@
23
23
  "directory": "packages/attrs"
24
24
  },
25
25
  "files": [
26
- "lib"
26
+ "dist"
27
27
  ],
28
28
  "type": "module",
29
- "browser": "./lib/browser.js",
30
- "types": "./lib/index.d.ts",
29
+ "sideEffects": false,
30
+ "unpkg": "./dist/cdn.umd.js",
31
+ "jsdelivr": "./dist/cdn.umd.js",
31
32
  "exports": {
32
33
  ".": {
33
- "type": "./lib/index.d.ts",
34
- "default": "./lib/index.js"
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
35
36
  },
36
37
  "./package.json": "./package.json"
37
38
  },
@@ -40,11 +41,10 @@
40
41
  },
41
42
  "dependencies": {
42
43
  "@types/markdown-it": "^14.1.2",
43
- "@mdit/helper": "0.22.2"
44
+ "@mdit/helper": "0.23.1"
44
45
  },
45
46
  "devDependencies": {
46
- "markdown-it": "14.1.0",
47
- "@mdit/plugin-katex": "0.24.2"
47
+ "@mdit/plugin-katex": "0.25.1"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "markdown-it": "^14.1.0"
@@ -55,10 +55,10 @@
55
55
  }
56
56
  },
57
57
  "engines": {
58
- "node": ">= 18"
58
+ "node": ">= 20"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "tsdown --config-loader unrun",
62
- "clean": "rimraf ./lib"
62
+ "clean": "rimraf ./dist"
63
63
  }
64
64
  }
package/lib/browser.js DELETED
@@ -1,3 +0,0 @@
1
- const e=e=>!(e===9||e===10||e===12||e===32||e===47||e===62||e===34||e===39||e===61),t=(t,n,r)=>{let i=``,a=``,o=!0,s=!1,c=[];for(let r=n[0];r<n[1];r++){let n=t.charCodeAt(r);if(n===61&&o){o=!1;continue}if(n===46&&i===``){t.charCodeAt(r+1)===46?(i=`css-module`,r++):i=`class`,o=!1;continue}if(n===35&&i===``){i=`id`,o=!1;continue}if(n===34&&a===``&&!s){s=!0;continue}if(n===34&&s){s=!1;continue}if(n===32&&!s){if(i===``)continue;c.push([i,a]),i=``,a=``,o=!0;continue}if(!(o&&!e(n))){if(o){i+=String.fromCharCode(n);continue}a+=String.fromCharCode(n)}}return i!==``&&c.push([i,a]),r.length>0?c.filter(([e])=>r.some(t=>t instanceof RegExp?t.test(e):t===e)):c},n=(e,n,r,i)=>{e&&t(n,r,i).forEach(([t,n])=>{switch(t){case`class`:e.attrJoin(`class`,n);break;case`css-module`:e.attrJoin(`css-module`,n);break;default:e.attrPush([t,n])}})},r=(e,t)=>{if(![`start`,`end`,`only`].includes(t))throw Error(`Invalid 'where' parameter: ${t}. Expected 'start', 'end', or 'only'.`);let n=e.left,r=e.right,i=n.length,a=r.length,o=i+1+a;return e=>{if(typeof e!=`string`||e.length<o)return!1;let s,c;if(t===`start`){if(!e.startsWith(n)||(s=i,c=e.indexOf(r,i+1),c===-1))return!1;let t=c+a;if(t<e.length&&r.includes(e.charAt(t)))return!1}else if(t===`end`){if(s=e.lastIndexOf(n),s===-1||(c=e.indexOf(r,s+i+1),s+=i,c===-1||c+a!==e.length))return!1}else{if(!e.startsWith(n)||!e.endsWith(r))return!1;s=i,c=e.length-a}let l=e.charCodeAt(s),u=c-s;return(l===46||l===35?u>=2:u>=1)?[s,c]:!1}},i=(e,t)=>{let n=e[t];if(n.type===`softbreak`)return null;if(n.nesting===0)return n;let r=n.level,i=n.type.replace(`_close`,`_open`);for(;t>=0;){let n=e[t];if(n.type===i&&n.level===r)return n;t--}return null},a=(e,t)=>t>=0?e[t]:e[e.length+t],o=(e,t,n)=>{let r={match:!1,position:null,range:null},i=n.shift!==void 0,s=i?t+n.shift:n.position;if(i&&s<0)return r;let c=a(e,s);if(!c)return r;let l=Object.keys(n),u=l.length;for(let e=0;e<u;e++){let t=l[e];if(t===`shift`||t===`position`)continue;if(c[t]===void 0)return r;if(t===`children`&&Array.isArray(n.children)){if(!c.children?.length)return r;let e=n.children,t=c.children,i,a=null;if(e.every(e=>e.position!==void 0)){if(i=e.every(e=>{let n=o(t,e.position,e);return n.match?(n.range&&(a=n.range),!0):!1}),i){let{position:n}=e[e.length-1];r.position=n>=0?n:t.length+n,r.range=a}}else for(let n=0;n<t.length;n++)if(i=e.every(e=>{let r=o(t,n,e);return r.match?(r.range&&(a=r.range),!0):!1}),i){r.position=n,a&&(r.range=a);break}if(i===!1)return r;continue}let i=n[t];switch(typeof i){case`boolean`:case`number`:case`string`:if(c[t]!==i)return r;break;case`function`:{let e=i(c[t]);if(!e)return r;Array.isArray(e)&&(r.range=e);break}default:throw Error(`Unknown type of pattern test (key: ${t}). Test should be of type boolean, number, string or function.`)}}return r.match=!0,r};function s(e){switch(e){case 9:case 32:return!0}return!1}const c=e=>e,l=e=>c({name:`end of block`,tests:[{shift:0,type:`inline`,children:[{position:-1,content:r(e,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(t,r,a,o)=>{let c=o[0]-e.left.length,l=t[r].children[a],{content:u}=l,d=s(u.charCodeAt(c-1)),f=r+1;for(;t[f+1]?.nesting===-1;)f++;n(i(t,f),u,o,e.allowed),l.content=u.slice(0,d?c-1:c)}}),u=e=>c({name:`code-block`,tests:[{shift:0,block:!0,info:r(e,`end`)}],transform:(t,r,i,a)=>{let o=a[0]-e.left.length,c=t[r],{info:l}=c,u=s(l.charCodeAt(o-1));n(c,l,a,e.allowed),c.info=l.slice(0,u?o-1:o)}}),d=e=>c({name:`end of block`,tests:[{shift:-1,type:`heading_open`},{shift:0,type:`inline`,children:[{position:-1,content:r(e,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(t,r,a,o)=>{let c=o[0]-e.left.length,l=t[r].children[a],{content:u}=l,d=s(u.charCodeAt(c-1));n(i(t,r+1),u,o,e.allowed),l.content=u.slice(0,d?c-1:c)}}),f=e=>[c({name:`inline nesting self-close`,tests:[{shift:0,type:`inline`,children:[{shift:-1,type:e=>e===`image`||e===`code_inline`},{shift:0,type:`text`,content:r(e,`start`)}]}],transform:(t,r,i,a)=>{let o=t[r].children,s=o[i],c=o[i-1],l=e.right.length+a[1];n(c,s.content,a,e.allowed),s.content.length===l?o.splice(i,1):s.content=s.content.slice(l)}}),c({name:`inline attributes`,tests:[{shift:0,type:`inline`,children:[{shift:-1,nesting:-1},{shift:0,type:`text`,content:r(e,`start`)}]}],transform:(t,r,a,o)=>{let s=t[r].children,c=s[a],{content:l}=c,u=e.right.length+o[1];n(i(s,a-1),l,o,e.allowed),c.content=l.slice(u)}})],p=e=>[c({name:`list softbreak`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:r(e,`only`)}]}],transform:(t,r,i,a)=>{let o=t[r].children,s=o[i],c=r-2;for(;t[c-1]?.type!==`ordered_list_open`&&t[c-1].type!==`bullet_list_open`;)c--;n(t[c-1],s.content,a,e.allowed),t[r].children=o.slice(0,-2)}}),c({name:`list double softbreak`,tests:[{shift:0,type:e=>e===`bullet_list_close`||e===`ordered_list_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:r(e,`only`),children:e=>e.length===1},{shift:3,type:`paragraph_close`}],transform:(t,r,a,o)=>{let s=t[r+2];n(i(t,r),s.content,o,e.allowed),t.splice(r+1,3)}}),c({name:`list item end`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-1,type:`text`,content:r(e,`end`)}]}],transform:(t,r,i,a)=>{let o=t[r].children[i],c=o.content,l=a[0]-e.left.length,u=s(c.charCodeAt(l-1));n(t[r-2],c,a,e.allowed),o.content=c.slice(0,u?l-1:l)}})],m=e=>c({name:`
2
- {.a} softbreak then curly in start`,tests:[{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:r(e,`only`)}]}],transform:(t,r,a,o)=>{let s=t[r].children,c=s[a],l=r+1;for(;t[l+1]?.nesting===-1;)l++;n(i(t,l),c.content,o,e.allowed),t[r].children=s.slice(0,-2)}}),h=e=>c({name:`horizontal rule`,tests:[{shift:0,type:`paragraph_open`},{shift:1,type:`inline`,children:e=>e.length===1,content:t=>{let n=0,i,a=t.charCodeAt(n++);if(a!==45&&a!==42&&a!==95)return!1;let o=1;for(;n<t.length&&(i=t.charCodeAt(n++),i===a);)o++;return o<3?!1:(s(t.charCodeAt(n-1))||n--,r(e,`end`)(t))}},{shift:2,type:`paragraph_close`}],transform:(t,r,i,a)=>{let o=t[r],{content:s}=t[r+1];o.type=`hr`,o.tag=`hr`,o.nesting=0,n(o,s,a,e.allowed),o.markup=s,t.splice(r+1,2)}}),g=e=>[c({name:`table`,tests:[{shift:0,type:`table_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:r(e,`only`)}],transform:(t,r,a,o)=>{let s=t[r+2];n(i(t,r),s.content,o,e.allowed),t.splice(r+1,3)}}),c({name:`table cell attributes`,tests:[{shift:-1,type:e=>e===`td_open`||e===`th_open`},{shift:0,type:`inline`,children:[{shift:0,type:`text`,content:r(e,`end`)}]}],transform:(t,r,i,a)=>{let o=a[0]-e.left.length,c=t[r].children[i],l=t[r-1],{content:u}=c,d=s(u.charCodeAt(o-1));n(l,u,a,e.allowed),c.content=u.slice(0,d?o-1:o)}}),c({name:`table thead metadata`,tests:[{shift:0,type:`tr_close`},{shift:1,type:`thead_close`},{shift:2,type:`tbody_open`}],transform:(e,t)=>{let n=i(e,t),r=e[t-1],a=0,o=t-1;for(;o>0;){let t=e[o];if(t===n){let t=e[o-1];t.meta={...t.meta,columnCount:a};break}t.level===r.level&&t.type===r.type&&a++,o--}let s=e[t+2];s.meta={...s.meta,columnCount:a}}}),c({name:`table tbody calculate`,tests:[{shift:0,type:`tbody_close`,hidden:!1}],transform:(e,t)=>{let n=t-2;for(;n>=0&&e[n].type!==`tbody_open`;)n--;let r=e[n].meta?.columnCount??0;if(r<2)return;let i=Array.from({length:r}).fill(0),a=[],o=n+1;for(;o<t;){let n=o,s=n+1;for(;s<t&&e[s].type!==`tr_close`;)s++;let c=[],l=n+1;for(;l<s;){let t=l+1;for(;t<s&&e[t].type!==`td_close`&&e[t].type!==`th_close`;)t++;c.push([l,t]),l=t+1}let u=0,d=0;for(;d<r;){if(i[d]>0){i[d]--,a.push(c[u]),u++,d++;continue}let t=e[c[u][0]],n=Number(t.attrGet(`colspan`))||1,o=Number(t.attrGet(`rowspan`))||1;u++;let s=0;for(let e=0;e<n;e++)if(d+e<r)if(i[d+e]===0)s++;else break;n>1&&s<n&&t.attrSet(`colspan`,String(s));for(let e=0;e<s;e++)d+e<r&&(i[d+e]=o-1);let l=s-1;if(l>0)for(let e=0;e<l;e++)a.push(c[u]),u++;d+=s}o=s+1}a.sort((e,t)=>t[0]-e[0]);for(let[t,n]of a)e.splice(t,n-t+1)}})],_=[`fence`,`inline`,`table`,`list`,`heading`,`hr`,`softbreak`,`block`],v=e=>{let t=e.rule===!1?[]:Array.isArray(e.rule)?e.rule.filter(e=>_.includes(e)):_,n=[];return t.includes(`fence`)&&n.push(u(e)),t.includes(`inline`)&&n.push(...f(e)),t.includes(`table`)&&n.push(...g(e)),t.includes(`list`)&&n.push(...p(e)),t.includes(`softbreak`)&&n.push(m(e)),t.includes(`hr`)&&n.push(h(e)),t.includes(`block`)?n.push(l(e)):t.includes(`heading`)&&n.push(d(e)),n},y=(e,{left:t=`{`,right:n=`}`,allowed:r=[],rule:i=`all`}={})=>{let a=v({left:t,right:n,allowed:r,rule:i});e.core.ruler.before(`linkify`,`attrs`,e=>{let t=e.tokens;for(let e=0;e<t.length;e++)for(let n=0;n<a.length;n++){let r=a[n],i=null,s=null;r.tests.every(n=>{let r=o(t,e,n);return r.position!==null&&({position:i}=r),r.range&&(s=r.range),r.match})&&(r.transform(t,e,i,s),(r.name===`inline attributes`||r.name===`inline nesting self-close`)&&n--)}})};export{y as attrs};
3
- //# sourceMappingURL=browser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.js","names":[],"sources":["../src/helper/constants.ts","../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../../../node_modules/.pnpm/markdown-it@14.1.0/node_modules/markdown-it/lib/common/utils.mjs","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.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":["/** . */\nexport const CLASS_MARKER = 46;\n/** # */\nexport const ID_MARKER = 35;\n/** space */\nexport const PAIR_SEPARATOR = 32;\n/** = */\nexport const KEY_SEPARATOR = 61;\n/** \" */\nexport const QUOTE_MARKER = 34;\n","import {\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n QUOTE_MARKER,\n} from \"./constants.js\";\nimport type { Attr } from \"./types.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nconst isAllowedKeyChar = (charCode: number): boolean =>\n !(\n (\n charCode === 9 /* \\t */ ||\n charCode === 10 /* \\n */ ||\n charCode === 12 /* \\f */ ||\n charCode === 32 /* 空格 */ ||\n charCode === 47 /* / */ ||\n charCode === 62 /* > */ ||\n charCode === 34 /* \" */ ||\n charCode === 39 /* ' */ ||\n charCode === 61\n ) /* = */\n );\n\nexport const getAttrs = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\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 marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(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 (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\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 && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport { getAttrs } from \"./getAttrs.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\nimport type { DelimiterChecker } from \"../rules/types.js\";\n\n/**\n * Get a function to check if a string matches the delimiter pattern\n * 获取一个函数来检查字符串是否匹配分隔符模式\n *\n * @param options - Delimiter configuration / 分隔符配置\n * @param where - Position for matching: start, end, or only / 匹配位置:开始、结束或仅匹配\n * @returns A function that checks if content matches the delimiter pattern / 检查内容是否匹配分隔符模式的函数\n */\nexport const getDelimiterChecker = (\n options: DelimiterConfig,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where))\n throw new Error(`Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`);\n\n // Cache frequently used values\n const left = options.left;\n const right = options.right;\n const leftLength = left.length;\n const rightLength = right.length;\n const minContentLength = leftLength + 1 + rightLength;\n\n return (content) => {\n // Quick check for minimum length requirements\n if (typeof content !== \"string\" || content.length < minContentLength) return false;\n\n let start: number;\n let end: number;\n\n if (where === \"start\") {\n // Check if content starts with left delimiter\n if (!content.startsWith(left)) return false;\n\n start = leftLength;\n end = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): 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) return currentToken;\n\n index--;\n }\n\n /* istanbul ignore next -- @preserve */\n return null;\n};\n","/**\n * Get index item of array. Supports negative index, where -1 is last element in array.\n *\n * 获取数组中的索引项。支持负索引,其中 -1 是数组的最后一个元素。\n *\n * @param arr - Array to get item from / 要获取项的数组\n * @param index - Index of item / 项的索引\n * @returns Array item / 数组项\n */\nexport const getArrayItem = <T>(arr: T[], index: number): T =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet } from \"../rules/types.js\";\nimport { getArrayItem } 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 range: [start: number, end: number] | null;\n}\n\n/**\n * Test if rule matches token stream.\n *\n * @param tokens - token stream\n * @param index - current token index\n * @param rule - rule to test\n *\n * @returns test result\n */\nexport const testRule = (tokens: Token[], index: number, rule: AttrRuleSet): TestRuleResult => {\n const testResult: TestRuleResult = {\n match: false,\n position: null,\n range: null,\n };\n const isShift = rule.shift !== undefined;\n\n const tokenIndex = isShift ? index + rule.shift : rule.position;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (isShift && tokenIndex < 0) return testResult;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (!token) return testResult;\n\n const ruleKeys = Object.keys(rule) as (keyof typeof rule)[];\n\n const ruleKeysLength = ruleKeys.length;\n\n for (let i = 0; i < ruleKeysLength; i++) {\n const key = ruleKeys[i];\n\n if (key === \"shift\" || key === \"position\") continue;\n\n if (token[key as keyof Token] === undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => childTest.position !== undefined)) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth typescript/no-unnecessary-condition\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\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 testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\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 or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","// Utilities\n//\n\nimport * as mdurl from 'mdurl'\nimport * as ucmicro from 'uc.micro'\nimport { decodeHTML } from 'entities'\n\nfunction _class (obj) { return Object.prototype.toString.call(obj) }\n\nfunction isString (obj) { return _class(obj) === '[object String]' }\n\nconst _hasOwnProperty = Object.prototype.hasOwnProperty\n\nfunction has (object, key) {\n return _hasOwnProperty.call(object, key)\n}\n\n// Merge objects\n//\nfunction assign (obj /* from1, from2, from3, ... */) {\n const sources = Array.prototype.slice.call(arguments, 1)\n\n sources.forEach(function (source) {\n if (!source) { return }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be object')\n }\n\n Object.keys(source).forEach(function (key) {\n obj[key] = source[key]\n })\n })\n\n return obj\n}\n\n// Remove element from array and put another array at those position.\n// Useful for some operations with tokens\nfunction arrayReplaceAt (src, pos, newElements) {\n return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1))\n}\n\nfunction isValidEntityCode (c) {\n /* eslint no-bitwise:0 */\n // broken sequence\n if (c >= 0xD800 && c <= 0xDFFF) { return false }\n // never used\n if (c >= 0xFDD0 && c <= 0xFDEF) { return false }\n if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false }\n // control codes\n if (c >= 0x00 && c <= 0x08) { return false }\n if (c === 0x0B) { return false }\n if (c >= 0x0E && c <= 0x1F) { return false }\n if (c >= 0x7F && c <= 0x9F) { return false }\n // out of range\n if (c > 0x10FFFF) { return false }\n return true\n}\n\nfunction fromCodePoint (c) {\n /* eslint no-bitwise:0 */\n if (c > 0xffff) {\n c -= 0x10000\n const surrogate1 = 0xd800 + (c >> 10)\n const surrogate2 = 0xdc00 + (c & 0x3ff)\n\n return String.fromCharCode(surrogate1, surrogate2)\n }\n return String.fromCharCode(c)\n}\n\nconst UNESCAPE_MD_RE = /\\\\([!\"#$%&'()*+,\\-./:;<=>?@[\\\\\\]^_`{|}~])/g\nconst ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi\nconst UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi')\n\nconst DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i\n\nfunction replaceEntityPattern (match, name) {\n if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {\n const code = name[1].toLowerCase() === 'x'\n ? parseInt(name.slice(2), 16)\n : parseInt(name.slice(1), 10)\n\n if (isValidEntityCode(code)) {\n return fromCodePoint(code)\n }\n\n return match\n }\n\n const decoded = decodeHTML(match)\n if (decoded !== match) {\n return decoded\n }\n\n return match\n}\n\n/* function replaceEntities(str) {\n if (str.indexOf('&') < 0) { return str; }\n\n return str.replace(ENTITY_RE, replaceEntityPattern);\n} */\n\nfunction unescapeMd (str) {\n if (str.indexOf('\\\\') < 0) { return str }\n return str.replace(UNESCAPE_MD_RE, '$1')\n}\n\nfunction unescapeAll (str) {\n if (str.indexOf('\\\\') < 0 && str.indexOf('&') < 0) { return str }\n\n return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {\n if (escaped) { return escaped }\n return replaceEntityPattern(match, entity)\n })\n}\n\nconst HTML_ESCAPE_TEST_RE = /[&<>\"]/\nconst HTML_ESCAPE_REPLACE_RE = /[&<>\"]/g\nconst HTML_REPLACEMENTS = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;'\n}\n\nfunction replaceUnsafeChar (ch) {\n return HTML_REPLACEMENTS[ch]\n}\n\nfunction escapeHtml (str) {\n if (HTML_ESCAPE_TEST_RE.test(str)) {\n return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar)\n }\n return str\n}\n\nconst REGEXP_ESCAPE_RE = /[.?*+^$[\\]\\\\(){}|-]/g\n\nfunction escapeRE (str) {\n return str.replace(REGEXP_ESCAPE_RE, '\\\\$&')\n}\n\nfunction isSpace (code) {\n switch (code) {\n case 0x09:\n case 0x20:\n return true\n }\n return false\n}\n\n// Zs (unicode class) || [\\t\\f\\v\\r\\n]\nfunction isWhiteSpace (code) {\n if (code >= 0x2000 && code <= 0x200A) { return true }\n switch (code) {\n case 0x09: // \\t\n case 0x0A: // \\n\n case 0x0B: // \\v\n case 0x0C: // \\f\n case 0x0D: // \\r\n case 0x20:\n case 0xA0:\n case 0x1680:\n case 0x202F:\n case 0x205F:\n case 0x3000:\n return true\n }\n return false\n}\n\n/* eslint-disable max-len */\n\n// Currently without astral characters support.\nfunction isPunctChar (ch) {\n return ucmicro.P.test(ch) || ucmicro.S.test(ch)\n}\n\n// Markdown ASCII punctuation characters.\n//\n// !, \", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \\, ], ^, _, `, {, |, }, or ~\n// http://spec.commonmark.org/0.15/#ascii-punctuation-character\n//\n// Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.\n//\nfunction isMdAsciiPunct (ch) {\n switch (ch) {\n case 0x21/* ! */:\n case 0x22/* \" */:\n case 0x23/* # */:\n case 0x24/* $ */:\n case 0x25/* % */:\n case 0x26/* & */:\n case 0x27/* ' */:\n case 0x28/* ( */:\n case 0x29/* ) */:\n case 0x2A/* * */:\n case 0x2B/* + */:\n case 0x2C/* , */:\n case 0x2D/* - */:\n case 0x2E/* . */:\n case 0x2F/* / */:\n case 0x3A/* : */:\n case 0x3B/* ; */:\n case 0x3C/* < */:\n case 0x3D/* = */:\n case 0x3E/* > */:\n case 0x3F/* ? */:\n case 0x40/* @ */:\n case 0x5B/* [ */:\n case 0x5C/* \\ */:\n case 0x5D/* ] */:\n case 0x5E/* ^ */:\n case 0x5F/* _ */:\n case 0x60/* ` */:\n case 0x7B/* { */:\n case 0x7C/* | */:\n case 0x7D/* } */:\n case 0x7E/* ~ */:\n return true\n default:\n return false\n }\n}\n\n// Hepler to unify [reference labels].\n//\nfunction normalizeReference (str) {\n // Trim and collapse whitespace\n //\n str = str.trim().replace(/\\s+/g, ' ')\n\n // In node v10 'ẞ'.toLowerCase() === 'Ṿ', which is presumed to be a bug\n // fixed in v12 (couldn't find any details).\n //\n // So treat this one as a special case\n // (remove this when node v10 is no longer supported).\n //\n if ('ẞ'.toLowerCase() === 'Ṿ') {\n str = str.replace(/ẞ/g, 'ß')\n }\n\n // .toLowerCase().toUpperCase() should get rid of all differences\n // between letter variants.\n //\n // Simple .toLowerCase() doesn't normalize 125 code points correctly,\n // and .toUpperCase doesn't normalize 6 of them (list of exceptions:\n // İ, ϴ, ẞ, Ω, K, Å - those are already uppercased, but have differently\n // uppercased versions).\n //\n // Here's an example showing how it happens. Lets take greek letter omega:\n // uppercase U+0398 (Θ), U+03f4 (ϴ) and lowercase U+03b8 (θ), U+03d1 (ϑ)\n //\n // Unicode entries:\n // 0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8;\n // 03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398\n // 03D1;GREEK THETA SYMBOL;Ll;0;L;<compat> 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398\n // 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L;<compat> 0398;;;;N;;;;03B8;\n //\n // Case-insensitive comparison should treat all of them as equivalent.\n //\n // But .toLowerCase() doesn't change ϑ (it's already lowercase),\n // and .toUpperCase() doesn't change ϴ (already uppercase).\n //\n // Applying first lower then upper case normalizes any character:\n // '\\u0398\\u03f4\\u03b8\\u03d1'.toLowerCase().toUpperCase() === '\\u0398\\u0398\\u0398\\u0398'\n //\n // Note: this is equivalent to unicode case folding; unicode normalization\n // is a different step that is not required here.\n //\n // Final result should be uppercased, because it's later stored in an object\n // (this avoid a conflict with Object.prototype members,\n // most notably, `__proto__`)\n //\n return str.toLowerCase().toUpperCase()\n}\n\n// Re-export libraries commonly used in both markdown-it and its plugins,\n// so plugins won't have to depend on them explicitly, which reduces their\n// bundled size (e.g. a browser build).\n//\nconst lib = { mdurl, ucmicro }\n\nexport {\n lib,\n assign,\n isString,\n has,\n unescapeMd,\n unescapeAll,\n isValidEntityCode,\n fromCodePoint,\n escapeHtml,\n arrayReplaceAt,\n isSpace,\n isWhiteSpace,\n isMdAsciiPunct,\n isPunctChar,\n escapeRE,\n normalizeReference\n}\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer T) | null\n ? T | TestFunction<T>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项\n * 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens\n * One of shift or position must be defined\n */\nexport type AttrRuleSet = ShiftAttrRuleSet | PositionAttrRuleSet;\n\nexport interface AttrRule {\n name: string;\n tests: AttrRuleSet[];\n transform: (tokens: Token[], index: number, childIndex: number, range: DelimiterRange) => void;\n}\n\n/**\n * Define an attribute rule helper\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n *\n * @example\n * ```ts\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n * ```\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getBlockRule = (options: DelimiterConfig): AttrRule =>\n /**\n * end of {.block}\n */\n defineAttrRule({\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, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker } from \"../helper/index.js\";\n\nexport const getFenceRule = (options: DelimiterConfig): AttrRule =>\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n defineAttrRule({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: getDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getHeadingRule = (options: DelimiterConfig): AttrRule =>\n /**\n * ## end of {#heading}\n */\n defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: -1,\n type: \"heading_open\",\n },\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, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getInlineRules = (options: DelimiterConfig): AttrRule[] => [\n /**\n * bla `click()`{.c} ![](img.png){.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n const targetToken = childTokens[childIndex - 1];\n const attrsEndIndex = options.right.length + range[1];\n\n // Apply attributes to the target token\n addAttrs(targetToken, token.content, range, options.allowed);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /**\n * *emphasis*{.with attrs=1}\n */\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const currentToken = childTokens[childIndex];\n const { content } = currentToken;\n const attrsEndIndex = options.right.length + range[1];\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(childTokens, childIndex - 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getListRules = (options: DelimiterConfig): AttrRule[] => [\n /**\n * - item\n * {.a}\n */\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, options.allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.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 defineAttrRule({\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) => 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, _, range): void => {\n const token = tokens[index + 2];\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, token.content, range, options.allowed);\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 defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const content = token.content;\n const attrStartIndex = range[0] - options.left.length;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the list item opening token\n addAttrs(tokens[index - 2], content, range, options.allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n];\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getSoftBreakRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Apply attributes to the opening token\n addAttrs(\n getMatchingOpeningToken(tokens, closingTokenIndex),\n token.content,\n range,\n options.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker } from \"../helper/index.js\";\n\nexport const getHrRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\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): DelimiterRange | false => {\n let pos = 0;\n let charCode;\n const markerCode = content.charCodeAt(pos++);\n\n if (\n markerCode !== 45 /** - */ &&\n markerCode !== 42 /** * */ &&\n markerCode !== 95 /** _ */\n )\n return false;\n\n let count = 1;\n\n while (pos < content.length) {\n charCode = content.charCodeAt(pos++);\n if (charCode !== markerCode) break;\n\n count++;\n }\n\n if (count < 3) return false;\n\n if (!isSpace(content.charCodeAt(pos - 1))) pos--;\n\n return getDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } 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// oxlint-disable-next-line max-lines-per-function\nexport const getTableRules = (options: DelimiterConfig): AttrRule[] => [\n defineAttrRule({\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, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, options.allowed);\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 defineAttrRule({\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, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find last attribute syntax in the content\n\n // Apply attributes to the table cell token\n addAttrs(cellOpenToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\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[currentIndex - 1] 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 (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\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 defineAttrRule({\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 let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\") tbodyOpenIndex--;\n\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta?.columnCount ?? 0;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++) {\n if (colIndex + i < columnCount)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n }\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n];\n","import type { AttrRule } from \"./types.js\";\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { getBlockRule } from \"./block.js\";\nimport { getFenceRule } from \"./fence.js\";\nimport { getHeadingRule } from \"./heading.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 \"heading\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const getRules = (options: Required<MarkdownItAttrsOptions>): 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 // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(getHeadingRule(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 type { DelimiterRange } from \"./rules/index.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 = (state) => {\n const tokens = state.tokens;\n\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 let range: DelimiterRange | null = null;\n\n // oxlint-disable-next-line no-loop-func\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position !== null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\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 };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"x_google_ignoreList":[7],"mappings":"AACA,MCSM,EAAoB,GACxB,EAEI,IAAa,GACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IAIN,GACX,EACA,EACA,IACW,CACX,IAAI,EAAM,GACN,EAAQ,GACR,EAAa,GACb,EAAoB,GAElB,EAAgB,EAAE,CAKxB,IAAK,IAAI,EAAQ,EAA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I,GACX,EACA,CAAE,OAAO,IAAK,QAAQ,IAAK,UAAU,EAAE,CAAE,OAAO,OAAU,EAAE,GACzD,CACH,IAAM,EAAQ,EAAS,CACrB,OACA,QACA,UACA,OACD,CAAC,CAsCF,EAAG,KAAK,MAAM,OAAO,UAAW,QApCH,GAAU,CACrC,IAAM,EAAS,EAAM,OAErB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAO,OAAQ,IACzC,IAAK,IAAI,EAAY,EAAG,EAAY,EAAM,OAAQ,IAAa,CAC7D,IAAM,EAAU,EAAM,GAElB,EAA0B,KAC1B,EAA+B,KAGrB,EAAQ,MAAM,MAAO,GAAS,CAC1C,IAAM,EAAS,EAAS,EAAQ,EAAO,EAAK,CAK5C,OAHI,EAAO,WAAa,OAAO,aAAe,GAC1C,EAAO,QAAO,EAAQ,EAAO,OAE1B,EAAO,OACd,GAIA,EAAQ,UAAU,EAAQ,EAAO,EAAW,EAAO,EAGjD,EAAQ,OAAS,qBACjB,EAAQ,OAAS,8BAGjB,OAOyC"}
package/lib/index.js DELETED
@@ -1,3 +0,0 @@
1
- import{isSpace as e}from"markdown-it/lib/common/utils.mjs";const t=e=>!(e===9||e===10||e===12||e===32||e===47||e===62||e===34||e===39||e===61),n=(e,n,r)=>{let i=``,a=``,o=!0,s=!1,c=[];for(let r=n[0];r<n[1];r++){let n=e.charCodeAt(r);if(n===61&&o){o=!1;continue}if(n===46&&i===``){e.charCodeAt(r+1)===46?(i=`css-module`,r++):i=`class`,o=!1;continue}if(n===35&&i===``){i=`id`,o=!1;continue}if(n===34&&a===``&&!s){s=!0;continue}if(n===34&&s){s=!1;continue}if(n===32&&!s){if(i===``)continue;c.push([i,a]),i=``,a=``,o=!0;continue}if(!(o&&!t(n))){if(o){i+=String.fromCharCode(n);continue}a+=String.fromCharCode(n)}}return i!==``&&c.push([i,a]),r.length>0?c.filter(([e])=>r.some(t=>t instanceof RegExp?t.test(e):t===e)):c},r=(e,t,r,i)=>{e&&n(t,r,i).forEach(([t,n])=>{switch(t){case`class`:e.attrJoin(`class`,n);break;case`css-module`:e.attrJoin(`css-module`,n);break;default:e.attrPush([t,n])}})},i=(e,t)=>{if(![`start`,`end`,`only`].includes(t))throw Error(`Invalid 'where' parameter: ${t}. Expected 'start', 'end', or 'only'.`);let n=e.left,r=e.right,i=n.length,a=r.length,o=i+1+a;return e=>{if(typeof e!=`string`||e.length<o)return!1;let s,c;if(t===`start`){if(!e.startsWith(n)||(s=i,c=e.indexOf(r,i+1),c===-1))return!1;let t=c+a;if(t<e.length&&r.includes(e.charAt(t)))return!1}else if(t===`end`){if(s=e.lastIndexOf(n),s===-1||(c=e.indexOf(r,s+i+1),s+=i,c===-1||c+a!==e.length))return!1}else{if(!e.startsWith(n)||!e.endsWith(r))return!1;s=i,c=e.length-a}let l=e.charCodeAt(s),u=c-s;return(l===46||l===35?u>=2:u>=1)?[s,c]:!1}},a=(e,t)=>{let n=e[t];if(n.type===`softbreak`)return null;if(n.nesting===0)return n;let r=n.level,i=n.type.replace(`_close`,`_open`);for(;t>=0;){let n=e[t];if(n.type===i&&n.level===r)return n;t--}return null},o=(e,t)=>t>=0?e[t]:e[e.length+t],s=(e,t,n)=>{let r={match:!1,position:null,range:null},i=n.shift!==void 0,a=i?t+n.shift:n.position;if(i&&a<0)return r;let c=o(e,a);if(!c)return r;let l=Object.keys(n),u=l.length;for(let e=0;e<u;e++){let t=l[e];if(t===`shift`||t===`position`)continue;if(c[t]===void 0)return r;if(t===`children`&&Array.isArray(n.children)){if(!c.children?.length)return r;let e=n.children,t=c.children,i,a=null;if(e.every(e=>e.position!==void 0)){if(i=e.every(e=>{let n=s(t,e.position,e);return n.match?(n.range&&(a=n.range),!0):!1}),i){let{position:n}=e[e.length-1];r.position=n>=0?n:t.length+n,r.range=a}}else for(let n=0;n<t.length;n++)if(i=e.every(e=>{let r=s(t,n,e);return r.match?(r.range&&(a=r.range),!0):!1}),i){r.position=n,a&&(r.range=a);break}if(i===!1)return r;continue}let i=n[t];switch(typeof i){case`boolean`:case`number`:case`string`:if(c[t]!==i)return r;break;case`function`:{let e=i(c[t]);if(!e)return r;Array.isArray(e)&&(r.range=e);break}default:throw Error(`Unknown type of pattern test (key: ${t}). Test should be of type boolean, number, string or function.`)}}return r.match=!0,r},c=e=>e,l=t=>c({name:`end of block`,tests:[{shift:0,type:`inline`,children:[{position:-1,content:i(t,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(n,i,o,s)=>{let c=s[0]-t.left.length,l=n[i].children[o],{content:u}=l,d=e(u.charCodeAt(c-1)),f=i+1;for(;n[f+1]?.nesting===-1;)f++;r(a(n,f),u,s,t.allowed),l.content=u.slice(0,d?c-1:c)}}),u=t=>c({name:`code-block`,tests:[{shift:0,block:!0,info:i(t,`end`)}],transform:(n,i,a,o)=>{let s=o[0]-t.left.length,c=n[i],{info:l}=c,u=e(l.charCodeAt(s-1));r(c,l,o,t.allowed),c.info=l.slice(0,u?s-1:s)}}),d=t=>c({name:`end of block`,tests:[{shift:-1,type:`heading_open`},{shift:0,type:`inline`,children:[{position:-1,content:i(t,`end`),type:e=>e!==`code_inline`&&e!==`math_inline`}]}],transform:(n,i,o,s)=>{let c=s[0]-t.left.length,l=n[i].children[o],{content:u}=l,d=e(u.charCodeAt(c-1));r(a(n,i+1),u,s,t.allowed),l.content=u.slice(0,d?c-1:c)}}),f=e=>[c({name:`inline nesting self-close`,tests:[{shift:0,type:`inline`,children:[{shift:-1,type:e=>e===`image`||e===`code_inline`},{shift:0,type:`text`,content:i(e,`start`)}]}],transform:(t,n,i,a)=>{let o=t[n].children,s=o[i],c=o[i-1],l=e.right.length+a[1];r(c,s.content,a,e.allowed),s.content.length===l?o.splice(i,1):s.content=s.content.slice(l)}}),c({name:`inline attributes`,tests:[{shift:0,type:`inline`,children:[{shift:-1,nesting:-1},{shift:0,type:`text`,content:i(e,`start`)}]}],transform:(t,n,i,o)=>{let s=t[n].children,c=s[i],{content:l}=c,u=e.right.length+o[1];r(a(s,i-1),l,o,e.allowed),c.content=l.slice(u)}})],p=t=>[c({name:`list softbreak`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:i(t,`only`)}]}],transform:(e,n,i,a)=>{let o=e[n].children,s=o[i],c=n-2;for(;e[c-1]?.type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;r(e[c-1],s.content,a,t.allowed),e[n].children=o.slice(0,-2)}}),c({name:`list double softbreak`,tests:[{shift:0,type:e=>e===`bullet_list_close`||e===`ordered_list_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:i(t,`only`),children:e=>e.length===1},{shift:3,type:`paragraph_close`}],transform:(e,n,i,o)=>{let s=e[n+2];r(a(e,n),s.content,o,t.allowed),e.splice(n+1,3)}}),c({name:`list item end`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-1,type:`text`,content:i(t,`end`)}]}],transform:(n,i,a,o)=>{let s=n[i].children[a],c=s.content,l=o[0]-t.left.length,u=e(c.charCodeAt(l-1));r(n[i-2],c,o,t.allowed),s.content=c.slice(0,u?l-1:l)}})],m=e=>c({name:`
2
- {.a} softbreak then curly in start`,tests:[{shift:0,type:`inline`,children:[{position:-2,type:`softbreak`},{position:-1,type:`text`,content:i(e,`only`)}]}],transform:(t,n,i,o)=>{let s=t[n].children,c=s[i],l=n+1;for(;t[l+1]?.nesting===-1;)l++;r(a(t,l),c.content,o,e.allowed),t[n].children=s.slice(0,-2)}}),h=t=>c({name:`horizontal rule`,tests:[{shift:0,type:`paragraph_open`},{shift:1,type:`inline`,children:e=>e.length===1,content:n=>{let r=0,a,o=n.charCodeAt(r++);if(o!==45&&o!==42&&o!==95)return!1;let s=1;for(;r<n.length&&(a=n.charCodeAt(r++),a===o);)s++;return s<3?!1:(e(n.charCodeAt(r-1))||r--,i(t,`end`)(n))}},{shift:2,type:`paragraph_close`}],transform:(e,n,i,a)=>{let o=e[n],{content:s}=e[n+1];o.type=`hr`,o.tag=`hr`,o.nesting=0,r(o,s,a,t.allowed),o.markup=s,e.splice(n+1,2)}}),g=t=>[c({name:`table`,tests:[{shift:0,type:`table_close`},{shift:1,type:`paragraph_open`},{shift:2,type:`inline`,content:i(t,`only`)}],transform:(e,n,i,o)=>{let s=e[n+2];r(a(e,n),s.content,o,t.allowed),e.splice(n+1,3)}}),c({name:`table cell attributes`,tests:[{shift:-1,type:e=>e===`td_open`||e===`th_open`},{shift:0,type:`inline`,children:[{shift:0,type:`text`,content:i(t,`end`)}]}],transform:(n,i,a,o)=>{let s=o[0]-t.left.length,c=n[i].children[a],l=n[i-1],{content:u}=c,d=e(u.charCodeAt(s-1));r(l,u,o,t.allowed),c.content=u.slice(0,d?s-1:s)}}),c({name:`table thead metadata`,tests:[{shift:0,type:`tr_close`},{shift:1,type:`thead_close`},{shift:2,type:`tbody_open`}],transform:(e,t)=>{let n=a(e,t),r=e[t-1],i=0,o=t-1;for(;o>0;){let t=e[o];if(t===n){let t=e[o-1];t.meta={...t.meta,columnCount:i};break}t.level===r.level&&t.type===r.type&&i++,o--}let s=e[t+2];s.meta={...s.meta,columnCount:i}}}),c({name:`table tbody calculate`,tests:[{shift:0,type:`tbody_close`,hidden:!1}],transform:(e,t)=>{let n=t-2;for(;n>=0&&e[n].type!==`tbody_open`;)n--;let r=e[n].meta?.columnCount??0;if(r<2)return;let i=Array.from({length:r}).fill(0),a=[],o=n+1;for(;o<t;){let n=o,s=n+1;for(;s<t&&e[s].type!==`tr_close`;)s++;let c=[],l=n+1;for(;l<s;){let t=l+1;for(;t<s&&e[t].type!==`td_close`&&e[t].type!==`th_close`;)t++;c.push([l,t]),l=t+1}let u=0,d=0;for(;d<r;){if(i[d]>0){i[d]--,a.push(c[u]),u++,d++;continue}let t=e[c[u][0]],n=Number(t.attrGet(`colspan`))||1,o=Number(t.attrGet(`rowspan`))||1;u++;let s=0;for(let e=0;e<n;e++)if(d+e<r)if(i[d+e]===0)s++;else break;n>1&&s<n&&t.attrSet(`colspan`,String(s));for(let e=0;e<s;e++)d+e<r&&(i[d+e]=o-1);let l=s-1;if(l>0)for(let e=0;e<l;e++)a.push(c[u]),u++;d+=s}o=s+1}a.sort((e,t)=>t[0]-e[0]);for(let[t,n]of a)e.splice(t,n-t+1)}})],_=[`fence`,`inline`,`table`,`list`,`heading`,`hr`,`softbreak`,`block`],v=e=>{let t=e.rule===!1?[]:Array.isArray(e.rule)?e.rule.filter(e=>_.includes(e)):_,n=[];return t.includes(`fence`)&&n.push(u(e)),t.includes(`inline`)&&n.push(...f(e)),t.includes(`table`)&&n.push(...g(e)),t.includes(`list`)&&n.push(...p(e)),t.includes(`softbreak`)&&n.push(m(e)),t.includes(`hr`)&&n.push(h(e)),t.includes(`block`)?n.push(l(e)):t.includes(`heading`)&&n.push(d(e)),n},y=(e,{left:t=`{`,right:n=`}`,allowed:r=[],rule:i=`all`}={})=>{let a=v({left:t,right:n,allowed:r,rule:i});e.core.ruler.before(`linkify`,`attrs`,e=>{let t=e.tokens;for(let e=0;e<t.length;e++)for(let n=0;n<a.length;n++){let r=a[n],i=null,o=null;r.tests.every(n=>{let r=s(t,e,n);return r.position!==null&&({position:i}=r),r.range&&(o=r.range),r.match})&&(r.transform(t,e,i,o),(r.name===`inline attributes`||r.name===`inline nesting self-close`)&&n--)}})};export{y as attrs};
3
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/helper/constants.ts","../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.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":["/** . */\nexport const CLASS_MARKER = 46;\n/** # */\nexport const ID_MARKER = 35;\n/** space */\nexport const PAIR_SEPARATOR = 32;\n/** = */\nexport const KEY_SEPARATOR = 61;\n/** \" */\nexport const QUOTE_MARKER = 34;\n","import {\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n QUOTE_MARKER,\n} from \"./constants.js\";\nimport type { Attr } from \"./types.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nconst isAllowedKeyChar = (charCode: number): boolean =>\n !(\n (\n charCode === 9 /* \\t */ ||\n charCode === 10 /* \\n */ ||\n charCode === 12 /* \\f */ ||\n charCode === 32 /* 空格 */ ||\n charCode === 47 /* / */ ||\n charCode === 62 /* > */ ||\n charCode === 34 /* \" */ ||\n charCode === 39 /* ' */ ||\n charCode === 61\n ) /* = */\n );\n\nexport const getAttrs = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\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 marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(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 (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\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 && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport { getAttrs } from \"./getAttrs.js\";\nimport type { DelimiterRange } from \"../rules/types.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\nimport type { DelimiterChecker } from \"../rules/types.js\";\n\n/**\n * Get a function to check if a string matches the delimiter pattern\n * 获取一个函数来检查字符串是否匹配分隔符模式\n *\n * @param options - Delimiter configuration / 分隔符配置\n * @param where - Position for matching: start, end, or only / 匹配位置:开始、结束或仅匹配\n * @returns A function that checks if content matches the delimiter pattern / 检查内容是否匹配分隔符模式的函数\n */\nexport const getDelimiterChecker = (\n options: DelimiterConfig,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where))\n throw new Error(`Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`);\n\n // Cache frequently used values\n const left = options.left;\n const right = options.right;\n const leftLength = left.length;\n const rightLength = right.length;\n const minContentLength = leftLength + 1 + rightLength;\n\n return (content) => {\n // Quick check for minimum length requirements\n if (typeof content !== \"string\" || content.length < minContentLength) return false;\n\n let start: number;\n let end: number;\n\n if (where === \"start\") {\n // Check if content starts with left delimiter\n if (!content.startsWith(left)) return false;\n\n start = leftLength;\n end = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): 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) return currentToken;\n\n index--;\n }\n\n /* istanbul ignore next -- @preserve */\n return null;\n};\n","/**\n * Get index item of array. Supports negative index, where -1 is last element in array.\n *\n * 获取数组中的索引项。支持负索引,其中 -1 是数组的最后一个元素。\n *\n * @param arr - Array to get item from / 要获取项的数组\n * @param index - Index of item / 项的索引\n * @returns Array item / 数组项\n */\nexport const getArrayItem = <T>(arr: T[], index: number): T =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet } from \"../rules/types.js\";\nimport { getArrayItem } 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 range: [start: number, end: number] | null;\n}\n\n/**\n * Test if rule matches token stream.\n *\n * @param tokens - token stream\n * @param index - current token index\n * @param rule - rule to test\n *\n * @returns test result\n */\nexport const testRule = (tokens: Token[], index: number, rule: AttrRuleSet): TestRuleResult => {\n const testResult: TestRuleResult = {\n match: false,\n position: null,\n range: null,\n };\n const isShift = rule.shift !== undefined;\n\n const tokenIndex = isShift ? index + rule.shift : rule.position;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (isShift && tokenIndex < 0) return testResult;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n if (!token) return testResult;\n\n const ruleKeys = Object.keys(rule) as (keyof typeof rule)[];\n\n const ruleKeysLength = ruleKeys.length;\n\n for (let i = 0; i < ruleKeysLength; i++) {\n const key = ruleKeys[i];\n\n if (key === \"shift\" || key === \"position\") continue;\n\n if (token[key as keyof Token] === undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => childTest.position !== undefined)) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth typescript/no-unnecessary-condition\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\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 testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\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 or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer T) | null\n ? T | TestFunction<T>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项\n * 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens\n * One of shift or position must be defined\n */\nexport type AttrRuleSet = ShiftAttrRuleSet | PositionAttrRuleSet;\n\nexport interface AttrRule {\n name: string;\n tests: AttrRuleSet[];\n transform: (tokens: Token[], index: number, childIndex: number, range: DelimiterRange) => void;\n}\n\n/**\n * Define an attribute rule helper\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n *\n * @example\n * ```ts\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n * ```\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getBlockRule = (options: DelimiterConfig): AttrRule =>\n /**\n * end of {.block}\n */\n defineAttrRule({\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, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker } from \"../helper/index.js\";\n\nexport const getFenceRule = (options: DelimiterConfig): AttrRule =>\n /**\n * fenced code blocks\n *\n * ```python {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n defineAttrRule({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: getDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getHeadingRule = (options: DelimiterConfig): AttrRule =>\n /**\n * ## end of {#heading}\n */\n defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: -1,\n type: \"heading_open\",\n },\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, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getInlineRules = (options: DelimiterConfig): AttrRule[] => [\n /**\n * bla `click()`{.c} ![](img.png){.d}\n *\n * differs from 'inline attributes' as it does\n * not have a closing tag (nesting: -1)\n */\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n const targetToken = childTokens[childIndex - 1];\n const attrsEndIndex = options.right.length + range[1];\n\n // Apply attributes to the target token\n addAttrs(targetToken, token.content, range, options.allowed);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /**\n * *emphasis*{.with attrs=1}\n */\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const currentToken = childTokens[childIndex];\n const { content } = currentToken;\n const attrsEndIndex = options.right.length + range[1];\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(childTokens, childIndex - 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getListRules = (options: DelimiterConfig): AttrRule[] => [\n /**\n * - item\n * {.a}\n */\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, options.allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.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 defineAttrRule({\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) => 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, _, range): void => {\n const token = tokens[index + 2];\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, token.content, range, options.allowed);\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 defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const content = token.content;\n const attrStartIndex = range[0] - options.left.length;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the list item opening token\n addAttrs(tokens[index - 2], content, range, options.allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n];\n","import type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\n\nexport const getSoftBreakRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\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, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Apply attributes to the opening token\n addAttrs(\n getMatchingOpeningToken(tokens, closingTokenIndex),\n token.content,\n range,\n options.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\n\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker } from \"../helper/index.js\";\n\nexport const getHrRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\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): DelimiterRange | false => {\n let pos = 0;\n let charCode;\n const markerCode = content.charCodeAt(pos++);\n\n if (\n markerCode !== 45 /** - */ &&\n markerCode !== 42 /** * */ &&\n markerCode !== 95 /** _ */\n )\n return false;\n\n let count = 1;\n\n while (pos < content.length) {\n charCode = content.charCodeAt(pos++);\n if (charCode !== markerCode) break;\n\n count++;\n }\n\n if (count < 3) return false;\n\n if (!isSpace(content.charCodeAt(pos - 1))) pos--;\n\n return getDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n","import { isSpace } from \"markdown-it/lib/common/utils.mjs\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, getDelimiterChecker, getMatchingOpeningToken } 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// oxlint-disable-next-line max-lines-per-function\nexport const getTableRules = (options: DelimiterConfig): AttrRule[] => [\n defineAttrRule({\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, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, options.allowed);\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 defineAttrRule({\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, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find last attribute syntax in the content\n\n // Apply attributes to the table cell token\n addAttrs(cellOpenToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\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[currentIndex - 1] 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 (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\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 defineAttrRule({\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 let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\") tbodyOpenIndex--;\n\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta?.columnCount ?? 0;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++) {\n if (colIndex + i < columnCount)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n }\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n];\n","import type { AttrRule } from \"./types.js\";\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { getBlockRule } from \"./block.js\";\nimport { getFenceRule } from \"./fence.js\";\nimport { getHeadingRule } from \"./heading.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 \"heading\",\n \"hr\",\n \"softbreak\",\n \"block\",\n];\n\nexport const getRules = (options: Required<MarkdownItAttrsOptions>): 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 // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(getHeadingRule(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 type { DelimiterRange } from \"./rules/index.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 = (state) => {\n const tokens = state.tokens;\n\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 let range: DelimiterRange | null = null;\n\n // oxlint-disable-next-line no-loop-func\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position !== null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\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 };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"mappings":"2DACA,MCSM,EAAoB,GACxB,EAEI,IAAa,GACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IAIN,GACX,EACA,EACA,IACW,CACX,IAAI,EAAM,GACN,EAAQ,GACR,EAAa,GACb,EAAoB,GAElB,EAAgB,EAAE,CAKxB,IAAK,IAAI,EAAQ,EAAM,GAAI,EAAQ,EAAM,GAAI,IAAS,CACpD,IAAM,EAAW,EAAI,WAAW,EAAM,CAGtC,GAAI,IAAa,IAAiB,EAAY,CAC5C,EAAa,GACb,SAIF,GAAI,IAAa,IAAgB,IAAQ,GAAI,CACvC,EAAI,WAAW,EAAQ,EAAE,GAAK,IAChC,EAAM,aACN,KAEA,EAAM,QAGR,EAAa,GACb,SAIF,GAAI,IAAa,IAAa,IAAQ,GAAI,CACxC,EAAM,KACN,EAAa,GACb,SAIF,GAAI,IAAa,IAAgB,IAAU,IAAM,CAAC,EAAmB,CACnE,EAAoB,GACpB,SAGF,GAAI,IAAa,IAAgB,EAAmB,CAClD,EAAoB,GACpB,SAIF,GAAI,IAAa,IAAkB,CAAC,EAAmB,CACrD,GAAI,I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