@mdit/plugin-attrs 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PluginWithOptions } from "markdown-it";
2
2
  import "markdown-it/lib/token.mjs";
3
3
  //#region src/helper/types.d.ts
4
+ type Attr = [key: string, value: string];
4
5
  interface AllowedAttrEntry {
5
6
  /**
6
7
  * Attribute name, supports string or RegExp
@@ -60,6 +61,24 @@ interface DelimiterConfig {
60
61
  }
61
62
  //#endregion
62
63
  //#region src/options.d.ts
64
+ interface ParseAttrsOptions extends Partial<Omit<DelimiterConfig, "filter">> {
65
+ /**
66
+ * Where the attrs section shall be located in the content
67
+ *
68
+ * - `"start"`: at the start of the content
69
+ * - `"end"`: at the end of the content
70
+ * - `"only"`: the content shall only contain the attrs section
71
+ *
72
+ * 属性部分在内容中的位置
73
+ *
74
+ * - `"start"`: 位于内容开头
75
+ * - `"end"`: 位于内容结尾
76
+ * - `"only"`: 内容仅包含属性部分
77
+ *
78
+ * @default "end"
79
+ */
80
+ where?: "start" | "end" | "only";
81
+ }
63
82
  type MarkdownItAttrRuleName = "fence" | "inline" | "table" | "list" | "heading" | "hr" | "softbreak" | "blockInfo" | "blockEnd" |
64
83
  /** Legacy alias of `blockEnd` */
65
84
  "block" |
@@ -86,8 +105,25 @@ interface MarkdownItAttrsOptions extends Partial<DelimiterConfig> {
86
105
  fenceAttrsOnPre?: boolean;
87
106
  }
88
107
  //#endregion
108
+ //#region src/parseAttrs.d.ts
109
+ /**
110
+ * Parse attrs from a string containing a delimited attrs section
111
+ *
112
+ * 从包含分隔符属性部分的字符串中解析属性
113
+ *
114
+ * @example
115
+ * parseAttrs("foo {.bar #baz data-a=b}");
116
+ * // [["class", "bar"], ["id", "baz"], ["data-a", "b"]]
117
+ *
118
+ * @param content - Content to parse / 要解析的内容
119
+ * @param options - Parse options / 解析选项
120
+ * @returns Parsed attrs, or `null` when no valid attrs section is found / 解析出的属性,未找到有效属性部分时为
121
+ * `null`
122
+ */
123
+ declare const parseAttrs: (content: string, { where, left, right, allowed }?: ParseAttrsOptions) => Attr[] | null;
124
+ //#endregion
89
125
  //#region src/plugin.d.ts
90
126
  declare const attrs: PluginWithOptions<MarkdownItAttrsOptions>;
91
127
  //#endregion
