text
\n * ```\n * \n * ## `string`\n * \n * ```markdown\n * text\n * \n * ```\n * \n * ⇣⇣⇣⇣⇣⇣\n * \n * ```html\n *text
\n * ```\n * \n * ## attr\n * \n * ```markdown\n * text\n * \n * ```\n * ⇣⇣⇣⇣⇣⇣\n * ```html\n *text
\n * ```\n */\n properties: 'data' | 'string' | 'attr';\n}\n\nconst defaultOptions: RehypeAttrsOptions = {\n properties: 'data',\n}\n\nconst rehypeAttrs: Plugin<[RehypeAttrsOptions?], Root> = (options) => {\n const opts = { ...defaultOptions, ...options }\n return (tree) => {\n visit(tree, 'element', (node, index, parent) => {\n if (node.tagName === 'pre' && node && Array.isArray(node.children) && parent && Array.isArray(parent.children) && parent.children.length > 1) {\n const firstChild = node.children[0] as Element;\n if (firstChild && firstChild.tagName === 'code' && typeof index === 'number') {\n const child = prevChild(parent.children as Literal[], index);\n if (child) {\n const attr = getCommentObject(child);\n if (Object.keys(attr).length > 0) {\n node.properties = { ...node.properties, ...{ 'data-type': 'rehyp' } }\n firstChild.properties = propertiesHandle(firstChild.properties, attr, opts.properties) as Properties\n }\n }\n }\n }\n\n if (/^(em|strong|b|a|i|p|pre|kbd|blockquote|h(1|2|3|4|5|6)|code|table|img|del|ul|ol)$/.test(node.tagName) && parent && Array.isArray(parent.children) && typeof index === 'number') {\n const child = nextChild(parent.children, index)\n if (child) {\n const attr = getCommentObject(child as Comment)\n if (Object.keys(attr).length > 0) {\n node.properties = propertiesHandle(node.properties, attr, opts.properties) as Properties\n }\n }\n }\n });\n }\n}\n\n\nexport default rehypeAttrs\n","/**\n * @typedef {import('unist').Node} Node\n * @typedef {import('unist').Parent} Parent\n * @typedef {import('unist-util-is').Test} Test\n */\n\n/**\n * Options for unist util filter\n *\n * @typedef {Object} FilterOptions\n * @property {boolean} [cascade=true] Whether to drop parent nodes if they had children, but all their children were filtered out.\n */\n\nimport {convert} from 'unist-util-is'\n\nconst own = {}.hasOwnProperty\n\n/**\n * Create a new tree consisting of copies of all nodes that pass test.\n * The tree is walked in preorder (NLR), visiting the node itself, then its head, etc.\n *\n * @param tree Tree to filter.\n * @param options Configuration (optional).\n * @param test is-compatible test (such as a type).\n * @returns Given `tree` or `null` if it didn’t pass `test`.\n */\nexport const filter =\n /**\n * @type {(\n * (