@mdit/plugin-attrs 0.25.2 → 1.0.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.
@@ -1 +1 @@
1
- {"version":3,"file":"cdn.umd.js","names":[],"sources":["../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["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 type { Attr } 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 = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterRange } from \"../rules/types.js\";\nimport { getAttrs } from \"./getAttrs.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import type { DelimiterChecker } from \"../rules/types.js\";\nimport { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\n\n/**\n * Get a function to check if a string matches the delimiter pattern\n * 获取一个函数来检查字符串是否匹配分隔符模式\n *\n * @param options - Delimiter configuration / 分隔符配置\n * @param where - Position for matching: start, end, or only / 匹配位置:开始、结束或仅匹配\n * @returns A function that checks if content matches the delimiter pattern / 检查内容是否匹配分隔符模式的函数\n */\nexport const createDelimiterChecker = (\n options: DelimiterConfig,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where))\n throw new Error(`Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`);\n\n // Cache frequently used values\n const left = options.left;\n const right = options.right;\n const leftLength = left.length;\n const rightLength = right.length;\n const minContentLength = leftLength + 1 + rightLength;\n\n return (content) => {\n // Quick check for minimum length requirements\n if (typeof content !== \"string\" || content.length < minContentLength) return false;\n\n let start: number;\n let end: number;\n\n if (where === \"start\") {\n // Check if content starts with left delimiter\n if (!content.startsWith(left)) return false;\n\n start = leftLength;\n end = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): Token | null => {\n const token = tokens[index];\n\n // 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","/**\n * Get index item of array. Supports negative index, where -1 is last element in array.\n *\n * 获取数组中的索引项。支持负索引,其中 -1 是数组的最后一个元素。\n *\n * @param arr - Array to get item from / 要获取项的数组\n * @param index - Index of item / 项的索引\n * @returns Array item / 数组项\n */\nexport const getArrayItem = <Item>(arr: Item[], index: number): Item =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet } from \"../rules/types.js\";\nimport { getArrayItem } from \"../utils.js\";\n\nexport interface TestRuleResult {\n /** whether rule matches token stream */\n match: boolean;\n /** position of token */\n position: null | number;\n range: [start: number, end: number] | null;\n}\n\n/**\n * Test if rule matches token stream.\n *\n * @param tokens - token stream\n * @param index - current token index\n * @param rule - rule to test\n *\n * @returns test result\n */\nexport const testRule = (tokens: Token[], index: number, rule: AttrRuleSet): TestRuleResult => {\n const testResult: TestRuleResult = {\n match: false,\n position: null,\n range: null,\n };\n const isShift = typeof rule.shift === \"number\";\n\n const tokenIndex = isShift ? index + rule.shift : rule.position;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (isShift && tokenIndex < 0) return testResult;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token) return testResult;\n\n const ruleKeys = Object.keys(rule) as (keyof typeof rule)[];\n\n const ruleKeysLength = ruleKeys.length;\n\n for (let i = 0; i < ruleKeysLength; i++) {\n const key = ruleKeys[i];\n\n if (key === \"shift\" || key === \"position\") continue;\n\n // undefined and null are treated as non-existing keys\n // oxlint-disable-next-line eqeqeq, no-undefined\n if (token[key as keyof Token] == undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => typeof childTest.position === \"number\")) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth, typescript/strict-boolean-expressions\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\n\n // fall through for objects !== arrays of functions\n default: {\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer KeyType) | null\n ? KeyType | TestFunction<KeyType>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项\n * 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens\n * One of shift or position must be defined\n */\nexport type AttrRuleSet = ShiftAttrRuleSet | PositionAttrRuleSet;\n\nexport interface AttrRule {\n name: string;\n tests: AttrRuleSet[];\n transform: (tokens: Token[], index: number, childIndex: number, range: DelimiterRange) => void;\n}\n\n/**\n * Define an attribute rule helper\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n *\n * @example\n * ```ts\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n * ```\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 createBlockRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * end of {.block}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n return defineAttrRule({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: createDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 /**\n * ## end of {#heading}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: -1,\n type: \"heading_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { 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\n * not have a closing tag (nesting: -1)\n */\n defineAttrRule({\n name: \"inline nesting self-close\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n // oxlint-disable-next-line typescript/explicit-function-return-type\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n const targetToken = childTokens[childIndex - 1];\n const attrsEndIndex = options.right.length + range[1];\n\n // Apply attributes to the target token\n addAttrs(targetToken, token.content, range, options.allowed);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /**\n * *emphasis*{.with attrs=1}\n */\n defineAttrRule({\n name: \"inline attributes\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n nesting: -1, // closing inline tag, </em>{.a}\n },\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const currentToken = childTokens[childIndex];\n const { content } = currentToken;\n const attrsEndIndex = options.right.length + range[1];\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(childTokens, childIndex - 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 allowed = options.allowed;\n\n return [\n /**\n * - item\n * {.a}\n */\n defineAttrRule({\n name: \"list softbreak\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /**\n * - nested list\n * - with double \\n\n * {.a} <-- apply to nested ul\n *\n * {.b} <-- apply to root <ul>\n */\n defineAttrRule({\n name: \"list double softbreak\",\n tests: [\n {\n // let this token be i = 0 so that we can erase\n // the <p>{.a}</p> tokens below\n shift: 0,\n type: (type) => type === \"bullet_list_close\" || type === \"ordered_list_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: createDelimiterChecker(options, \"only\"),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, token.content, range, allowed);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n\n /**\n * - end of {.list-item}\n */\n defineAttrRule({\n name: \"list item end\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n type: \"text\",\n content: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const content = token.content;\n const attrStartIndex = range[0] - options.left.length;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the list item opening token\n addAttrs(tokens[index - 2], content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { 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 /**\n * something with softbreak\n * {.cls}\n */\n\n name: \"\\n{.a} softbreak then curly in start\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Apply attributes to the opening token\n addAttrs(\n getMatchingOpeningToken(tokens, closingTokenIndex),\n token.content,\n range,\n options.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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\n return defineAttrRule({\n /**\n * horizontal rule --- {#id}\n */\n name: \"horizontal rule\",\n tests: [\n {\n shift: 0,\n type: \"paragraph_open\",\n },\n {\n shift: 1,\n type: \"inline\",\n children: (children) => children.length === 1,\n content: (content): DelimiterRange | false => {\n let pos = 0;\n let charCode;\n const markerCode = content.charCodeAt(pos++);\n\n if (\n markerCode !== 45 /** - */ &&\n markerCode !== 42 /** * */ &&\n markerCode !== 95 /** _ */\n )\n return false;\n\n let count = 1;\n\n while (pos < content.length) {\n charCode = content.charCodeAt(pos++);\n if (charCode !== markerCode) break;\n\n count++;\n }\n\n if (count < 3) return false;\n\n if (!isSpace(content.charCodeAt(pos - 1))) pos--;\n\n return createDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { 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 allowed = options.allowed;\n\n return [\n defineAttrRule({\n /**\n * | h1 |\n * | -- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, allowed);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n /**\n * Handle table cell attributes: title {.class}\n * This rule processes attributes within table cell text content\n */\n defineAttrRule({\n name: \"table cell attributes\",\n tests: [\n {\n shift: -1,\n type: (type) => type === \"td_open\" || type === \"th_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find last attribute syntax in the content\n\n // Apply attributes to the table cell token\n addAttrs(cellOpenToken, content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\n /**\n * | A | B |\n * | -- | -- |\n * | 1 | 2 |\n *\n * | C | D |\n * | -- | -- |\n *\n * only `| A | B |` sets the columnCount metadata\n */\n name: \"table thead metadata\",\n tests: [\n {\n shift: 0,\n type: \"tr_close\",\n },\n {\n shift: 1,\n type: \"thead_close\",\n },\n {\n shift: 2,\n type: \"tbody_open\",\n },\n ],\n\n transform: (tokens, index): void => {\n const trOpenToken = getMatchingOpeningToken(tokens, index);\n const thCloseToken = tokens[index - 1];\n let columnCount = 0;\n let currentIndex = index - 1;\n\n // Find the matching tr_open token and count columns\n while (currentIndex > 0) {\n const currentToken = tokens[currentIndex];\n\n if (currentToken === trOpenToken) {\n const tHeadOpenToken = tokens[currentIndex - 1] as TokenWithColumnCount;\n\n tHeadOpenToken.meta = {\n ...tHeadOpenToken.meta,\n columnCount,\n };\n break;\n }\n\n // Count th_close tokens at the same level\n if (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\n\n currentIndex--;\n }\n\n // Apply metadata to tbody_open token\n const tbodyOpenToken = tokens[index + 2] as TokenWithColumnCount;\n\n tbodyOpenToken.meta = {\n ...tbodyOpenToken.meta,\n columnCount,\n };\n },\n }),\n defineAttrRule({\n /**\n * | A | B | C | D |\n * | -- | -- | -- | -- |\n * | 1 | 11 | 111 | 1111 {rowspan=3} |\n * | 2 {colspan=2 rowspan=2} | 22 | 222 | 2222 |\n * | 3 | 33 | 333 | 3333 |\n */\n name: \"table tbody calculate\",\n tests: [\n {\n shift: 0,\n type: \"tbody_close\",\n hidden: false,\n },\n ],\n transform: (tokens, index): void => {\n let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\")\n tbodyOpenIndex--;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta!.columnCount!;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockRule } from \"./block.js\";\nimport { createFenceRule } from \"./fence.js\";\nimport { createHeadingRule } from \"./heading.js\";\nimport { createHrRule } from \"./hr.js\";\nimport { createInlineRules } from \"./inline.js\";\nimport { createListRules } from \"./list.js\";\nimport { createSoftBreakRule } from \"./softbreak.js\";\nimport { createTableRules } from \"./table.js\";\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 \"block\",\n];\n\nexport const createRules = (\n md: MarkdownIt,\n options: Required<MarkdownItAttrsOptions>,\n): AttrRule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => AVAILABLE_RULES.includes(item))\n : AVAILABLE_RULES;\n\n const rules: AttrRule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(createFenceRule(md, options));\n if (enabledRules.includes(\"inline\")) rules.push(...createInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...createTableRules(md, options));\n if (enabledRules.includes(\"list\")) rules.push(...createListRules(md, options));\n if (enabledRules.includes(\"softbreak\")) rules.push(createSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(createHrRule(md, options));\n if (enabledRules.includes(\"block\")) rules.push(createBlockRule(md, options));\n // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(createHeadingRule(md, options));\n\n return rules;\n};\n","/**\n * Forked and modified from https://github.com/arve0/markdown-it-attrs/\n */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { testRule } from \"./helper/index.js\";\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport type { DelimiterRange } from \"./rules/index.js\";\nimport { createRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = createRules(md, {\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = (state) => {\n const tokens = state.tokens;\n\n for (let index = 0; index < tokens.length; index++) {\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n let range: DelimiterRange | null = null;\n\n // oxlint-disable-next-line no-loop-func\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position != null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting self-close\"\n ) {\n // retry,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
+ {"version":3,"file":"cdn.umd.js","names":[],"sources":["../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["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 type { Attr } 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 = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterRange } from \"../rules/types.js\";\nimport { getAttrs } from \"./getAttrs.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import type { DelimiterChecker } from \"../rules/types.js\";\nimport { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\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 = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): Token | null => {\n const token = tokens[index];\n\n // 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","/**\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 as keyof Token] == undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => typeof childTest.position === \"number\")) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth, typescript/strict-boolean-expressions\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\n\n // fall through for objects !== arrays of functions\n default: {\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer KeyType) | null\n ? KeyType | TestFunction<KeyType>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项 必须指定 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\";\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 createBlockRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /** End of {.block} */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 block: true,\n info: createDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { 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.allowed);\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.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 allowed = options.allowed;\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\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /**\n * - Nested list\n *\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, allowed);\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, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { 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.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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\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 return createDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { 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 allowed = options.allowed;\n\n return [\n defineAttrRule({\n /**\n * | h1 |\n * | --- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, allowed);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n /**\n * Handle table cell attributes: title {.class} 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, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\n /**\n * | A | B |\n * | --- | --- |\n * | 1 | 2 |\n *\n * | C | D |\n * | --- | --- |\n *\n * Only `| A | B |` sets the columnCount metadata\n */\n name: \"table thead metadata\",\n tests: [\n {\n shift: 0,\n type: \"tr_close\",\n },\n {\n shift: 1,\n type: \"thead_close\",\n },\n {\n shift: 2,\n type: \"tbody_open\",\n },\n ],\n\n transform: (tokens, index): void => {\n const trOpenToken = getMatchingOpeningToken(tokens, index);\n const thCloseToken = tokens[index - 1];\n let columnCount = 0;\n let currentIndex = index - 1;\n\n // Find the matching tr_open token and count columns\n while (currentIndex > 0) {\n const currentToken = tokens[currentIndex];\n\n if (currentToken === trOpenToken) {\n const tHeadOpenToken = tokens[currentIndex - 1] as TokenWithColumnCount;\n\n tHeadOpenToken.meta = {\n ...tHeadOpenToken.meta,\n columnCount,\n };\n break;\n }\n\n // Count th_close tokens at the same level\n if (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\n\n currentIndex--;\n }\n\n // Apply metadata to tbody_open token\n const tbodyOpenToken = tokens[index + 2] as TokenWithColumnCount;\n\n tbodyOpenToken.meta = {\n ...tbodyOpenToken.meta,\n columnCount,\n };\n },\n }),\n defineAttrRule({\n /**\n * | A | B | C | D |\n * | ----------------------- | --- | --- | ---------------- |\n * | 1 | 11 | 111 | 1111 {rowspan=3} |\n * | 2 {colspan=2 rowspan=2} | 22 | 222 | 2222 |\n * | 3 | 33 | 333 | 3333 |\n */\n name: \"table tbody calculate\",\n tests: [\n {\n shift: 0,\n type: \"tbody_close\",\n hidden: false,\n },\n ],\n transform: (tokens, index): void => {\n let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\")\n tbodyOpenIndex--;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta!.columnCount!;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockRule } from \"./block.js\";\nimport { createFenceRule } from \"./fence.js\";\nimport { createHeadingRule } from \"./heading.js\";\nimport { createHrRule } from \"./hr.js\";\nimport { createInlineRules } from \"./inline.js\";\nimport { createListRules } from \"./list.js\";\nimport { createSoftBreakRule } from \"./softbreak.js\";\nimport { createTableRules } from \"./table.js\";\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 \"block\",\n];\n\nexport const createRules = (\n md: MarkdownIt,\n options: Required<MarkdownItAttrsOptions>,\n): AttrRule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => AVAILABLE_RULES.includes(item))\n : AVAILABLE_RULES;\n\n const rules: AttrRule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(createFenceRule(md, options));\n if (enabledRules.includes(\"inline\")) rules.push(...createInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...createTableRules(md, options));\n if (enabledRules.includes(\"list\")) rules.push(...createListRules(md, options));\n if (enabledRules.includes(\"softbreak\")) rules.push(createSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(createHrRule(md, options));\n if (enabledRules.includes(\"block\")) rules.push(createBlockRule(md, options));\n // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(createHeadingRule(md, options));\n\n return rules;\n};\n","/** Forked and modified from https://github.com/arve0/markdown-it-attrs/ */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { testRule } from \"./helper/index.js\";\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport type { DelimiterRange } from \"./rules/index.js\";\nimport { createRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = createRules(md, {\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = (state) => {\n const tokens = state.tokens;\n\n for (let index = 0; index < tokens.length; index++) {\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n let range: DelimiterRange | null = null;\n\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position != null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting self-close\"\n ) {\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"mappings":"uRAUA,IAAM,EAAoB,GACxB,EAEI,IAAa,GACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa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,EAK3C,OAHI,EAAO,UAAY,OAAO,aAAe,GACzC,EAAO,QAAO,EAAQ,EAAO,OAE1B,EAAO,KAChB,CAEQ,IAEN,EAAQ,UAAU,EAAQ,EAAO,EAAW,CAAM,GAGhD,EAAQ,OAAS,qBACjB,EAAQ,OAAS,8BAGjB,IAGN,CAEJ,CAEkD,CACpD"}
package/dist/index.d.ts CHANGED
@@ -3,31 +3,29 @@ import { PluginWithOptions } from "markdown-it";
3
3
  //#region src/helper/types.d.ts
4
4
  interface DelimiterConfig {
5
5
  /**
6
- * left delimiter
6
+ * Left delimiter
7
7
  *
8
8
  * 左分隔符
9
9
  *
10
- * @default '{'
10
+ * @default "{"
11
11
  */
12
12
  left: string;
13
13
  /**
14
- * right delimiter
14
+ * Right delimiter
15
15
  *
16
16
  * 右分隔符
17
17
  *
18
- * @default '}'
18
+ * @default "}"
19
19
  */
20
20
  right: string;
21
21
  /**
22
- * allowed attributes
22
+ * Allowed attributes
23
23
  *
24
- * @description An empty list means allowing all attribute
24
+ * An empty list means allowing all attribute 允许的属性
25
25
  *
26
- * 允许的属性
26
+ * 设置空数组意味着允许所有属性
27
27
  *
28
- * @description 设置空数组意味着允许所有属性
29
- *
30
- * @default []
28
+ * @default [ ]
31
29
  */
32
30
  allowed: (string | RegExp)[];
33
31
  }
@@ -48,5 +46,5 @@ interface MarkdownItAttrsOptions extends Partial<DelimiterConfig> {
48
46
  //#region src/plugin.d.ts
49
47
  declare const attrs: PluginWithOptions<MarkdownItAttrsOptions>;
50
48
  //#endregion
51
- export { MarkdownItAttrRuleName, MarkdownItAttrsOptions, attrs };
49
+ export { type MarkdownItAttrRuleName, type MarkdownItAttrsOptions, attrs };
52
50
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["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 type { Attr } 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 = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterRange } from \"../rules/types.js\";\nimport { getAttrs } from \"./getAttrs.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import type { DelimiterChecker } from \"../rules/types.js\";\nimport { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\n\n/**\n * Get a function to check if a string matches the delimiter pattern\n * 获取一个函数来检查字符串是否匹配分隔符模式\n *\n * @param options - Delimiter configuration / 分隔符配置\n * @param where - Position for matching: start, end, or only / 匹配位置:开始、结束或仅匹配\n * @returns A function that checks if content matches the delimiter pattern / 检查内容是否匹配分隔符模式的函数\n */\nexport const createDelimiterChecker = (\n options: DelimiterConfig,\n where: \"start\" | \"end\" | \"only\",\n): DelimiterChecker => {\n if (![\"start\", \"end\", \"only\"].includes(where))\n throw new Error(`Invalid 'where' parameter: ${where}. Expected 'start', 'end', or 'only'.`);\n\n // Cache frequently used values\n const left = options.left;\n const right = options.right;\n const leftLength = left.length;\n const rightLength = right.length;\n const minContentLength = leftLength + 1 + rightLength;\n\n return (content) => {\n // Quick check for minimum length requirements\n if (typeof content !== \"string\" || content.length < minContentLength) return false;\n\n let start: number;\n let end: number;\n\n if (where === \"start\") {\n // Check if content starts with left delimiter\n if (!content.startsWith(left)) return false;\n\n start = leftLength;\n end = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): Token | null => {\n const token = tokens[index];\n\n // 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","/**\n * Get index item of array. Supports negative index, where -1 is last element in array.\n *\n * 获取数组中的索引项。支持负索引,其中 -1 是数组的最后一个元素。\n *\n * @param arr - Array to get item from / 要获取项的数组\n * @param index - Index of item / 项的索引\n * @returns Array item / 数组项\n */\nexport const getArrayItem = <Item>(arr: Item[], index: number): Item =>\n index >= 0 ? arr[index] : arr[arr.length + index];\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { AttrRuleSet } from \"../rules/types.js\";\nimport { getArrayItem } from \"../utils.js\";\n\nexport interface TestRuleResult {\n /** whether rule matches token stream */\n match: boolean;\n /** position of token */\n position: null | number;\n range: [start: number, end: number] | null;\n}\n\n/**\n * Test if rule matches token stream.\n *\n * @param tokens - token stream\n * @param index - current token index\n * @param rule - rule to test\n *\n * @returns test result\n */\nexport const testRule = (tokens: Token[], index: number, rule: AttrRuleSet): TestRuleResult => {\n const testResult: TestRuleResult = {\n match: false,\n position: null,\n range: null,\n };\n const isShift = typeof rule.shift === \"number\";\n\n const tokenIndex = isShift ? index + rule.shift : rule.position;\n\n // we should never shift to negative indexes (rolling around to back of array)\n if (isShift && tokenIndex < 0) return testResult;\n\n const token = getArrayItem(tokens, tokenIndex);\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token) return testResult;\n\n const ruleKeys = Object.keys(rule) as (keyof typeof rule)[];\n\n const ruleKeysLength = ruleKeys.length;\n\n for (let i = 0; i < ruleKeysLength; i++) {\n const key = ruleKeys[i];\n\n if (key === \"shift\" || key === \"position\") continue;\n\n // undefined and null are treated as non-existing keys\n // oxlint-disable-next-line eqeqeq, no-undefined\n if (token[key as keyof Token] == undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => typeof childTest.position === \"number\")) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth, typescript/strict-boolean-expressions\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\n\n // fall through for objects !== arrays of functions\n default: {\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer KeyType) | null\n ? KeyType | TestFunction<KeyType>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项\n * 必须指定 shift 或 position 中的一个\n *\n * Attribute rule set for defining how to find matches in tokens\n * One of shift or position must be defined\n */\nexport type AttrRuleSet = ShiftAttrRuleSet | PositionAttrRuleSet;\n\nexport interface AttrRule {\n name: string;\n tests: AttrRuleSet[];\n transform: (tokens: Token[], index: number, childIndex: number, range: DelimiterRange) => void;\n}\n\n/**\n * Define an attribute rule helper\n *\n * @param rule - Attribute rule definition / 属性规则定义\n * @returns Attribute rule passed through without modification / 未被修改的属性规则\n *\n * @example\n * ```ts\n * const rule = defineAttrRule({\n * name: \"example\",\n * tests: [],\n * transform(tokens, index, childIndex, range) {\n * // transform logic\n * },\n * });\n * ```\n */\nexport const defineAttrRule = (rule: AttrRule): AttrRule => rule;\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 createBlockRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /**\n * end of {.block}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 {.cls}\n * for i in range(10):\n * print(i)\n * ```\n */\n return defineAttrRule({\n name: \"code-block\",\n tests: [\n {\n shift: 0,\n block: true,\n info: createDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 /**\n * ## end of {#heading}\n */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: -1,\n type: \"heading_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, index + 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { 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\n * not have a closing tag (nesting: -1)\n */\n defineAttrRule({\n name: \"inline nesting self-close\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n // oxlint-disable-next-line typescript/explicit-function-return-type\n type: (str) => str === \"image\" || str === \"code_inline\",\n },\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n const targetToken = childTokens[childIndex - 1];\n const attrsEndIndex = options.right.length + range[1];\n\n // Apply attributes to the target token\n addAttrs(targetToken, token.content, range, options.allowed);\n\n if (token.content.length === attrsEndIndex) childTokens.splice(childIndex, 1);\n else token.content = token.content.slice(attrsEndIndex);\n },\n }),\n\n /**\n * *emphasis*{.with attrs=1}\n */\n defineAttrRule({\n name: \"inline attributes\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: -1,\n nesting: -1, // closing inline tag, </em>{.a}\n },\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"start\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const currentToken = childTokens[childIndex];\n const { content } = currentToken;\n const attrsEndIndex = options.right.length + range[1];\n\n // Find the corresponding opening token\n const openingToken = getMatchingOpeningToken(childTokens, childIndex - 1);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 allowed = options.allowed;\n\n return [\n /**\n * - item\n * {.a}\n */\n defineAttrRule({\n name: \"list softbreak\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n let listOpenIndex = index - 2;\n\n // Find the list opening token\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /**\n * - nested list\n * - with double \\n\n * {.a} <-- apply to nested ul\n *\n * {.b} <-- apply to root <ul>\n */\n defineAttrRule({\n name: \"list double softbreak\",\n tests: [\n {\n // let this token be i = 0 so that we can erase\n // the <p>{.a}</p> tokens below\n shift: 0,\n type: (type) => type === \"bullet_list_close\" || type === \"ordered_list_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: createDelimiterChecker(options, \"only\"),\n children: (children) => children.length === 1,\n },\n {\n shift: 3,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const openingToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, token.content, range, allowed);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n\n /**\n * - end of {.list-item}\n */\n defineAttrRule({\n name: \"list item end\",\n tests: [\n {\n shift: -2,\n type: \"list_item_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n type: \"text\",\n content: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const content = token.content;\n const attrStartIndex = range[0] - options.left.length;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the list item opening token\n addAttrs(tokens[index - 2], content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { 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 /**\n * something with softbreak\n * {.cls}\n */\n\n name: \"\\n{.a} softbreak then curly in start\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -2,\n type: \"softbreak\",\n },\n {\n position: -1,\n type: \"text\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const childTokens = tokens[index].children!;\n const token = childTokens[childIndex];\n\n // Find the last closing tag by searching forward\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Apply attributes to the opening token\n addAttrs(\n getMatchingOpeningToken(tokens, closingTokenIndex),\n token.content,\n range,\n options.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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\n return defineAttrRule({\n /**\n * horizontal rule --- {#id}\n */\n name: \"horizontal rule\",\n tests: [\n {\n shift: 0,\n type: \"paragraph_open\",\n },\n {\n shift: 1,\n type: \"inline\",\n children: (children) => children.length === 1,\n content: (content): DelimiterRange | false => {\n let pos = 0;\n let charCode;\n const markerCode = content.charCodeAt(pos++);\n\n if (\n markerCode !== 45 /** - */ &&\n markerCode !== 42 /** * */ &&\n markerCode !== 95 /** _ */\n )\n return false;\n\n let count = 1;\n\n while (pos < content.length) {\n charCode = content.charCodeAt(pos++);\n if (charCode !== markerCode) break;\n\n count++;\n }\n\n if (count < 3) return false;\n\n if (!isSpace(content.charCodeAt(pos - 1))) pos--;\n\n return createDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { 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 allowed = options.allowed;\n\n return [\n defineAttrRule({\n /**\n * | h1 |\n * | -- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, allowed);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n /**\n * Handle table cell attributes: title {.class}\n * This rule processes attributes within table cell text content\n */\n defineAttrRule({\n name: \"table cell attributes\",\n tests: [\n {\n shift: -1,\n type: (type) => type === \"td_open\" || type === \"th_open\",\n },\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n shift: 0,\n type: \"text\",\n content: createDelimiterChecker(options, \"end\"),\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const cellOpenToken = tokens[index - 1];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find last attribute syntax in the content\n\n // Apply attributes to the table cell token\n addAttrs(cellOpenToken, content, range, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\n /**\n * | A | B |\n * | -- | -- |\n * | 1 | 2 |\n *\n * | C | D |\n * | -- | -- |\n *\n * only `| A | B |` sets the columnCount metadata\n */\n name: \"table thead metadata\",\n tests: [\n {\n shift: 0,\n type: \"tr_close\",\n },\n {\n shift: 1,\n type: \"thead_close\",\n },\n {\n shift: 2,\n type: \"tbody_open\",\n },\n ],\n\n transform: (tokens, index): void => {\n const trOpenToken = getMatchingOpeningToken(tokens, index);\n const thCloseToken = tokens[index - 1];\n let columnCount = 0;\n let currentIndex = index - 1;\n\n // Find the matching tr_open token and count columns\n while (currentIndex > 0) {\n const currentToken = tokens[currentIndex];\n\n if (currentToken === trOpenToken) {\n const tHeadOpenToken = tokens[currentIndex - 1] as TokenWithColumnCount;\n\n tHeadOpenToken.meta = {\n ...tHeadOpenToken.meta,\n columnCount,\n };\n break;\n }\n\n // Count th_close tokens at the same level\n if (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\n\n currentIndex--;\n }\n\n // Apply metadata to tbody_open token\n const tbodyOpenToken = tokens[index + 2] as TokenWithColumnCount;\n\n tbodyOpenToken.meta = {\n ...tbodyOpenToken.meta,\n columnCount,\n };\n },\n }),\n defineAttrRule({\n /**\n * | A | B | C | D |\n * | -- | -- | -- | -- |\n * | 1 | 11 | 111 | 1111 {rowspan=3} |\n * | 2 {colspan=2 rowspan=2} | 22 | 222 | 2222 |\n * | 3 | 33 | 333 | 3333 |\n */\n name: \"table tbody calculate\",\n tests: [\n {\n shift: 0,\n type: \"tbody_close\",\n hidden: false,\n },\n ],\n transform: (tokens, index): void => {\n let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\")\n tbodyOpenIndex--;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta!.columnCount!;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockRule } from \"./block.js\";\nimport { createFenceRule } from \"./fence.js\";\nimport { createHeadingRule } from \"./heading.js\";\nimport { createHrRule } from \"./hr.js\";\nimport { createInlineRules } from \"./inline.js\";\nimport { createListRules } from \"./list.js\";\nimport { createSoftBreakRule } from \"./softbreak.js\";\nimport { createTableRules } from \"./table.js\";\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 \"block\",\n];\n\nexport const createRules = (\n md: MarkdownIt,\n options: Required<MarkdownItAttrsOptions>,\n): AttrRule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => AVAILABLE_RULES.includes(item))\n : AVAILABLE_RULES;\n\n const rules: AttrRule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(createFenceRule(md, options));\n if (enabledRules.includes(\"inline\")) rules.push(...createInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...createTableRules(md, options));\n if (enabledRules.includes(\"list\")) rules.push(...createListRules(md, options));\n if (enabledRules.includes(\"softbreak\")) rules.push(createSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(createHrRule(md, options));\n if (enabledRules.includes(\"block\")) rules.push(createBlockRule(md, options));\n // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(createHeadingRule(md, options));\n\n return rules;\n};\n","/**\n * Forked and modified from https://github.com/arve0/markdown-it-attrs/\n */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { testRule } from \"./helper/index.js\";\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport type { DelimiterRange } from \"./rules/index.js\";\nimport { createRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = createRules(md, {\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = (state) => {\n const tokens = state.tokens;\n\n for (let index = 0; index < tokens.length; index++) {\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n let range: DelimiterRange | null = null;\n\n // oxlint-disable-next-line no-loop-func\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position != null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting self-close\"\n ) {\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"mappings":"AAUA,MAAM,EAAoB,GACxB,EAEI,IAAa,GACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IAIN,GACX,EACA,EACA,IACW,CACX,IAAI,EAAM,G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KAAK,GAAG,EAAgB,EAAI,EAAQ,CAAC,CAC1E,EAAa,SAAS,YAAY,EAAE,EAAM,KAAK,EAAoB,EAAQ,CAAC,CAC5E,EAAa,SAAS,KAAK,EAAE,EAAM,KAAK,EAAa,EAAI,EAAQ,CAAC,CAClE,EAAa,SAAS,QAAQ,CAAE,EAAM,KAAK,EAAgB,EAAI,EAAQ,CAAC,CAEnE,EAAa,SAAS,UAAU,EAAE,EAAM,KAAK,EAAkB,EAAI,EAAQ,CAAC,CAE9E,GCrCI,GACX,EACA,CAAE,OAAO,IAAK,QAAQ,IAAK,UAAU,EAAE,CAAE,OAAO,OAAU,EAAE,GACzD,CACH,IAAM,EAAQ,EAAY,EAAI,CAC5B,OACA,QACA,UACA,OACD,CAAC,CAsCF,EAAG,KAAK,MAAM,OAAO,UAAW,QApCH,GAAU,CACrC,IAAM,EAAS,EAAM,OAErB,IAAK,IAAI,EAAQ,EAAG,EAAQ,EAAO,OAAQ,IACzC,IAAK,IAAI,EAAY,EAAG,EAAY,EAAM,OAAQ,IAAa,CAC7D,IAAM,EAAU,EAAM,GAElB,EAA0B,KAC1B,EAA+B,KAGrB,EAAQ,MAAM,MAAO,GAAS,CAC1C,IAAM,EAAS,EAAS,EAAQ,EAAO,EAAK,CAK5C,OAHI,EAAO,UAAY,OAAO,aAAe,GACzC,EAAO,QAAO,EAAQ,EAAO,OAE1B,EAAO,OACd,GAIA,EAAQ,UAAU,EAAQ,EAAO,EAAW,EAAO,EAGjD,EAAQ,OAAS,qBACjB,EAAQ,OAAS,8BAGjB,OAOyC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/helper/getAttrs.ts","../src/helper/addAttrs.ts","../src/helper/getDelimiterChecker.ts","../src/helper/getMatchingOpeningToken.ts","../src/utils.ts","../src/helper/testRule.ts","../src/rules/types.ts","../src/rules/block.ts","../src/rules/fence.ts","../src/rules/heading.ts","../src/rules/inline.ts","../src/rules/list.ts","../src/rules/softbreak.ts","../src/rules/hr.ts","../src/rules/table.ts","../src/rules/rules.ts","../src/plugin.ts"],"sourcesContent":["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 type { Attr } 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 = (\n str: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): Attr[] => {\n let key = \"\";\n let value = \"\";\n let parsingKey = true;\n let valueInsideQuotes = false;\n\n const attrs: Attr[] = [];\n\n // read inside marker\n // start + left delimiter length to avoid beginning marker\n // breaks when ending marker is found or end of string\n for (let index = range[0]; index < range[1]; index++) {\n const charCode = str.charCodeAt(index);\n\n // switch to reading value if equal sign\n if (charCode === KEY_SEPARATOR && parsingKey) {\n parsingKey = false;\n continue;\n }\n\n // {.class} {..css-module}\n if (charCode === CLASS_MARKER && key === \"\") {\n if (str.charCodeAt(index + 1) === CLASS_MARKER) {\n key = \"css-module\";\n index++;\n } else {\n key = \"class\";\n }\n\n parsingKey = false;\n continue;\n }\n\n // {#id}\n if (charCode === ID_MARKER && key === \"\") {\n key = \"id\";\n parsingKey = false;\n continue;\n }\n\n // {value=\"inside quotes\"}\n if (charCode === QUOTE_MARKER && value === \"\" && !valueInsideQuotes) {\n valueInsideQuotes = true;\n continue;\n }\n\n if (charCode === QUOTE_MARKER && valueInsideQuotes) {\n valueInsideQuotes = false;\n continue;\n }\n\n // read next key/value pair\n if (charCode === PAIR_SEPARATOR && !valueInsideQuotes) {\n if (key === \"\") {\n // beginning or ending space: { .red } vs {.red}\n continue;\n }\n\n attrs.push([key, value]);\n key = \"\";\n value = \"\";\n parsingKey = true;\n\n continue;\n }\n\n // continue if character not allowed\n if (parsingKey && !isAllowedKeyChar(charCode)) continue;\n\n // no other conditions met; append to key/value\n if (parsingKey) {\n key += String.fromCharCode(charCode);\n continue;\n }\n\n value += String.fromCharCode(charCode);\n }\n\n // append last key/value pair\n if (key !== \"\") attrs.push([key, value]);\n\n return allowed.length > 0\n ? attrs.filter(([attr]) =>\n allowed.some((item) => (item instanceof RegExp ? item.test(attr) : item === attr)),\n )\n : attrs;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { DelimiterRange } from \"../rules/types.js\";\nimport { getAttrs } from \"./getAttrs.js\";\n\nexport const addAttrs = (\n token: Token | null,\n content: string,\n range: DelimiterRange,\n allowed: (string | RegExp)[],\n): void => {\n if (!token) return;\n\n getAttrs(content, range, allowed).forEach(([key, value]) => {\n switch (key) {\n case \"class\": {\n token.attrJoin(\"class\", value);\n break;\n }\n case \"css-module\": {\n token.attrJoin(\"css-module\", value);\n break;\n }\n default: {\n token.attrPush([key, value]);\n }\n }\n });\n};\n","import type { DelimiterChecker } from \"../rules/types.js\";\nimport { CLASS_MARKER, ID_MARKER } from \"./constants.js\";\nimport type { DelimiterConfig } from \"./types.js\";\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 = content.indexOf(right, leftLength + 1);\n\n if (end === -1) return false;\n\n // Check if next character is not part of right delimiter\n const nextCharPos = end + rightLength;\n\n if (nextCharPos < content.length && right.includes(content.charAt(nextCharPos))) return false;\n } else if (where === \"end\") {\n // Check if content ends with right delimiter\n start = content.lastIndexOf(left);\n\n if (start === -1) return false;\n\n end = content.indexOf(right, start + leftLength + 1);\n start += leftLength;\n\n if (end === -1 || end + rightLength !== content.length) return false;\n } else {\n // Check if content is wrapped by delimiters ('{.a}')\n if (!content.startsWith(left) || !content.endsWith(right)) return false;\n\n start = leftLength;\n end = content.length - rightLength;\n }\n\n // Check if content between delimiters is valid\n const firstCharCode = content.charCodeAt(start);\n const length = end - start;\n\n const isValid =\n firstCharCode === CLASS_MARKER || firstCharCode === ID_MARKER ? length >= 2 : length >= 1;\n\n if (!isValid) return false;\n\n return [start, end];\n };\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\n\nexport const getMatchingOpeningToken = (tokens: Token[], index: number): Token | null => {\n const token = tokens[index];\n\n // 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","/**\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 as keyof Token] == undefined) return testResult;\n\n if (key === \"children\" && Array.isArray(rule.children)) {\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!token.children?.length) return testResult;\n\n const childTests = rule.children;\n const children = token.children;\n let match;\n let range: [start: number, end: number] | null = null;\n\n if (childTests.every((childTest) => typeof childTest.position === \"number\")) {\n // positions instead of shifts, do not loop all children\n match = childTests.every((childTest) => {\n const result = testRule(children, childTest.position, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n // get position of child\n const { position } = childTests[childTests.length - 1];\n\n testResult.position = position >= 0 ? position : children.length + position;\n\n // set pos data\n // oxlint-disable-next-line typescript/no-non-null-assertion\n testResult.range = range!;\n }\n } else {\n for (let childIndex = 0; childIndex < children.length; childIndex++) {\n // oxlint-disable-next-line no-loop-func\n match = childTests.every((childTest) => {\n const result = testRule(children, childIndex, childTest);\n\n if (!result.match) return false;\n\n if (result.range) range = result.range;\n\n return true;\n });\n\n if (match) {\n testResult.position = childIndex;\n // set pos data\n // oxlint-disable-next-line max-depth, typescript/strict-boolean-expressions\n if (range) testResult.range = range;\n\n // all tests passes. so the check is successful\n break;\n }\n }\n }\n\n if (match === false) return testResult;\n\n continue;\n }\n\n // oxlint-disable-next-line typescript/no-unsafe-assignment\n const ruleDetail = rule[key];\n\n switch (typeof ruleDetail) {\n case \"boolean\":\n case \"number\":\n case \"string\": {\n if (token[key] !== ruleDetail) return testResult;\n\n break;\n }\n\n case \"function\": {\n // oxlint-disable-next-line typescript/no-unsafe-call\n const result = ruleDetail(token[key]) as boolean | [start: number, end: number];\n\n // oxlint-disable-next-line typescript/strict-boolean-expressions\n if (!result) return testResult;\n\n if (Array.isArray(result)) testResult.range = result;\n\n break;\n }\n\n // fall through for objects !== arrays of functions\n default: {\n throw new Error(\n `Unknown type of pattern test (key: ${key}). Test should be of type boolean, number, string or function.`,\n );\n }\n }\n }\n\n // no tests returned false -> all tests returns true\n testResult.match = true;\n\n return testResult;\n};\n","import type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\n\nexport type DelimiterRange = [start: number, end: number];\nexport type TestFunction<Value = unknown> = (value: Value) => boolean;\nexport type DelimiterChecker = (content: string) => DelimiterRange | false;\n\n/**\n * Token 的属性测试函数映射,用于规则匹配\n *\n * Test function mapping for token properties used in rule matching\n */\nexport type TokenPropTest = {\n [Key in keyof Token]?: Key extends \"nesting\"\n ? Nesting | TestFunction<Nesting>\n : Key extends \"attrs\" | \"map\" | \"children\"\n ? never\n : Key extends \"content\" | \"info\"\n ? string | DelimiterChecker\n : Token[Key] extends (infer KeyType) | null\n ? KeyType | TestFunction<KeyType>\n : Token[Key] | TestFunction<Token[Key]>;\n};\n\n/**\n * 基础属性规则集接口,不包含定位属性\n *\n * Base attribute rule set interface without positioning properties\n */\ninterface BaseAttrRuleSet extends Omit<TokenPropTest, \"children\"> {\n /**\n * 子规则集合,用于递归匹配\n *\n * Child rule sets for recursive matching\n */\n children?: AttrRuleSet[] | TestFunction<Token[]>;\n}\n\n/**\n * 使用shift定位的规则集\n *\n * Rule set using shift for positioning\n */\ninterface ShiftAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 相对于当前位置的偏移量,用于查找目标 token\n *\n * Offset relative to current position to find target token\n */\n shift: number;\n\n /**\n * 绝对位置,可选\n *\n * Optional absolute position\n */\n position?: never;\n}\n\n/**\n * 使用position定位的规则集\n *\n * Rule set using position for positioning\n */\ninterface PositionAttrRuleSet extends BaseAttrRuleSet {\n /**\n * 绝对位置,用于在 tokens 数组中直接定位目标 token\n *\n * Absolute position to locate target token in tokens array\n */\n position: number;\n\n /**\n * 相对偏移量,可选\n *\n * Optional relative offset\n */\n shift?: never;\n}\n\n/**\n * 属性规则集,用于定义如何在 tokens 中查找匹配项 必须指定 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\";\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 createBlockRule = (md: MarkdownIt, options: DelimiterConfig): AttrRule => {\n const isSpace = md.utils.isSpace;\n\n /** End of {.block} */\n return defineAttrRule({\n name: \"end of block\",\n tests: [\n {\n shift: 0,\n type: \"inline\",\n children: [\n {\n position: -1,\n content: createDelimiterChecker(options, \"end\"),\n type: (type) => type !== \"code_inline\" && type !== \"math_inline\",\n },\n ],\n },\n ],\n transform: (tokens, index, childIndex, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const token = tokens[index].children![childIndex];\n const { content } = token;\n const hasTrailingSpace = isSpace(content.charCodeAt(attrStartIndex - 1));\n\n // Find the closing token by skipping all nested closing tokens\n let closingTokenIndex = index + 1;\n\n while (tokens[closingTokenIndex + 1]?.nesting === -1) closingTokenIndex++;\n\n // Get the corresponding opening token\n const openingToken = getMatchingOpeningToken(tokens, closingTokenIndex);\n\n // Apply attributes to the opening token\n addAttrs(openingToken, content, range, options.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 block: true,\n info: createDelimiterChecker(options, \"end\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const attrStartIndex = range[0] - options.left.length;\n const token = tokens[index];\n const { info } = token;\n const hasTrailingSpace = isSpace(info.charCodeAt(attrStartIndex - 1));\n\n // Apply attributes to the current token\n addAttrs(token, info, range, options.allowed);\n\n // Remove the attribute syntax from info\n token.info = info.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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.allowed);\n\n // Remove the attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n });\n};\n","import type { 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.allowed);\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.allowed);\n\n // Remove attribute syntax from content\n currentToken.content = content.slice(attrsEndIndex);\n },\n }),\n];\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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 allowed = options.allowed;\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\n while (\n tokens[listOpenIndex - 1]?.type !== \"ordered_list_open\" &&\n tokens[listOpenIndex - 1].type !== \"bullet_list_open\"\n )\n listOpenIndex--;\n\n // Apply attributes to the list opening token\n addAttrs(tokens[listOpenIndex - 1], token.content, range, allowed);\n\n // Remove the attribute tokens from children\n tokens[index].children = childTokens.slice(0, -2);\n },\n }),\n\n /**\n * - Nested list\n *\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, allowed);\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, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n ];\n};\n","import type { 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.allowed,\n );\n\n // Remove the softbreak and attribute tokens\n tokens[index].children = childTokens.slice(0, -2);\n },\n });\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { 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\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 return createDelimiterChecker(options, \"end\")(content);\n },\n },\n {\n shift: 2,\n type: \"paragraph_close\",\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index];\n // Extract attributes from the inline content\n const inlineToken = tokens[index + 1];\n const { content } = inlineToken;\n\n token.type = \"hr\";\n token.tag = \"hr\";\n token.nesting = 0;\n\n // Apply attributes to the hr token\n addAttrs(token, content, range, options.allowed);\n token.markup = content;\n\n // Remove the inline and closing paragraph tokens\n tokens.splice(index + 1, 2);\n },\n });\n};\n","import type MarkdownIt from \"markdown-it\";\nimport type Token from \"markdown-it/lib/token.mjs\";\n\nimport type { 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 allowed = options.allowed;\n\n return [\n defineAttrRule({\n /**\n * | h1 |\n * | --- |\n * | c1 |\n *\n * {.c}\n */\n name: \"table\",\n tests: [\n {\n // let this token be i, such that for-loop continues at\n // next token after tokens.splice\n shift: 0,\n type: \"table_close\",\n },\n {\n shift: 1,\n type: \"paragraph_open\",\n },\n {\n shift: 2,\n type: \"inline\",\n content: createDelimiterChecker(options, \"only\"),\n },\n ],\n transform: (tokens, index, _, range): void => {\n const token = tokens[index + 2];\n const tableOpeningToken = getMatchingOpeningToken(tokens, index);\n\n // Apply attributes to the table opening token\n addAttrs(tableOpeningToken, token.content, range, allowed);\n\n // Remove the paragraph tokens containing the attributes\n tokens.splice(index + 1, 3);\n },\n }),\n /**\n * Handle table cell attributes: title {.class} 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, allowed);\n\n // Remove attribute syntax from content\n token.content = content.slice(0, hasTrailingSpace ? attrStartIndex - 1 : attrStartIndex);\n },\n }),\n defineAttrRule({\n /**\n * | A | B |\n * | --- | --- |\n * | 1 | 2 |\n *\n * | C | D |\n * | --- | --- |\n *\n * Only `| A | B |` sets the columnCount metadata\n */\n name: \"table thead metadata\",\n tests: [\n {\n shift: 0,\n type: \"tr_close\",\n },\n {\n shift: 1,\n type: \"thead_close\",\n },\n {\n shift: 2,\n type: \"tbody_open\",\n },\n ],\n\n transform: (tokens, index): void => {\n const trOpenToken = getMatchingOpeningToken(tokens, index);\n const thCloseToken = tokens[index - 1];\n let columnCount = 0;\n let currentIndex = index - 1;\n\n // Find the matching tr_open token and count columns\n while (currentIndex > 0) {\n const currentToken = tokens[currentIndex];\n\n if (currentToken === trOpenToken) {\n const tHeadOpenToken = tokens[currentIndex - 1] as TokenWithColumnCount;\n\n tHeadOpenToken.meta = {\n ...tHeadOpenToken.meta,\n columnCount,\n };\n break;\n }\n\n // Count th_close tokens at the same level\n if (currentToken.level === thCloseToken.level && currentToken.type === thCloseToken.type)\n columnCount++;\n\n currentIndex--;\n }\n\n // Apply metadata to tbody_open token\n const tbodyOpenToken = tokens[index + 2] as TokenWithColumnCount;\n\n tbodyOpenToken.meta = {\n ...tbodyOpenToken.meta,\n columnCount,\n };\n },\n }),\n defineAttrRule({\n /**\n * | A | B | C | D |\n * | ----------------------- | --- | --- | ---------------- |\n * | 1 | 11 | 111 | 1111 {rowspan=3} |\n * | 2 {colspan=2 rowspan=2} | 22 | 222 | 2222 |\n * | 3 | 33 | 333 | 3333 |\n */\n name: \"table tbody calculate\",\n tests: [\n {\n shift: 0,\n type: \"tbody_close\",\n hidden: false,\n },\n ],\n transform: (tokens, index): void => {\n let tbodyOpenIndex = index - 2;\n\n while (tbodyOpenIndex >= 0 && tokens[tbodyOpenIndex].type !== \"tbody_open\")\n tbodyOpenIndex--;\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n const columnCount = (tokens[tbodyOpenIndex] as TokenWithColumnCount).meta!.columnCount!;\n\n if (columnCount < 2) return;\n\n const remainingCellRemovedByRowSpan = Array.from({\n length: columnCount,\n }).fill(0) as number[];\n const rangesToRemove: [start: number, end: number][] = [];\n\n let currentTokenIndex = tbodyOpenIndex + 1;\n\n while (currentTokenIndex < index) {\n // The current token should be tr_open\n const trOpenIndex = currentTokenIndex;\n // Find tr_close\n let trCloseIndex = trOpenIndex + 1;\n\n while (trCloseIndex < index && tokens[trCloseIndex].type !== \"tr_close\") trCloseIndex++;\n\n // Collect cell info\n const cells: [openIndex: number, closeIndex: number][] = [];\n\n let cellSearchIndex = trOpenIndex + 1;\n\n // if it's not tr_close, then it should be a td_open or th_open\n while (cellSearchIndex < trCloseIndex) {\n let closeIndex = cellSearchIndex + 1;\n\n // find the close token\n while (\n closeIndex < trCloseIndex &&\n tokens[closeIndex].type !== \"td_close\" &&\n tokens[closeIndex].type !== \"th_close\"\n )\n closeIndex++;\n\n cells.push([cellSearchIndex, closeIndex]);\n // move to next token\n cellSearchIndex = closeIndex + 1;\n }\n\n let cellIndex = 0;\n let colIndex = 0;\n\n while (colIndex < columnCount) {\n // skip cells removed by rowspan\n if (remainingCellRemovedByRowSpan[colIndex] > 0) {\n remainingCellRemovedByRowSpan[colIndex]--;\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n colIndex++;\n continue;\n }\n\n // get rowspan and colspan for current cell\n const cellOpenToken = tokens[cells[cellIndex][0]];\n const colspan = Number(cellOpenToken.attrGet(\"colspan\")) || 1;\n const rowspan = Number(cellOpenToken.attrGet(\"rowspan\")) || 1;\n\n cellIndex++;\n\n // Calculate real colspan based on availability\n let realColspan = 0;\n\n for (let colSpanIndex = 0; colSpanIndex < colspan; colSpanIndex++) {\n // colspan should not overflow table columns\n if (colIndex + colSpanIndex < columnCount) {\n // the column is not occupied by rowspan\n if (remainingCellRemovedByRowSpan[colIndex + colSpanIndex] === 0) realColspan++;\n else break;\n }\n }\n\n if (colspan > 1 && realColspan < colspan)\n cellOpenToken.attrSet(\"colspan\", String(realColspan));\n\n // Mark columns as occupied\n for (let i = 0; i < realColspan; i++)\n remainingCellRemovedByRowSpan[colIndex + i] = rowspan - 1;\n\n // Consume merged cells\n const cellsToMerge = realColspan - 1;\n\n if (cellsToMerge > 0) {\n for (let i = 0; i < cellsToMerge; i++) {\n rangesToRemove.push(cells[cellIndex]);\n cellIndex++;\n }\n }\n\n colIndex += realColspan;\n }\n\n // Move to next tr\n currentTokenIndex = trCloseIndex + 1;\n }\n\n // Remove tokens in reverse order\n rangesToRemove.sort((a, b) => b[0] - a[0]);\n for (const [start, end] of rangesToRemove) tokens.splice(start, end - start + 1);\n },\n }),\n ];\n};\n","import type MarkdownIt from \"markdown-it\";\n\nimport type { MarkdownItAttrRuleName, MarkdownItAttrsOptions } from \"../options.js\";\nimport { createBlockRule } from \"./block.js\";\nimport { createFenceRule } from \"./fence.js\";\nimport { createHeadingRule } from \"./heading.js\";\nimport { createHrRule } from \"./hr.js\";\nimport { createInlineRules } from \"./inline.js\";\nimport { createListRules } from \"./list.js\";\nimport { createSoftBreakRule } from \"./softbreak.js\";\nimport { createTableRules } from \"./table.js\";\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 \"block\",\n];\n\nexport const createRules = (\n md: MarkdownIt,\n options: Required<MarkdownItAttrsOptions>,\n): AttrRule[] => {\n const enabledRules =\n // disable\n options.rule === false\n ? []\n : Array.isArray(options.rule)\n ? // user specific rules\n options.rule.filter((item) => AVAILABLE_RULES.includes(item))\n : AVAILABLE_RULES;\n\n const rules: AttrRule[] = [];\n\n if (enabledRules.includes(\"fence\")) rules.push(createFenceRule(md, options));\n if (enabledRules.includes(\"inline\")) rules.push(...createInlineRules(options));\n if (enabledRules.includes(\"table\")) rules.push(...createTableRules(md, options));\n if (enabledRules.includes(\"list\")) rules.push(...createListRules(md, options));\n if (enabledRules.includes(\"softbreak\")) rules.push(createSoftBreakRule(options));\n if (enabledRules.includes(\"hr\")) rules.push(createHrRule(md, options));\n if (enabledRules.includes(\"block\")) rules.push(createBlockRule(md, options));\n // heading rule is fully covered by block rules\n else if (enabledRules.includes(\"heading\")) rules.push(createHeadingRule(md, options));\n\n return rules;\n};\n","/** Forked and modified from https://github.com/arve0/markdown-it-attrs/ */\n\nimport type { PluginWithOptions } from \"markdown-it\";\nimport type { RuleCore } from \"markdown-it/lib/parser_core.mjs\";\n\nimport { testRule } from \"./helper/index.js\";\nimport type { MarkdownItAttrsOptions } from \"./options.js\";\nimport type { DelimiterRange } from \"./rules/index.js\";\nimport { createRules } from \"./rules/index.js\";\n\nexport const attrs: PluginWithOptions<MarkdownItAttrsOptions> = (\n md,\n { left = \"{\", right = \"}\", allowed = [], rule = \"all\" } = {},\n) => {\n const rules = createRules(md, {\n left,\n right,\n allowed,\n rule,\n });\n\n const attrsRule: RuleCore = (state) => {\n const tokens = state.tokens;\n\n for (let index = 0; index < tokens.length; index++) {\n for (let ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) {\n const pattern = rules[ruleIndex];\n // position of child with offset 0\n let position: null | number = null;\n let range: DelimiterRange | null = null;\n\n const match = pattern.tests.every((test) => {\n const result = testRule(tokens, index, test);\n\n if (result.position != null) ({ position } = result);\n if (result.range) range = result.range;\n\n return result.match;\n });\n\n if (match) {\n // oxlint-disable-next-line typescript/no-non-null-assertion\n pattern.transform(tokens, index, position!, range!);\n\n if (\n pattern.name === \"inline attributes\" ||\n pattern.name === \"inline nesting self-close\"\n ) {\n // retry, may be several inline attributes\n ruleIndex--;\n }\n }\n }\n }\n };\n\n md.core.ruler.before(\"linkify\", \"attrs\", attrsRule);\n};\n"],"mappings":"AAUA,MAAM,EAAoB,GACxB,EAEI,IAAa,GACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IACb,IAAa,IAIN,GACX,EACA,EACA,IACW,CACX,IAAI,EAAM,GACN,EAAQ,GACR,EAAa,GACb,EAAoB,GAElB,EAAgB,CAAC,EAKvB,IAAK,IAAI,EAAQ,EAAM,GAAI,EAAQ,EAAM,GAAI,IAAS,CACpD,IAAM,EAAW,EAAI,WAAW,CAAK,EAGrC,GAAI,IAAA,IAA8B,EAAY,CAC5C,EAAa,GACb,QACF,CAGA,GAAI,IA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2
  "name": "@mdit/plugin-attrs",
3
- "version": "0.25.2",
3
+ "version": "1.0.0",
4
4
  "description": "attrs plugin for MarkdownIt",
5
5
  "keywords": [
6
6
  "attrs",
@@ -41,14 +41,15 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@types/markdown-it": "^14.1.2",
44
- "@mdit/helper": "0.23.2"
44
+ "@mdit/helper": "1.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@mdit/plugin-mark": "0.23.2",
48
- "@mdit/plugin-katex": "0.25.2"
47
+ "@mdit/plugin-katex": "1.0.0",
48
+ "@mdit/plugin-figure": "1.0.0",
49
+ "@mdit/plugin-mark": "1.0.0"
49
50
  },
50
51
  "peerDependencies": {
51
- "markdown-it": "^14.1.0"
52
+ "markdown-it": "^14.2.0"
52
53
  },
53
54
  "peerDependenciesMeta": {
54
55
  "markdown-it": {
@@ -56,10 +57,10 @@
56
57
  }
57
58
  },
58
59
  "engines": {
59
- "node": ">= 20"
60
+ "node": ">=22"
60
61
  },
61
62
  "scripts": {
62
- "build": "tsdown --config-loader unrun",
63
+ "build": "tsdown",
63
64
  "clean": "rimraf ./dist"
64
65
  }
65
66
  }