92
- export { type MarkdownItAttrRuleName, type MarkdownItAttrsOptions, attrs };
128
+ export { type AllowedAttrEntry, type AllowedAttrs, type Attr, type AttrFilter, type DelimiterConfig, type MarkdownItAttrRuleName, type MarkdownItAttrsOptions, type ParseAttrsOptions, attrs, parseAttrs };
93
129
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import e from"markdown-it";const t=(e,t)=>{if(e.charCodeAt(t)!==34)return!1;let n=0;for(let r=t-1;r>=0&&e.charCodeAt(r)===92;r--)n++;return n%2==0},n=(e,n,r)=>{let i=e.indexOf(r,n);if(i===-1)return-1;let a=e.indexOf(`"`,n);if(a===-1||a>i)return i;let o=!1;for(let i=n;i<e.length;i++)if(t(e,i))o=!o;else if(!o&&e.startsWith(r,i))return i;return-1},r=(e,n)=>{let r=e.lastIndexOf(n);if(r===-1)return-1;let i=e.indexOf(`"`);if(i===-1||i>r)return r;let a=-1,o=!1;for(let r=0;r<e.length;r++)t(e,r)?o=!o:!o&&e.startsWith(n,r)&&(a=r);return a},i=(e,t)=>{if(![`start`,`end`,`only`].includes(t))throw Error(`Invalid 'where' parameter: ${t}. Expected 'start', 'end', or 'only'.`);let i=e.left,a=e.right,o=i.length,s=a.length,c=o+1+s;return e=>{if(typeof e!=`string`||e.length<c)return!1;let l,u;if(t===`start`){if(!e.startsWith(i)||(l=o,u=n(e,o+1,a),u===-1))return!1;let t=u+s;if(t<e.length&&a.includes(e.charAt(t)))return!1}else if(t===`end`){if(l=r(e,i),l===-1||(u=n(e,l+o+1,a),l+=o,u===-1||u+s!==e.length))return!1}else{if(!e.startsWith(i)||!e.endsWith(a))return!1;l=o,u=e.length-s}let d=e.charCodeAt(l),f=u-l;return(d===46||d===35?f>=2:f>=1)?[l,u]:!1}},a=e=>e!==9&&e!==10&&e!==12&&e!==32&&e!==47&&e!==62&&e!==34&&e!==39&&e!==61,o=(e,n,r)=>{let i=``,o=``,s=!0,c=!1,l=[];for(let r=n[0];r<n[1];r++){let n=e.charCodeAt(r);if(n===61&&s){s=!1;continue}if(n===46&&i===``){e.charCodeAt(r+1)===46?(i=`css-module`,r++):i=`class`,s=!1;continue}if(n===35&&i===``){i=`id`,s=!1;continue}if(n===34&&t(e,r)&&o===``&&!c){c=!0;continue}if(n===34&&t(e,r)&&c){c=!1;continue}if(n===32&&!c){if(i===``)continue;l.push([i,o]),i=``,o=``,s=!0;continue}if(!(s&&!a(n))){if(s){i+=String.fromCharCode(n);continue}o+=String.fromCharCode(n)}}return i!==``&&l.push([i,o]),r?l.filter(([e,t])=>r(e,t)):l},s=(e,t,n,r)=>{e&&o(t,n,r).forEach(([t,n])=>{switch(t){case`class`:e.attrJoin(`class`,n);break;case`css-module`:e.attrJoin(`css-module`,n);break;default:e.attrSet(t,n)}})},c=(e,t)=>{let n=e[t];if(!n||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},l=e=>e.length>0&&typeof e[0]==`object`&&`name`in e[0],u=e=>{if(!e||e.length===0)return()=>!0;let t=new Set,n=[];for(let r of e)r instanceof RegExp?n.push(r):t.add(r);let r=t.size,i=n.length;return e=>{if(r>0&&t.has(e))return!0;for(let t=0;t<i;t++)if(n[t].test(e))return!0;return!1}},d=e=>{if(e.length===0)return null;if(!l(e)){let t=new Set,n=[];for(let r of e)r instanceof RegExp?n.push(r):t.add(r);let r=t.size,i=n.length;return e=>{if(r>0&&t.has(e))return!0;for(let t=0;t<i;t++)if(n[t].test(e))return!0;return!1}}let t=[],n=[];for(let r of e){let e=u(r.value);r.name instanceof RegExp?n.push([r.name,e]):t.push([r.name,e])}let r=t.length,i=n.length;return(e,a)=>{for(let n=0;n<r;n++){let[r,i]=t[n];if(r===e)return i(a)}for(let t=0;t<i;t++){let[r,i]=n[t];if(r.test(e))return i(a)}return!1}},f=(e,t)=>t>=0?e[t]:e[e.length+t],p=(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 o=f(e,a);if(!o)return r;let s=Object.keys(n),c=s.length;for(let e=0;e<c;e++){let t=s[e];if(t===`shift`||t===`position`)continue;if(o[t]==null)return r;if(t===`children`&&Array.isArray(n.children)){if(!o.children?.length)return r;let e=n.children,t=o.children,i,a=null;if(e.every(e=>typeof e.position==`number`)){if(i=e.every(e=>{let n=p(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=p(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(o[t]!==i)return r;break;case`function`:{let e=i(o[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},m=e=>e,h=(e,t)=>{let n=e.utils.isSpace,r=e.utils.isWhiteSpace,a=i(t,`end`),o=e=>{for(let t=0;t<e.length;t++)if(!r(e.charCodeAt(t)))return!1;return!0},l=e=>{let t=e.length-1;if(t>=0){let n=e[t];if(n.type===`text`&&!o(n.content))return t}let n=0;for(let r=t;r>=0;r--){let t=e[r];if(t.type===`code_inline`||t.type===`math_inline`)return-1;if(t.nesting===-1){n++;continue}if(t.nesting===1&&--n<0)return-1;if(!(n>0||t.type!==`text`||o(t.content)))return r}return-1},u=-1;return m({name:`end of block`,tests:[{shift:0,type:`inline`,children:e=>(u=l(e),u!==-1&&a(e[u].content))}],transform:(e,r,i,a)=>{let o=e[r].children[u],l=a[0]-t.left.length,{content:d}=o,f=n(d.charCodeAt(l-1));s(c(e,r+1),d,a,t.filter),o.content=d.slice(0,f?l-1:l)}})},g=(e,t)=>{let n=e.utils.isSpace;return m({name:`block info`,tests:[{shift:0,type:e=>e!==`fence`,block:!0,info:i(t,`end`)}],transform:(e,r,i,a)=>{let o=a[0]-t.left.length,c=e[r],{info:l}=c,u=n(l.charCodeAt(o-1));s(c,l,a,t.filter),c.info=l.slice(0,u?o-1:o)}})},_=(e,t)=>{let n=e.utils.isSpace;return m({name:`code-block`,tests:[{shift:0,type:`fence`,block:!0,info:i(t,`end`)}],transform:(e,r,i,a)=>{let o=a[0]-t.left.length,c=e[r],{info:l}=c,u=n(l.charCodeAt(o-1));s(c,l,a,t.filter),c.info=l.slice(0,u?o-1:o)}})},v=(e,t)=>{let n=e.utils.isSpace;return m({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,r,i,a)=>{let o=a[0]-t.left.length,l=e[r].children[i],{content:u}=l,d=n(u.charCodeAt(o-1));s(c(e,r+1),u,a,t.filter),l.content=u.slice(0,d?o-1:o)}})},y=e=>[m({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,r,i)=>{let a=t[n].children,o=a[r],c=a[r-1],l=e.right.length+i[1];s(c,o.content,i,e.filter),o.content.length===l?a.splice(r,1):o.content=o.content.slice(l)}}),m({name:`inline attributes`,tests:[{shift:0,type:`inline`,children:[{shift:-1,nesting:-1},{shift:0,type:`text`,content:i(e,`start`)}]}],transform:(t,n,r,i)=>{let a=t[n].children,o=a[r],{content:l}=o,u=e.right.length+i[1];s(c(a,r-1),l,i,e.filter),o.content=l.slice(u)}})],b=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[m({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,o=a[n],c=t-2;for(;e[c-1].type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;s(e[c-1],o.content,i,r),e[t].children=a.slice(0,-2)}}),m({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 a=e[t+2];s(c(e,t),a.content,i,r),e.splice(t+1,3)}}),m({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,o)=>{let c=e[i].children[a],l=c.content,u=o[0]-t.left.length,d=n(l.charCodeAt(u-1));s(e[i-2],l,o,r),c.content=l.slice(0,d?u-1:u)}})]},x=e=>m({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,r,i)=>{let a=t[n].children,o=a[r],l=n+1;for(;t[l+1]?.nesting===-1;)l++;s(c(t,l),o.content,i,e.filter),t[n].children=a.slice(0,-2)}}),S=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[m({name:`dl softbreak`,tests:[{shift:-2,type:`dd_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,o=a[n],c=t-2;for(;e[c-1].type!==`dl_open`;)c--;s(e[c-1],o.content,i,r),e[t].children=a.slice(0,-2)}}),m({name:`dl double softbreak`,tests:[{shift:0,type:`dl_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 a=e[t+2];s(c(e,t),a.content,i,r),e.splice(t+1,3)}}),m({name:`dl item end`,tests:[{shift:-2,type:`dd_open`},{shift:0,type:`inline`,children:[{position:-1,type:`text`,content:i(t,`end`)}]}],transform:(e,i,a,o)=>{let c=e[i].children[a],l=c.content,u=o[0]-t.left.length,d=n(l.charCodeAt(u-1));s(e[i-2],l,o,r),c.content=l.slice(0,d?u-1:u)}})]},C=(e,t)=>{let n=e.utils.isSpace,r=i(t,`end`);return m({name:`horizontal rule`,tests:[{shift:0,type:`paragraph_open`},{shift:1,type:`inline`,children:e=>e.length===1,content:e=>{let i=0,a,o=e.charCodeAt(i++);if(o!==45&&o!==42&&o!==95)return!1;let s=1;for(;i<e.length&&(a=e.charCodeAt(i++),a===o);)s++;if(s<3)return!1;n(e.charCodeAt(i-1))||i--;let c=r(e);return c!==!1&&c[0]-t.left.length===i&&c}},{shift:2,type:`paragraph_close`}],transform:(e,n,r,i)=>{let a=e[n],{content:o}=e[n+1];a.type=`hr`,a.tag=`hr`,a.nesting=0,s(a,o,i,t.filter),a.markup=o,e.splice(n+1,2)}})},w=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[m({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 a=e[t+2];s(c(e,t),a.content,i,r),e.splice(t+1,3)}}),m({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,o)=>{let c=o[0]-t.left.length,l=e[i].children[a],u=e[i-1],{content:d}=l,f=n(d.charCodeAt(c-1));s(u,d,o,r),l.content=d.slice(0,f?c-1:c)}}),m({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=c(e,t),r=e[t-1],i=0,a=t-1;for(;a>0;){let t=e[a];if(t===n){let t=e[a-1];t.meta={...t.meta,columnCount:i};break}t.level===r.level&&t.type===r.type&&i++,a--}let o=e[t+2];o.meta={...o.meta,columnCount:i}}}),m({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++)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)}})]},T=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[m({name:`tasklist softbreak`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-3,type:`softbreak`},{position:-2,type:`text`,content:i(t,`only`)},{position:-1,type:`label_close`}]}],transform:(e,t,n,i)=>{let a=e[t].children,o=a[n-1],c=t-2;for(;e[c-1].type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;s(e[c-1],o.content,i,r),a.splice(n-2,2)}}),m({name:`tasklist item end`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-2,type:`text`,content:i(t,`end`)},{position:-1,type:`label_close`}]}],transform:(e,i,a,o)=>{let c=e[i].children[a-1],l=c.content,u=o[0]-t.left.length,d=n(l.charCodeAt(u-1));s(e[i-2],l,o,r),c.content=l.slice(0,d?u-1:u)}})]},E=[`fence`,`inline`,`table`,`list`,`heading`,`hr`,`softbreak`,`blockInfo`,`blockEnd`,`block`],D=new Set([`dl`,`tasklist`]),O=(e,t)=>{let n=t.rule===!1?[]:Array.isArray(t.rule)?t.rule.filter(e=>E.includes(e)||D.has(e)):E,r=[];return n.includes(`fence`)&&r.push(_(e,t)),n.includes(`inline`)&&r.push(...y(t)),n.includes(`table`)&&r.push(...w(e,t)),n.includes(`list`)&&r.push(...b(e,t)),n.includes(`tasklist`)&&r.push(...T(e,t)),n.includes(`dl`)&&r.push(...S(e,t)),n.includes(`softbreak`)&&r.push(x(t)),n.includes(`hr`)&&r.push(C(e,t)),n.includes(`blockInfo`)&&r.push(g(e,t)),n.includes(`blockEnd`)||n.includes(`block`)?r.push(h(e,t)):n.includes(`heading`)&&r.push(v(e,t)),r},k=(t,{left:n=`{`,right:r=`}`,allowed:i=[],rule:a=`all`,fenceAttrsOnPre:o=!0}={})=>{let s=O(t,{left:n,right:r,allowed:i,filter:d(i),rule:a});if(t.core.ruler.before(`linkify`,`attrs`,e=>{let t=e.tokens;for(let e=0;e<t.length;e++)for(let n=0;n<s.length;n++){let r=s[n],i=null,a=null;if(r.tests.every(n=>{let r=p(t,e,n);return r.position!=null&&({position:i}=r),r.range&&(a=r.range),r.match})){let o=t[e];r.transform(t,e,i,a),t[e]!==o&&(e=t.indexOf(o)),(r.name===`inline attributes`||r.name===`inline nesting self-close`)&&n--}}}),o&&s.some(({name:e})=>e===`code-block`)){let n=new e().renderer.rules.fence,r=t.renderer.rules.fence;if((typeof r!=`function`||r===n)&&typeof r==`function`){let e=r;t.renderer.rules.fence=(t,n,r,i,a)=>{let o=t[n],s=o.attrs?o.attrs.slice():null;o.attrs=null;let c=e(t,n,r,i,a);return o.attrs=s,!s||s.length===0?c:c.replace(/^<pre(?<char>[ >])/,(e,t)=>`<pre${a.renderAttrs(o)}${t}`)}}}};export{k as attrs};
1
+ import e from"markdown-it";const t=(e,t)=>{if(e.charCodeAt(t)!==34)return!1;let n=0;for(let r=t-1;r>=0&&e.charCodeAt(r)===92;r--)n++;return n%2==0},n=(e,n,r)=>{let i=e.indexOf(r,n);if(i===-1)return-1;let a=e.indexOf(`"`,n);if(a===-1||a>i)return i;let o=!1;for(let i=n;i<e.length;i++)if(t(e,i))o=!o;else if(!o&&e.startsWith(r,i))return i;return-1},r=(e,n)=>{let r=e.lastIndexOf(n);if(r===-1)return-1;let i=e.indexOf(`"`);if(i===-1||i>r)return r;let a=-1,o=!1;for(let r=0;r<e.length;r++)t(e,r)?o=!o:!o&&e.startsWith(n,r)&&(a=r);return a},i=(e,t)=>{if(![`start`,`end`,`only`].includes(t))throw Error(`Invalid 'where' parameter: ${t}. Expected 'start', 'end', or 'only'.`);let i=e.left,a=e.right,o=i.length,s=a.length,c=o+1+s;return e=>{if(typeof e!=`string`||e.length<c)return!1;let l,u;if(t===`start`){if(!e.startsWith(i)||(l=o,u=n(e,o+1,a),u===-1))return!1;let t=u+s;if(t<e.length&&a.includes(e.charAt(t)))return!1}else if(t===`end`){if(l=r(e,i),l===-1||(u=n(e,l+o+1,a),l+=o,u===-1||u+s!==e.length))return!1}else{if(!e.startsWith(i)||!e.endsWith(a))return!1;l=o,u=e.length-s}let d=e.charCodeAt(l),f=u-l;return(d===46||d===35?f>=2:f>=1)?[l,u]:!1}},a=e=>e!==9&&e!==10&&e!==12&&e!==32&&e!==47&&e!==62&&e!==34&&e!==39&&e!==61,o=(e,n,r)=>{let i=``,o=``,s=!0,c=!1,l=[];for(let r=n[0];r<n[1];r++){let n=e.charCodeAt(r);if(n===61&&s){s=!1;continue}if(n===46&&i===``){e.charCodeAt(r+1)===46?(i=`css-module`,r++):i=`class`,s=!1;continue}if(n===35&&i===``){i=`id`,s=!1;continue}if(n===34&&t(e,r)&&o===``&&!c){c=!0;continue}if(n===34&&t(e,r)&&c){c=!1;continue}if(n===32&&!c){if(i===``)continue;l.push([i,o]),i=``,o=``,s=!0;continue}if(!(s&&!a(n))){if(s){i+=String.fromCharCode(n);continue}o+=String.fromCharCode(n)}}return i!==``&&l.push([i,o]),r?l.filter(([e,t])=>r(e,t)):l},s=(e,t,n,r)=>{e&&o(t,n,r).forEach(([t,n])=>{switch(t){case`class`:e.attrJoin(`class`,n);break;case`css-module`:e.attrJoin(`css-module`,n);break;default:e.attrSet(t,n)}})},c=(e,t)=>{let n=e[t];if(!n||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},l=e=>e.length>0&&typeof e[0]==`object`&&`name`in e[0],u=e=>{if(!e||e.length===0)return()=>!0;let t=new Set,n=[];for(let r of e)r instanceof RegExp?n.push(r):t.add(r);let r=t.size,i=n.length;return e=>{if(r>0&&t.has(e))return!0;for(let t=0;t<i;t++)if(n[t].test(e))return!0;return!1}},d=e=>{if(e.length===0)return null;if(!l(e)){let t=new Set,n=[];for(let r of e)r instanceof RegExp?n.push(r):t.add(r);let r=t.size,i=n.length;return e=>{if(r>0&&t.has(e))return!0;for(let t=0;t<i;t++)if(n[t].test(e))return!0;return!1}}let t=[],n=[];for(let r of e){let e=u(r.value);r.name instanceof RegExp?n.push([r.name,e]):t.push([r.name,e])}let r=t.length,i=n.length;return(e,a)=>{for(let n=0;n<r;n++){let[r,i]=t[n];if(r===e)return i(a)}for(let t=0;t<i;t++){let[r,i]=n[t];if(r.test(e))return i(a)}return!1}},f=(e,t)=>t>=0?e[t]:e[e.length+t],p=(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 o=f(e,a);if(!o)return r;let s=Object.keys(n),c=s.length;for(let e=0;e<c;e++){let t=s[e];if(t===`shift`||t===`position`)continue;if(o[t]==null)return r;if(t===`children`&&Array.isArray(n.children)){if(!o.children?.length)return r;let e=n.children,t=o.children,i,a=null;if(e.every(e=>typeof e.position==`number`)){if(i=e.every(e=>{let n=p(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=p(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(o[t]!==i)return r;break;case`function`:{let e=i(o[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},m=(e,{where:t=`end`,left:n=`{`,right:r=`}`,allowed:a=[]}={})=>{let s=d(a),c=i({left:n,right:r,allowed:a,filter:s},t)(e);return c===!1?null:o(e,c,s)},h=e=>e,g=(e,t)=>{let n=e.utils.isSpace,r=e.utils.isWhiteSpace,a=i(t,`end`),o=e=>{for(let t=0;t<e.length;t++)if(!r(e.charCodeAt(t)))return!1;return!0},l=e=>{let t=e.length-1;if(t>=0){let n=e[t];if(n.type===`text`&&!o(n.content))return t}let n=0;for(let r=t;r>=0;r--){let t=e[r];if(t.type===`code_inline`||t.type===`math_inline`)return-1;if(t.nesting===-1){n++;continue}if(t.nesting===1&&--n<0)return-1;if(!(n>0||t.type!==`text`||o(t.content)))return r}return-1},u=-1;return h({name:`end of block`,tests:[{shift:0,type:`inline`,children:e=>(u=l(e),u!==-1&&a(e[u].content))}],transform:(e,r,i,a)=>{let o=e[r].children[u],l=a[0]-t.left.length,{content:d}=o,f=n(d.charCodeAt(l-1));s(c(e,r+1),d,a,t.filter),o.content=d.slice(0,f?l-1:l)}})},_=(e,t)=>{let n=e.utils.isSpace;return h({name:`block info`,tests:[{shift:0,type:e=>e!==`fence`,block:!0,info:i(t,`end`)}],transform:(e,r,i,a)=>{let o=a[0]-t.left.length,c=e[r],{info:l}=c,u=n(l.charCodeAt(o-1));s(c,l,a,t.filter),c.info=l.slice(0,u?o-1:o)}})},v=(e,t)=>{let n=e.utils.isSpace;return h({name:`code-block`,tests:[{shift:0,type:`fence`,block:!0,info:i(t,`end`)}],transform:(e,r,i,a)=>{let o=a[0]-t.left.length,c=e[r],{info:l}=c,u=n(l.charCodeAt(o-1));s(c,l,a,t.filter),c.info=l.slice(0,u?o-1:o)}})},y=(e,t)=>{let n=e.utils.isSpace;return h({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,r,i,a)=>{let o=a[0]-t.left.length,l=e[r].children[i],{content:u}=l,d=n(u.charCodeAt(o-1));s(c(e,r+1),u,a,t.filter),l.content=u.slice(0,d?o-1:o)}})},b=e=>[h({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,r,i)=>{let a=t[n].children,o=a[r],c=a[r-1],l=e.right.length+i[1];s(c,o.content,i,e.filter),o.content.length===l?a.splice(r,1):o.content=o.content.slice(l)}}),h({name:`inline attributes`,tests:[{shift:0,type:`inline`,children:[{shift:-1,nesting:-1},{shift:0,type:`text`,content:i(e,`start`)}]}],transform:(t,n,r,i)=>{let a=t[n].children,o=a[r],{content:l}=o,u=e.right.length+i[1];s(c(a,r-1),l,i,e.filter),o.content=l.slice(u)}})],x=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[h({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,o=a[n],c=t-2;for(;e[c-1].type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;s(e[c-1],o.content,i,r),e[t].children=a.slice(0,-2)}}),h({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 a=e[t+2];s(c(e,t),a.content,i,r),e.splice(t+1,3)}}),h({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,o)=>{let c=e[i].children[a],l=c.content,u=o[0]-t.left.length,d=n(l.charCodeAt(u-1));s(e[i-2],l,o,r),c.content=l.slice(0,d?u-1:u)}})]},S=e=>h({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,r,i)=>{let a=t[n].children,o=a[r],l=n+1;for(;t[l+1]?.nesting===-1;)l++;s(c(t,l),o.content,i,e.filter),t[n].children=a.slice(0,-2)}}),C=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[h({name:`dl softbreak`,tests:[{shift:-2,type:`dd_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,o=a[n],c=t-2;for(;e[c-1].type!==`dl_open`;)c--;s(e[c-1],o.content,i,r),e[t].children=a.slice(0,-2)}}),h({name:`dl double softbreak`,tests:[{shift:0,type:`dl_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 a=e[t+2];s(c(e,t),a.content,i,r),e.splice(t+1,3)}}),h({name:`dl item end`,tests:[{shift:-2,type:`dd_open`},{shift:0,type:`inline`,children:[{position:-1,type:`text`,content:i(t,`end`)}]}],transform:(e,i,a,o)=>{let c=e[i].children[a],l=c.content,u=o[0]-t.left.length,d=n(l.charCodeAt(u-1));s(e[i-2],l,o,r),c.content=l.slice(0,d?u-1:u)}})]},w=(e,t)=>{let n=e.utils.isSpace,r=i(t,`end`);return h({name:`horizontal rule`,tests:[{shift:0,type:`paragraph_open`},{shift:1,type:`inline`,children:e=>e.length===1,content:e=>{let i=0,a,o=e.charCodeAt(i++);if(o!==45&&o!==42&&o!==95)return!1;let s=1;for(;i<e.length&&(a=e.charCodeAt(i++),a===o);)s++;if(s<3)return!1;n(e.charCodeAt(i-1))||i--;let c=r(e);return c!==!1&&c[0]-t.left.length===i&&c}},{shift:2,type:`paragraph_close`}],transform:(e,n,r,i)=>{let a=e[n],{content:o}=e[n+1];a.type=`hr`,a.tag=`hr`,a.nesting=0,s(a,o,i,t.filter),a.markup=o,e.splice(n+1,2)}})},T=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[h({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 a=e[t+2];s(c(e,t),a.content,i,r),e.splice(t+1,3)}}),h({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,o)=>{let c=o[0]-t.left.length,l=e[i].children[a],u=e[i-1],{content:d}=l,f=n(d.charCodeAt(c-1));s(u,d,o,r),l.content=d.slice(0,f?c-1:c)}}),h({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=c(e,t),r=e[t-1],i=0,a=t-1;for(;a>0;){let t=e[a];if(t===n){let t=e[a-1];t.meta={...t.meta,columnCount:i};break}t.level===r.level&&t.type===r.type&&i++,a--}let o=e[t+2];o.meta={...o.meta,columnCount:i}}}),h({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++)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)}})]},E=(e,t)=>{let n=e.utils.isSpace,r=t.filter;return[h({name:`tasklist softbreak`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-3,type:`softbreak`},{position:-2,type:`text`,content:i(t,`only`)},{position:-1,type:`label_close`}]}],transform:(e,t,n,i)=>{let a=e[t].children,o=a[n-1],c=t-2;for(;e[c-1].type!==`ordered_list_open`&&e[c-1].type!==`bullet_list_open`;)c--;s(e[c-1],o.content,i,r),a.splice(n-2,2)}}),h({name:`tasklist item end`,tests:[{shift:-2,type:`list_item_open`},{shift:0,type:`inline`,children:[{position:-2,type:`text`,content:i(t,`end`)},{position:-1,type:`label_close`}]}],transform:(e,i,a,o)=>{let c=e[i].children[a-1],l=c.content,u=o[0]-t.left.length,d=n(l.charCodeAt(u-1));s(e[i-2],l,o,r),c.content=l.slice(0,d?u-1:u)}})]},D=[`fence`,`inline`,`table`,`list`,`heading`,`hr`,`softbreak`,`blockInfo`,`blockEnd`,`block`],O=new Set([`dl`,`tasklist`]),k=(e,t)=>{let n=t.rule===!1?[]:Array.isArray(t.rule)?t.rule.filter(e=>D.includes(e)||O.has(e)):D,r=[];return n.includes(`fence`)&&r.push(v(e,t)),n.includes(`inline`)&&r.push(...b(t)),n.includes(`table`)&&r.push(...T(e,t)),n.includes(`list`)&&r.push(...x(e,t)),n.includes(`tasklist`)&&r.push(...E(e,t)),n.includes(`dl`)&&r.push(...C(e,t)),n.includes(`softbreak`)&&r.push(S(t)),n.includes(`hr`)&&r.push(w(e,t)),n.includes(`blockInfo`)&&r.push(_(e,t)),n.includes(`blockEnd`)||n.includes(`block`)?r.push(g(e,t)):n.includes(`heading`)&&r.push(y(e,t)),r},A=(t,{left:n=`{`,right:r=`}`,allowed:i=[],rule:a=`all`,fenceAttrsOnPre:o=!0}={})=>{let s=k(t,{left:n,right:r,allowed:i,filter:d(i),rule:a});if(t.core.ruler.before(`linkify`,`attrs`,e=>{let t=e.tokens;for(let e=0;e<t.length;e++)for(let n=0;n<s.length;n++){let r=s[n],i=null,a=null;if(r.tests.every(n=>{let r=p(t,e,n);return r.position!=null&&({position:i}=r),r.range&&(a=r.range),r.match})){let o=t[e];r.transform(t,e,i,a),t[e]!==o&&(e=t.indexOf(o)),(r.name===`inline attributes`||r.name===`inline nesting self-close`)&&n--}}}),o&&s.some(({name:e})=>e===`code-block`)){let n=new e().renderer.rules.fence,r=t.renderer.rules.fence;if((typeof r!=`function`||r===n)&&typeof r==`function`){let e=r;t.renderer.rules.fence=(t,n,r,i,a)=>{let o=t[n],s=o.attrs?o.attrs.slice():null;o.attrs=null;let c=e(t,n,r,i,a);return o.attrs=s,!s||s.length===0?c:c.replace(/^<pre(?<char>[ >])/,(e,t)=>`<pre${a.renderAttrs(o)}${t}`)}}}};export{A as attrs,m as parseAttrs};
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/helper/getDelimiterChecker.ts","../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getMatchingOpeningToken.ts","../src/helper/normalizeAllowed.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/blockEnd.ts","../src/rules/blockInfo.ts","../src/rules/fence.ts","../src/rules/heading.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/dl.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/tasklist.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["import type { DelimiterChecker } from \"../rules/types.js\";\nimport { CLASS_MARKER, ESCAPE_MARKER, ID_MARKER, QUOTE_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\n\n// Check whether the character at the given index is a double quote that is not escaped\nexport const isUnescapedQuote = (content: string, index: number): boolean => {\n if (content.charCodeAt(index) !== QUOTE_MARKER) return false;\n\n let escapeCount = 0;\n\n for (let i = index - 1; i >= 0 && content.charCodeAt(i) === ESCAPE_MARKER; i--) escapeCount++;\n\n return escapeCount % 2 === 0;\n};\n\n// Find the first occurrence of the delimiter outside quoted values, starting at `from`\nconst findDelimiter = (content: string, from: number, delimiter: string): number => {\n const delimiterIndex = content.indexOf(delimiter, from);\n\n if (delimiterIndex === -1) return -1;\n\n // Fast path: without a quote before the delimiter it cannot be inside a quoted value\n const quoteIndex = content.indexOf('\"', from);\n\n if (quoteIndex === -1 || quoteIndex > delimiterIndex) return delimiterIndex;\n\n let insideQuotes = false;\n\n for (let index = from; index < content.length; index++) {\n if (isUnescapedQuote(content, index)) insideQuotes = !insideQuotes;\n else if (!insideQuotes && content.startsWith(delimiter, index)) return index;\n }\n\n return -1;\n};\n\n// Find the last occurrence of the left delimiter outside quoted values\nconst findLastLeftDelimiter = (content: string, left: string): number => {\n const leftIndex = content.lastIndexOf(left);\n\n if (leftIndex === -1) return -1;\n\n // Fast path: without a quote before the delimiter it cannot be inside a quoted value\n const quoteIndex = content.indexOf('\"');\n\n if (quoteIndex === -1 || quoteIndex > leftIndex) return leftIndex;\n\n let result = -1;\n let insideQuotes = false;\n\n for (let index = 0; index < content.length; index++) {\n if (isUnescapedQuote(content, index)) insideQuotes = !insideQuotes;\n else if (!insideQuotes && content.startsWith(left, index)) result = index;\n }\n\n return result;\n};\n\n/**\n * Get a function to check if a string matches the delimiter pattern 获取一个函数来检查字符串是否匹配分隔符模式\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 = findDelimiter(content, leftLength + 1, right);\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 = findLastLeftDelimiter(content, left);\n\n if (start === -1) return false;\n\n end = findDelimiter(content, start + leftLength + 1, right);\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 { DelimiterRange } from \"../rules/types.js\";\nimport {\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n QUOTE_MARKER,\n} from \"./constants.js\";\nimport { isUnescapedQuote } from \"./getDelimiterChecker.js\";\nimport type { Attr, AttrFilter } from \"./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 = (str: string, range: DelimiterRange, filter: AttrFilter | null): 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 (\n charCode === QUOTE_MARKER &&\n isUnescapedQuote(str, index) &&\n value === \"\" &&\n !valueInsideQuotes\n ) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && isUnescapedQuote(str, index) && 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 filter ? attrs.filter(([attrKey, attrValue]) => filter(attrKey, attrValue)) : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterRange } from \"../rules/types.js\";\nimport { getAttrs } from \"./getAttrs.js\";\nimport type { AttrFilter } from \"./types.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n filter: AttrFilter | null,\n): void => {\n if (!token) return;\n\n getAttrs(content, range, filter).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.attrSet(key, value);\n }\n }\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 // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token || 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","import type { AllowedAttrEntry, AllowedAttrs, AttrFilter } from \"./types.js\";\n\nconst isEntryArray = (allowed: AllowedAttrs): allowed is AllowedAttrEntry[] =>\n allowed.length > 0 && typeof allowed[0] === \"object\" && \"name\" in allowed[0];\n\nconst createValueFilter = (value: (string | RegExp)[] | undefined): ((val: string) => boolean) => {\n if (!value || value.length === 0) return (): boolean => true;\n\n const stringValues = new Set<string>();\n const regexValues: RegExp[] = [];\n\n for (const item of value) {\n if (item instanceof RegExp) regexValues.push(item);\n else stringValues.add(item);\n }\n\n const stringSize = stringValues.size;\n const regexLength = regexValues.length;\n\n return (val): boolean => {\n if (stringSize > 0 && stringValues.has(val)) return true;\n\n for (let i = 0; i < regexLength; i++) if (regexValues[i].test(val)) return true;\n\n return false;\n };\n};\n\n/**\n * Normalize allowed attributes config into a fast filter function.\n *\n * Pre-computes string sets for O(1) lookup and compiles regex patterns to avoid repeated instanceof\n * checks at filter time.\n *\n * @param allowed - Raw allowed attributes config\n * @returns Normalized filter function, or null if no filtering needed\n */\nexport const normalizeAllowed = (allowed: AllowedAttrs): AttrFilter | null => {\n if (allowed.length === 0) return null;\n\n // Simple format: (string | RegExp)[] — only filter by attribute name\n if (!isEntryArray(allowed)) {\n const stringNames = new Set<string>();\n const regexNames: RegExp[] = [];\n\n for (const item of allowed) {\n if (item instanceof RegExp) regexNames.push(item);\n else stringNames.add(item);\n }\n\n const stringNamesSize = stringNames.size;\n const regexNamesLength = regexNames.length;\n\n return (_name): boolean => {\n if (stringNamesSize > 0 && stringNames.has(_name)) return true;\n\n for (let i = 0; i < regexNamesLength; i++) if (regexNames[i].test(_name)) return true;\n\n return false;\n };\n }\n\n // Entry format: AllowedAttrEntry[]\n type ValueCheck = (value: string) => boolean;\n\n const stringEntries: [name: string, check: ValueCheck][] = [];\n const regexEntries: [name: RegExp, check: ValueCheck][] = [];\n\n for (const entry of allowed) {\n const valueFilter = createValueFilter(entry.value);\n\n if (entry.name instanceof RegExp) regexEntries.push([entry.name, valueFilter]);\n else stringEntries.push([entry.name, valueFilter]);\n }\n\n const stringEntriesLength = stringEntries.length;\n const regexEntriesLength = regexEntries.length;\n\n return (name, value): boolean => {\n // Check string names first (O(n) but n is usually small)\n for (let i = 0; i < stringEntriesLength; i++) {\n const [entryName, check] = stringEntries[i];\n\n if (entryName === name) return check(value);\n }\n\n // Then check regex names\n for (let i = 0; i < regexEntriesLength; i++) {\n const [entryName, check] = regexEntries[i];\n\n if (entryName.test(name)) return check(value);\n }\n\n return false;\n };\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 * @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] == 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 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, or a custom checker function which may return the\n * matched delimiter range. When the function returns a boolean instead, another test of the rule\n * must provide the delimiter range\n */\n children?: AttrRuleSet[] | ((children: Token[]) => DelimiterRange | boolean);\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 中查找匹配项 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens One of shift or position must be\n * 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 * @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 *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createBlockEndRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n const isWhiteSpace = md.utils.isWhiteSpace;\n const endDelimiterChecker = createDelimiterChecker(options, \"end\");\n\n // Non-allocating whitespace-only check (markdown-it's whitespace set)\n const isWhitespaceOnly = (content: string): boolean => {\n for (let index = 0; index < content.length; index++)\n if (!isWhiteSpace(content.charCodeAt(index))) return false;\n\n return true;\n };\n\n // Find the last meaningful text child - the one end-of-block attributes live on - skipping\n // trailing whitespace-only text and balanced tag pairs (e.g. an appended permalink); returns -1\n // when inline code / math or an unmatched opening tag is found first\n const findEndOfBlockChild = (children: Token[]): number => {\n const lastIndex = children.length - 1;\n\n if (lastIndex >= 0) {\n const lastChild = children[lastIndex];\n\n // Fast path: no tokens were appended after the attribute text\n if (lastChild.type === \"text\" && !isWhitespaceOnly(lastChild.content)) return lastIndex;\n }\n\n let depth = 0;\n\n for (let index = lastIndex; index >= 0; index--) {\n const child = children[index];\n\n if (child.type === \"code_inline\" || child.type === \"math_inline\") return -1;\n\n // A closing tag enters a nested structure while scanning backwards\n if (child.nesting === -1) {\n depth++;\n continue;\n }\n\n // An opening tag leaves it; bail out on unmatched ones\n if (child.nesting === 1 && --depth < 0) return -1;\n\n // Skip nested, non-text and whitespace-only children\n if (depth > 0 || child.type !== \"text\" || isWhitespaceOnly(child.content)) continue;\n\n return index;\n }\n\n return -1;\n };\n\n // Captured by the children test and reused by the transform, which always\n // runs right after a match, to avoid scanning the children twice\n let endOfBlockChildIndex = -1;\n\n /** End of {.block} */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: (children): DelimiterRange | false => {\n endOfBlockChildIndex = findEndOfBlockChild(children);\n\n return endOfBlockChildIndex === -1\n ? false\n : endDelimiterChecker(children[endOfBlockChildIndex].content);\n },\n },\n ],\n transform: (tokens, index, _, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![endOfBlockChildIndex];\n const attrStartIndex = range[0] - options.left.length;\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token of the innermost wrapper - its\n // closing token sits right after the inline token (unlike the softbreak\n // rule, this never climbs to an outer ancestor)\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createBlockInfoRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * Block tokens carrying attributes on their info line, e.g. containers from\n * `@mdit/plugin-container` or `markdown-it-container`\n *\n * ```md\n * ::: warning {.custom-class #custom-id}\n * content\n * :::\n * ```\n */\n return defineAttrRule({\n name: \"block info\",\n tests: [\n {\n shift: 0,\n type: (type): boolean => type !== \"fence\",\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.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\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 type: \"fence\",\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createHeadingRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /** ## end of {#heading} */\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.filter);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.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 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.filter);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /** _emphasis_{.with attrs=1} */\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createListRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const filter = options.filter;\n\n return [\n /** - Item {.a} */\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 - a list item always has an enclosing\n // list, so the scan cannot run past the start of the stream\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, filter);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /**\n * - Nested list\n *\n * - With double \\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, filter);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n\n /** - End of {.list-item} */\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, filter);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createSoftBreakRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\n /** Something with softbreak {.cls} */\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.filter,\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\n// List rules for definition lists (@mdit/plugin-dl): dd contents are wrapped\n// in (possibly hidden) paragraphs and no list_item_open exists, so neither the\n// standard list rules nor the end-of-block rule can target the dd or dl\nexport const createDlRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const filter = options.filter;\n\n return [\n /** : Definition \\n {.a} */\n defineAttrRule({\n name: \"dl softbreak\",\n tests: [\n {\n shift: -2,\n type: \"dd_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 dlOpenIndex = index - 2;\n\n // Find the definition list opening token - a dd always has an\n // enclosing dl, so the scan cannot run past the start of the stream\n while (tokens[dlOpenIndex - 1].type !== \"dl_open\") dlOpenIndex--;\n\n // Apply attributes to the definition list opening token\n addAttrs(tokens[dlOpenIndex - 1], token.content, range, filter);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /** {.a} in its own paragraph after a definition list */\n defineAttrRule({\n name: \"dl double softbreak\",\n tests: [\n {\n shift: 0,\n type: \"dl_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 definition list opening token\n addAttrs(openingToken, token.content, range, filter);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n\n /** : End of {.definition} */\n defineAttrRule({\n name: \"dl item end\",\n tests: [\n {\n // the dd's first paragraph: dd_open sits behind the paragraph_open\n shift: -2,\n type: \"dd_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 dd opening token - the end-of-block rule\n // cannot: its target is the paragraph, which is hidden in tight lists\n addAttrs(tokens[index - 2], content, range, filter);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createHrRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n const endDelimiterChecker = createDelimiterChecker(options, \"end\");\n\n return defineAttrRule({\n /** Horizontal rule --- {#id} */\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 (markerCode !== 45 /** - */ && markerCode !== 42 && markerCode !== 95 /** _ */)\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 const range = endDelimiterChecker(content);\n\n // attrs must directly follow the marker run, or the transform would drop the extra text\n return range !== false && range[0] - options.left.length === pos ? range : false;\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.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 filter = options.filter;\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, filter);\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} This rule processes attributes within table cell\n * 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, filter);\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: TokenWithColumnCount = tokens[currentIndex - 1];\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: TokenWithColumnCount = tokens[index + 2];\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 const tbodyOpenToken: TokenWithColumnCount = tokens[tbodyOpenIndex];\n\n // oxlint-disable-next-line no-warning-comments\n // FIXME: this is a workaround for markdown-it-multimd-table ONLY, which fails to\n // produce markdown-it compatible tokens without columnCount\n // Ref: https://github.com/redbug312/markdown-it-multimd-table/issues/81\n // const columnCount = tbodyOpenToken.meta!.columnCount!;\n const columnCount = tbodyOpenToken.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 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\";\n\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\n// List rules for task list plugins that wrap item contents in a label (e.g.\n// @mdit/plugin-tasklist): the trailing label closing token hides the attribute\n// text from the standard list rules\nexport const createTasklistRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const filter = options.filter;\n\n return [\n /** - Task \\n {.a} */\n defineAttrRule({\n name: \"tasklist 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: -3,\n type: \"softbreak\",\n },\n {\n position: -2,\n type: \"text\",\n content: createDelimiterChecker(options, \"only\"),\n },\n {\n position: -1,\n type: \"label_close\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // childIndex points at label_close - the attribute text sits before it\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex - 1];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token - a list item always has an enclosing\n // list, so the scan cannot run past the start of the stream\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, filter);\n\n // Remove the attribute tokens from inside the label\n childTokens.splice(childIndex - 2, 2);\n },\n }),\n\n /** - End of {.task-item} */\n defineAttrRule({\n name: \"tasklist 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: -2,\n type: \"text\",\n content: createDelimiterChecker(options, \"end\"),\n },\n {\n position: -1,\n type: \"label_close\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // childIndex points at label_close - the attribute text sits before it\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex - 1];\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, filter);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockEndRule } from \"./blockEnd.js\";\nimport { createBlockInfoRule } from \"./blockInfo.js\";\nimport { createDlRules } from \"./dl.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\";\nimport { createTasklistRules } from \"./tasklist.js\";\nimport type { AttrRule } from \"./types.js\";\n\nconst AVAILABLE_RULES: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"heading\",\n \"hr\",\n \"softbreak\",\n \"blockInfo\",\n \"blockEnd\",\n \"block\",\n];\n\n// Opt-in rules for third-party plugin interop - excluded from \"all\"\nconst EXTENSION_RULES = new Set<MarkdownItAttrRuleName>([\"dl\", \"tasklist\"]);\n\nexport const createRules = (\n md: MarkdownIt,\n options: Required<Omit<MarkdownItAttrsOptions, \"fenceAttrsOnPre\">>,\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) || EXTENSION_RULES.has(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(\"tasklist\")) rules.push(...createTasklistRules(md, options));\n if (enabledRules.includes(\"dl\")) rules.push(...createDlRules(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(\"blockInfo\")) rules.push(createBlockInfoRule(md, options));\n // `block` is the legacy alias of `blockEnd`\n if (enabledRules.includes(\"blockEnd\") || enabledRules.includes(\"block\"))\n rules.push(createBlockEndRule(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","/** Forked and modified from https://github.com/arve0/markdown-it-attrs/ */\n\nimport MarkdownIt from \"markdown-it\";\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { normalizeAllowed, 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\", fenceAttrsOnPre = true } = {},\n) => {\n const filter = normalizeAllowed(allowed);\n\n const rules = createRules(md, {\n left,\n right,\n allowed,\n filter,\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 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 const currentToken = tokens[index];\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\n\n // re-locate the current token in case the transform spliced tokens\n // before it (e.g. the table calculate rule removing covered cells)\n if (tokens[index] !== currentToken) index = tokens.indexOf(currentToken);\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 // Place fence attributes on <pre> instead of <code>, but only when enabled,\n // the fence rule is active, and no custom fence renderer is already present.\n if (fenceAttrsOnPre && rules.some(({ name }) => name === \"code-block\")) {\n const defaultFence = new MarkdownIt().renderer.rules.fence;\n const currentFence = md.renderer.rules.fence;\n const hasCustomFence = typeof currentFence === \"function\" && currentFence !== defaultFence;\n\n if (!hasCustomFence && typeof currentFence === \"function\") {\n const originalFence = currentFence;\n\n md.renderer.rules.fence = (tokens, idx, mdOptions, env, slf): string => {\n const token = tokens[idx];\n const savedAttrs = token.attrs ? token.attrs.slice() : null;\n\n // Temporarily clear attrs so the default renderer does not place them\n // on <code>.\n token.attrs = null;\n const result = originalFence(tokens, idx, mdOptions, env, slf);\n\n token.attrs = savedAttrs;\n\n if (!savedAttrs || savedAttrs.length === 0) return result;\n\n // Inject user attrs into the opening <pre> tag.\n return result.replace(\n /^<pre(?<char>[ >])/,\n (_, ch) => `<pre${slf.renderAttrs(token)}${ch}`,\n );\n };\n }\n }\n};\n"],"mappings":"2BAKA,MAAa,GAAoB,EAAiB,IAA2B,CAC3E,GAAI,EAAQ,WAAW,CAAK,IAAA,GAAoB,MAAO,GAEvD,IAAI,EAAc,EAElB,IAAK,IAAI,EAAI,EAAQ,EAAG,GAAK,GAAK,EAAQ,WAAW,CAAC,IAAA,GAAqB,IAAK,IAEhF,OAAO,EAAc,GAAM,CAC7B,EAGM,GAAiB,EAAiB,EAAc,IAA8B,CAClF,IAAM,EAAiB,EAAQ,QAAQ,EAAW,CAAI,EAEtD,GAAI,IAAmB,GAAI,MAAO,GAGlC,IAAM,EAAa,EAAQ,QAAQ,IAAK,CAAI,EAE5C,GAAI,IAAe,IAAM,EAAa,EAAgB,OAAO,EAE7D,IAA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AAQ,EAAK,EAAW,EAAK,CAAG,EAO7D,MALA,GAAM,MAAQ,EAEV,CAAC,GAAc,EAAW,SAAW,EAAU,EAG5C,EAAO,QACZ,sBACC,EAAG,IAAO,OAAO,EAAI,YAAY,CAAK,IAAI,GAC7C,CACF,CACF,CACF,CACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/helper/getDelimiterChecker.ts","../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getMatchingOpeningToken.ts","../src/helper/normalizeAllowed.ts","../src/utils.ts","../src/helper/testRule.ts","../src/parseAttrs.ts","../src/rules/types.ts","../src/rules/blockEnd.ts","../src/rules/blockInfo.ts","../src/rules/fence.ts","../src/rules/heading.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/dl.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/tasklist.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["import type { DelimiterChecker } from \"../rules/types.js\";\nimport { CLASS_MARKER, ESCAPE_MARKER, ID_MARKER, QUOTE_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\n\n// Check whether the character at the given index is a double quote that is not escaped\nexport const isUnescapedQuote = (content: string, index: number): boolean => {\n if (content.charCodeAt(index) !== QUOTE_MARKER) return false;\n\n let escapeCount = 0;\n\n for (let i = index - 1; i >= 0 && content.charCodeAt(i) === ESCAPE_MARKER; i--) escapeCount++;\n\n return escapeCount % 2 === 0;\n};\n\n// Find the first occurrence of the delimiter outside quoted values, starting at `from`\nconst findDelimiter = (content: string, from: number, delimiter: string): number => {\n const delimiterIndex = content.indexOf(delimiter, from);\n\n if (delimiterIndex === -1) return -1;\n\n // Fast path: without a quote before the delimiter it cannot be inside a quoted value\n const quoteIndex = content.indexOf('\"', from);\n\n if (quoteIndex === -1 || quoteIndex > delimiterIndex) return delimiterIndex;\n\n let insideQuotes = false;\n\n for (let index = from; index < content.length; index++) {\n if (isUnescapedQuote(content, index)) insideQuotes = !insideQuotes;\n else if (!insideQuotes && content.startsWith(delimiter, index)) return index;\n }\n\n return -1;\n};\n\n// Find the last occurrence of the left delimiter outside quoted values\nconst findLastLeftDelimiter = (content: string, left: string): number => {\n const leftIndex = content.lastIndexOf(left);\n\n if (leftIndex === -1) return -1;\n\n // Fast path: without a quote before the delimiter it cannot be inside a quoted value\n const quoteIndex = content.indexOf('\"');\n\n if (quoteIndex === -1 || quoteIndex > leftIndex) return leftIndex;\n\n let result = -1;\n let insideQuotes = false;\n\n for (let index = 0; index < content.length; index++) {\n if (isUnescapedQuote(content, index)) insideQuotes = !insideQuotes;\n else if (!insideQuotes && content.startsWith(left, index)) result = index;\n }\n\n return result;\n};\n\n/**\n * Get a function to check if a string matches the delimiter pattern 获取一个函数来检查字符串是否匹配分隔符模式\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 = findDelimiter(content, leftLength + 1, right);\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 = findLastLeftDelimiter(content, left);\n\n if (start === -1) return false;\n\n end = findDelimiter(content, start + leftLength + 1, right);\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 { DelimiterRange } from \"../rules/types.js\";\nimport {\n CLASS_MARKER,\n ID_MARKER,\n KEY_SEPARATOR,\n PAIR_SEPARATOR,\n QUOTE_MARKER,\n} from \"./constants.js\";\nimport { isUnescapedQuote } from \"./getDelimiterChecker.js\";\nimport type { Attr, AttrFilter } from \"./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 = (str: string, range: DelimiterRange, filter: AttrFilter | null): 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 (\n charCode === QUOTE_MARKER &&\n isUnescapedQuote(str, index) &&\n value === \"\" &&\n !valueInsideQuotes\n ) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && isUnescapedQuote(str, index) && 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 filter ? attrs.filter(([attrKey, attrValue]) => filter(attrKey, attrValue)) : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterRange } from \"../rules/types.js\";\nimport { getAttrs } from \"./getAttrs.js\";\nimport type { AttrFilter } from \"./types.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n filter: AttrFilter | null,\n): void => {\n if (!token) return;\n\n getAttrs(content, range, filter).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.attrSet(key, value);\n }\n }\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 // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token || 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","import type { AllowedAttrEntry, AllowedAttrs, AttrFilter } from \"./types.js\";\n\nconst isEntryArray = (allowed: AllowedAttrs): allowed is AllowedAttrEntry[] =>\n allowed.length > 0 && typeof allowed[0] === \"object\" && \"name\" in allowed[0];\n\nconst createValueFilter = (value: (string | RegExp)[] | undefined): ((val: string) => boolean) => {\n if (!value || value.length === 0) return (): boolean => true;\n\n const stringValues = new Set<string>();\n const regexValues: RegExp[] = [];\n\n for (const item of value) {\n if (item instanceof RegExp) regexValues.push(item);\n else stringValues.add(item);\n }\n\n const stringSize = stringValues.size;\n const regexLength = regexValues.length;\n\n return (val): boolean => {\n if (stringSize > 0 && stringValues.has(val)) return true;\n\n for (let i = 0; i < regexLength; i++) if (regexValues[i].test(val)) return true;\n\n return false;\n };\n};\n\n/**\n * Normalize allowed attributes config into a fast filter function.\n *\n * Pre-computes string sets for O(1) lookup and compiles regex patterns to avoid repeated instanceof\n * checks at filter time.\n *\n * @param allowed - Raw allowed attributes config\n * @returns Normalized filter function, or null if no filtering needed\n */\nexport const normalizeAllowed = (allowed: AllowedAttrs): AttrFilter | null => {\n if (allowed.length === 0) return null;\n\n // Simple format: (string | RegExp)[] — only filter by attribute name\n if (!isEntryArray(allowed)) {\n const stringNames = new Set<string>();\n const regexNames: RegExp[] = [];\n\n for (const item of allowed) {\n if (item instanceof RegExp) regexNames.push(item);\n else stringNames.add(item);\n }\n\n const stringNamesSize = stringNames.size;\n const regexNamesLength = regexNames.length;\n\n return (_name): boolean => {\n if (stringNamesSize > 0 && stringNames.has(_name)) return true;\n\n for (let i = 0; i < regexNamesLength; i++) if (regexNames[i].test(_name)) return true;\n\n return false;\n };\n }\n\n // Entry format: AllowedAttrEntry[]\n type ValueCheck = (value: string) => boolean;\n\n const stringEntries: [name: string, check: ValueCheck][] = [];\n const regexEntries: [name: RegExp, check: ValueCheck][] = [];\n\n for (const entry of allowed) {\n const valueFilter = createValueFilter(entry.value);\n\n if (entry.name instanceof RegExp) regexEntries.push([entry.name, valueFilter]);\n else stringEntries.push([entry.name, valueFilter]);\n }\n\n const stringEntriesLength = stringEntries.length;\n const regexEntriesLength = regexEntries.length;\n\n return (name, value): boolean => {\n // Check string names first (O(n) but n is usually small)\n for (let i = 0; i < stringEntriesLength; i++) {\n const [entryName, check] = stringEntries[i];\n\n if (entryName === name) return check(value);\n }\n\n // Then check regex names\n for (let i = 0; i < regexEntriesLength; i++) {\n const [entryName, check] = regexEntries[i];\n\n if (entryName.test(name)) return check(value);\n }\n\n return false;\n };\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 * @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] == 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 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 { Attr } from \"./helper/index.js\";\nimport { createDelimiterChecker, getAttrs, normalizeAllowed } from \"./helper/index.js\";\nimport type { ParseAttrsOptions } from \"./options.js\";\n\n/**\n * Parse attrs from a string containing a delimited attrs section\n *\n * 从包含分隔符属性部分的字符串中解析属性\n *\n * @example\n * parseAttrs(\"foo {.bar #baz data-a=b}\");\n * // [[\"class\", \"bar\"], [\"id\", \"baz\"], [\"data-a\", \"b\"]]\n *\n * @param content - Content to parse / 要解析的内容\n * @param options - Parse options / 解析选项\n * @returns Parsed attrs, or `null` when no valid attrs section is found / 解析出的属性,未找到有效属性部分时为\n * `null`\n */\nexport const parseAttrs = (\n content: string,\n { where = \"end\", left = \"{\", right = \"}\", allowed = [] }: ParseAttrsOptions = {},\n): Attr[] | null => {\n const filter = normalizeAllowed(allowed);\n const range = createDelimiterChecker({ left, right, allowed, filter }, where)(content);\n\n return range === false ? null : getAttrs(content, range, filter);\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, or a custom checker function which may return the\n * matched delimiter range. When the function returns a boolean instead, another test of the rule\n * must provide the delimiter range\n */\n children?: AttrRuleSet[] | ((children: Token[]) => DelimiterRange | boolean);\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 中查找匹配项 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens One of shift or position must be\n * 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 * @example\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createBlockEndRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n const isWhiteSpace = md.utils.isWhiteSpace;\n const endDelimiterChecker = createDelimiterChecker(options, \"end\");\n\n // Non-allocating whitespace-only check (markdown-it's whitespace set)\n const isWhitespaceOnly = (content: string): boolean => {\n for (let index = 0; index < content.length; index++)\n if (!isWhiteSpace(content.charCodeAt(index))) return false;\n\n return true;\n };\n\n // Find the last meaningful text child - the one end-of-block attributes live on - skipping\n // trailing whitespace-only text and balanced tag pairs (e.g. an appended permalink); returns -1\n // when inline code / math or an unmatched opening tag is found first\n const findEndOfBlockChild = (children: Token[]): number => {\n const lastIndex = children.length - 1;\n\n if (lastIndex >= 0) {\n const lastChild = children[lastIndex];\n\n // Fast path: no tokens were appended after the attribute text\n if (lastChild.type === \"text\" && !isWhitespaceOnly(lastChild.content)) return lastIndex;\n }\n\n let depth = 0;\n\n for (let index = lastIndex; index >= 0; index--) {\n const child = children[index];\n\n if (child.type === \"code_inline\" || child.type === \"math_inline\") return -1;\n\n // A closing tag enters a nested structure while scanning backwards\n if (child.nesting === -1) {\n depth++;\n continue;\n }\n\n // An opening tag leaves it; bail out on unmatched ones\n if (child.nesting === 1 && --depth < 0) return -1;\n\n // Skip nested, non-text and whitespace-only children\n if (depth > 0 || child.type !== \"text\" || isWhitespaceOnly(child.content)) continue;\n\n return index;\n }\n\n return -1;\n };\n\n // Captured by the children test and reused by the transform, which always\n // runs right after a match, to avoid scanning the children twice\n let endOfBlockChildIndex = -1;\n\n /** End of {.block} */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: (children): DelimiterRange | false => {\n endOfBlockChildIndex = findEndOfBlockChild(children);\n\n return endOfBlockChildIndex === -1\n ? false\n : endDelimiterChecker(children[endOfBlockChildIndex].content);\n },\n },\n ],\n transform: (tokens, index, _, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![endOfBlockChildIndex];\n const attrStartIndex = range[0] - options.left.length;\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token of the innermost wrapper - its\n // closing token sits right after the inline token (unlike the softbreak\n // rule, this never climbs to an outer ancestor)\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createBlockInfoRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * Block tokens carrying attributes on their info line, e.g. containers from\n * `@mdit/plugin-container` or `markdown-it-container`\n *\n * ```md\n * ::: warning {.custom-class #custom-id}\n * content\n * :::\n * ```\n */\n return defineAttrRule({\n name: \"block info\",\n tests: [\n {\n shift: 0,\n type: (type): boolean => type !== \"fence\",\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.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\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 type: \"fence\",\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createHeadingRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /** ## end of {#heading} */\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.filter);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.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 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.filter);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /** _emphasis_{.with attrs=1} */\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createListRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const filter = options.filter;\n\n return [\n /** - Item {.a} */\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 - a list item always has an enclosing\n // list, so the scan cannot run past the start of the stream\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, filter);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /**\n * - Nested list\n *\n * - With double \\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, filter);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n\n /** - End of {.list-item} */\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, filter);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createSoftBreakRule = (options: DelimiterConfig): AttrRule =>\n defineAttrRule({\n /** Something with softbreak {.cls} */\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.filter,\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\n// List rules for definition lists (@mdit/plugin-dl): dd contents are wrapped\n// in (possibly hidden) paragraphs and no list_item_open exists, so neither the\n// standard list rules nor the end-of-block rule can target the dd or dl\nexport const createDlRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const filter = options.filter;\n\n return [\n /** : Definition \\n {.a} */\n defineAttrRule({\n name: \"dl softbreak\",\n tests: [\n {\n shift: -2,\n type: \"dd_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 dlOpenIndex = index - 2;\n\n // Find the definition list opening token - a dd always has an\n // enclosing dl, so the scan cannot run past the start of the stream\n while (tokens[dlOpenIndex - 1].type !== \"dl_open\") dlOpenIndex--;\n\n // Apply attributes to the definition list opening token\n addAttrs(tokens[dlOpenIndex - 1], token.content, range, filter);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /** {.a} in its own paragraph after a definition list */\n defineAttrRule({\n name: \"dl double softbreak\",\n tests: [\n {\n shift: 0,\n type: \"dl_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 definition list opening token\n addAttrs(openingToken, token.content, range, filter);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n\n /** : End of {.definition} */\n defineAttrRule({\n name: \"dl item end\",\n tests: [\n {\n // the dd's first paragraph: dd_open sits behind the paragraph_open\n shift: -2,\n type: \"dd_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 dd opening token - the end-of-block rule\n // cannot: its target is the paragraph, which is hidden in tight lists\n addAttrs(tokens[index - 2], content, range, filter);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule, DelimiterRange } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\nexport const createHrRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n const endDelimiterChecker = createDelimiterChecker(options, \"end\");\n\n return defineAttrRule({\n /** Horizontal rule --- {#id} */\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 (markerCode !== 45 /** - */ && markerCode !== 42 && markerCode !== 95 /** _ */)\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 const range = endDelimiterChecker(content);\n\n // attrs must directly follow the marker run, or the transform would drop the extra text\n return range !== false && range[0] - options.left.length === pos ? range : false;\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.filter);\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 { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker, getMatchingOpeningToken } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.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 filter = options.filter;\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, filter);\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} This rule processes attributes within table cell\n * 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, filter);\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: TokenWithColumnCount = tokens[currentIndex - 1];\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: TokenWithColumnCount = tokens[index + 2];\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 const tbodyOpenToken: TokenWithColumnCount = tokens[tbodyOpenIndex];\n\n // oxlint-disable-next-line no-warning-comments\n // FIXME: this is a workaround for markdown-it-multimd-table ONLY, which fails to\n // produce markdown-it compatible tokens without columnCount\n // Ref: https://github.com/redbug312/markdown-it-multimd-table/issues/81\n // const columnCount = tbodyOpenToken.meta!.columnCount!;\n const columnCount = tbodyOpenToken.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 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\";\n\nimport type { DelimiterConfig } from \"../helper/index.js\";\nimport { addAttrs, createDelimiterChecker } from \"../helper/index.js\";\nimport type { AttrRule } from \"./types.js\";\nimport { defineAttrRule } from \"./types.js\";\n\n// List rules for task list plugins that wrap item contents in a label (e.g.\n// @mdit/plugin-tasklist): the trailing label closing token hides the attribute\n// text from the standard list rules\nexport const createTasklistRules = (md: MarkdownIt, options: DelimiterConfig): AttrRule[] => {\n const isSpace = md.utils.isSpace;\n const filter = options.filter;\n\n return [\n /** - Task \\n {.a} */\n defineAttrRule({\n name: \"tasklist 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: -3,\n type: \"softbreak\",\n },\n {\n position: -2,\n type: \"text\",\n content: createDelimiterChecker(options, \"only\"),\n },\n {\n position: -1,\n type: \"label_close\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // childIndex points at label_close - the attribute text sits before it\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex - 1];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token - a list item always has an enclosing\n // list, so the scan cannot run past the start of the stream\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, filter);\n\n // Remove the attribute tokens from inside the label\n childTokens.splice(childIndex - 2, 2);\n },\n }),\n\n /** - End of {.task-item} */\n defineAttrRule({\n name: \"tasklist 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: -2,\n type: \"text\",\n content: createDelimiterChecker(options, \"end\"),\n },\n {\n position: -1,\n type: \"label_close\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // childIndex points at label_close - the attribute text sits before it\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex - 1];\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, filter);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockEndRule } from \"./blockEnd.js\";\nimport { createBlockInfoRule } from \"./blockInfo.js\";\nimport { createDlRules } from \"./dl.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\";\nimport { createTasklistRules } from \"./tasklist.js\";\nimport type { AttrRule } from \"./types.js\";\n\nconst AVAILABLE_RULES: MarkdownItAttrRuleName[] = [\n \"fence\",\n \"inline\",\n \"table\",\n \"list\",\n \"heading\",\n \"hr\",\n \"softbreak\",\n \"blockInfo\",\n \"blockEnd\",\n \"block\",\n];\n\n// Opt-in rules for third-party plugin interop - excluded from \"all\"\nconst EXTENSION_RULES = new Set<MarkdownItAttrRuleName>([\"dl\", \"tasklist\"]);\n\nexport const createRules = (\n md: MarkdownIt,\n options: Required<Omit<MarkdownItAttrsOptions, \"fenceAttrsOnPre\">>,\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) || EXTENSION_RULES.has(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(\"tasklist\")) rules.push(...createTasklistRules(md, options));\n if (enabledRules.includes(\"dl\")) rules.push(...createDlRules(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(\"blockInfo\")) rules.push(createBlockInfoRule(md, options));\n // `block` is the legacy alias of `blockEnd`\n if (enabledRules.includes(\"blockEnd\") || enabledRules.includes(\"block\"))\n rules.push(createBlockEndRule(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","/** Forked and modified from https://github.com/arve0/markdown-it-attrs/ */\n\nimport MarkdownIt from \"markdown-it\";\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { normalizeAllowed, 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\", fenceAttrsOnPre = true } = {},\n) => {\n const filter = normalizeAllowed(allowed);\n\n const rules = createRules(md, {\n left,\n right,\n allowed,\n filter,\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 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 const currentToken = tokens[index];\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\n\n // re-locate the current token in case the transform spliced tokens\n // before it (e.g. the table calculate rule removing covered cells)\n if (tokens[index] !== currentToken) index = tokens.indexOf(currentToken);\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 // Place fence attributes on <pre> instead of <code>, but only when enabled,\n // the fence rule is active, and no custom fence renderer is already present.\n if (fenceAttrsOnPre && rules.some(({ name }) => name === \"code-block\")) {\n const defaultFence = new MarkdownIt().renderer.rules.fence;\n const currentFence = md.renderer.rules.fence;\n const hasCustomFence = typeof currentFence === \"function\" && currentFence !== defaultFence;\n\n if (!hasCustomFence && typeof currentFence === \"function\") {\n const originalFence = currentFence;\n\n md.renderer.rules.fence = (tokens, idx, mdOptions, env, slf): string => {\n const token = tokens[idx];\n const savedAttrs = token.attrs ? token.attrs.slice() : null;\n\n // Temporarily clear attrs so the default renderer does not place them\n // on <code>.\n token.attrs = null;\n const result = originalFence(tokens, idx, mdOptions, env, slf);\n\n token.attrs = savedAttrs;\n\n if (!savedAttrs || savedAttrs.length === 0) return result;\n\n // Inject user attrs into the opening <pre> tag.\n return result.replace(\n /^<pre(?<char>[ >])/,\n (_, ch) => `<pre${slf.renderAttrs(token)}${ch}`,\n );\n };\n }\n }\n};\n"],"mappings":"2BAKA,MAAa,GAAoB,EAAiB,IAA2B,CAC3E,GAAI,EAAQ,WAAW,CAAK,IAAA,GAAoB,MAAO,GAEvD,IAAI,EAAc,EAElB,IAAK,IAAI,EAAI,EAAQ,EAAG,GAAK,GAAK,EAAQ,WAAW,CAAC,IAAA,GAAqB,IAAK,IAEhF,OAAO,EAAc,GAAM,CAC7B,EAGM,GAAiB,EAAiB,EAAc,IAA8B,CAClF,IAAM,EAAiB,EAAQ,QAAQ,EAAW,CAAI,EAEtD,GAAI,IAAmB,GAAI,MAAO,GAGlC,IAAM,EAAa,EAAQ,QAAQ,IAAK,CAAI,EAE5C,GAAI,IAAe,IAAM,EAAa,EAAgB,OAAO,EAE7D,IAAI,EAAe,GAEnB,IAAK,IAAI,EAAQ,EAAM,EAAQ,EAAQ,OAAQ,IAC7C,GAAI,EAAiB,EAAS,CAAK,EAAG,EAAe,CAAC,OACjD,GAAI,CAAC,GAAgB,EAAQ,WAAW,EAAW,CAAK,EAAG,OAAO,EAGzE,MAAO,EACT,EAGM,GAAyB,EAAiB,IAAyB,CACvE,IAAM,EAAY,EAAQ,YAAY,CAAI,EAE1C,GAAI,IAAc,GAAI,MAAO,GAG7B,IAAM,EAAa,EAAQ,QAAQ,GAAG,EAEtC,GAAI,IAAe,IAAM,EAAa,EAAW,OAAO,EAExD,IAAI,EAAS,GACT,EAAe,GAEnB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAQ,OAAQ,IACtC,EAAiB,EAAS,CAAK,EAAG,EAAe,CAAC,EAC7C,CAAC,GAAgB,EAAQ,WAAW,EAAM,CAA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+ "version": "1.2.0",
4
4
  "description": "attrs plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "attrs",
@@ -50,9 +50,9 @@
50
50
  "devDependencies": {
51
51
  "@mdit/plugin-container": "1.0.2",
52
52
  "@mdit/plugin-dl": "1.0.3",
53
- "@mdit/plugin-figure": "1.1.0",
54
- "@mdit/plugin-katex": "1.0.2",
55
- "@mdit/plugin-mark": "2.0.1",
53
+ "@mdit/plugin-figure": "1.1.1",
54
+ "@mdit/plugin-katex": "1.0.3",
55
+ "@mdit/plugin-mark": "2.0.2",
56
56
  "@mdit/plugin-tasklist": "1.0.2",
57
57
  "markdown-it-multimd-table": "^4.2.3"
58
58
  },
@@ -67,5 +67,5 @@
67
67
  "engines": {
68
68
  "node": ">=22"
69
69
  },
70
- "gitHead": "cceb5959ee112d79b02790e3f45f7f025ef86c12"
70
+ "gitHead": "c147432d5291597ee3453759027ef74572d63c62"
71
71
  }