{"_id":"hast-util-properties-to-mdx-jsx-attributes","_rev":"3-1f477b7b20e3a0fab075819a65a0f04c","name":"hast-util-properties-to-mdx-jsx-attributes","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"hast-util-properties-to-mdx-jsx-attributes","version":"1.0.0","keywords":["hast","mdx","rehype","unist"],"author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"license":"MIT","_id":"hast-util-properties-to-mdx-jsx-attributes@1.0.0","maintainers":[{"name":"remcohaszing","email":"remcohaszing@gmail.com"}],"homepage":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes#readme","bugs":{"url":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/issues"},"dist":{"shasum":"c40f9f07b74f9b323c1cf8dc14beb17d4d79d12c","tarball":"https://registry.npmjs.org/hast-util-properties-to-mdx-jsx-attributes/-/hast-util-properties-to-mdx-jsx-attributes-1.0.0.tgz","fileCount":8,"integrity":"sha512-MZEdAYiXC8wDBfntAc7syyWHbcg/X1h03DQ7IQ6MKagMttpYhnKqOZR/nia0657Dt2v2vuXB8YuKNExw0Fljew==","signatures":[{"sig":"MEUCIGR4K22G3OMO1syJnLwbefIxekCyXbqANNlbm2+8PkETAiEAnZCWKOT1zXW8YVkxCon4kMTHddSj/FwjH+GVjDVSH2c=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":20652},"type":"module","exports":"./dist/hast-util-properties-to-mdx-jsx-attributes.js","funding":"https://github.com/sponsors/remcohaszing","gitHead":"82aae7501029c4a6891d504ab64613d8b23d9136","scripts":{"test":"c8 node --enable-source-maps dist/hast-util-properties-to-mdx-jsx-attributes.test.js","prepack":"tsc --build","pretest":"tsc --build"},"_npmUser":{"name":"remcohaszing","email":"remcohaszing@gmail.com"},"repository":{"url":"git+https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes.git","type":"git"},"_npmVersion":"10.2.4","description":"Transform hast properties into mdxJsxAttribute nodes","directories":{},"sideEffects":false,"_nodeVersion":"20.11.1","dependencies":{"@types/hast":"^3.0.0","style-to-js":"^1.0.0","@types/estree":"^1.0.0","mdast-util-mdx-jsx":"^3.0.0","property-information":"^6.0.0","comma-separated-tokens":"^2.0.0","space-separated-tokens":"^2.0.0","estree-util-value-to-estree":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^9.0.0","eslint":"^8.0.0","prettier":"^3.0.0","remark-cli":"^11.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","unist-util-visit":"^5.0.0","eslint-config-remcohaszing":"^10.0.0","remark-preset-remcohaszing":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hast-util-properties-to-mdx-jsx-attributes_1.0.0_1711129091801_0.5884011681709649","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"hast-util-properties-to-mdx-jsx-attributes","version":"1.0.1","keywords":["hast","mdx","rehype","unist"],"author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"license":"MIT","_id":"hast-util-properties-to-mdx-jsx-attributes@1.0.1","maintainers":[{"name":"remcohaszing","email":"remcohaszing@gmail.com"}],"homepage":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes#readme","bugs":{"url":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/issues"},"dist":{"shasum":"ae5d73b6ae7b8f8000b4b59e9fa17b029fb4de91","tarball":"https://registry.npmjs.org/hast-util-properties-to-mdx-jsx-attributes/-/hast-util-properties-to-mdx-jsx-attributes-1.0.1.tgz","fileCount":8,"integrity":"sha512-ZzxhjHZ+gyxaPIFp/nuRpVL4GIFoqzfH6vNgjaA3CuUAV6XCxYwAQfRczrZRkgL6msi6DdOl+/QEduOdzszvbg==","signatures":[{"sig":"MEUCIQD6WdwoBTh0ZCseOywljuqqbbL8vH2cuxHwOkug+tSwlQIgGdzXF6clCEDCjcLBOL7EmJrAKSa9ZMLXUS9JMulpzQA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/hast-util-properties-to-mdx-jsx-attributes@1.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":20393},"type":"module","_from":"file:hast-util-properties-to-mdx-jsx-attributes-1.0.1.tgz","exports":"./dist/hast-util-properties-to-mdx-jsx-attributes.js","funding":"https://github.com/sponsors/remcohaszing","scripts":{"test":"c8 node --enable-source-maps dist/hast-util-properties-to-mdx-jsx-attributes.test.js","prepack":"tsc --build","pretest":"tsc --build"},"_npmUser":{"name":"remcohaszing","email":"remcohaszing@gmail.com"},"_resolved":"/home/runner/work/hast-util-properties-to-mdx-jsx-attributes/hast-util-properties-to-mdx-jsx-attributes/hast-util-properties-to-mdx-jsx-attributes-1.0.1.tgz","_integrity":"sha512-ZzxhjHZ+gyxaPIFp/nuRpVL4GIFoqzfH6vNgjaA3CuUAV6XCxYwAQfRczrZRkgL6msi6DdOl+/QEduOdzszvbg==","repository":{"url":"git+https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes.git","type":"git"},"_npmVersion":"10.8.2","description":"Transform hast properties into mdxJsxAttribute nodes","directories":{},"sideEffects":false,"_nodeVersion":"20.18.2","dependencies":{"@types/hast":"^3.0.0","style-to-js":"^1.0.0","@types/estree":"^1.0.0","mdast-util-mdx-jsx":"^3.0.0","property-information":"^7.0.0","comma-separated-tokens":"^2.0.0","space-separated-tokens":"^2.0.0","estree-util-value-to-estree":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^9.0.0","eslint":"^8.0.0","prettier":"^3.0.0","remark-cli":"^12.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","unist-util-visit":"^5.0.0","eslint-config-remcohaszing":"^10.0.0","remark-preset-remcohaszing":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hast-util-properties-to-mdx-jsx-attributes_1.0.1_1739973686977_0.5358091194804868","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"hast-util-properties-to-mdx-jsx-attributes","version":"1.1.1","description":"Transform hast properties into mdxJsxAttribute nodes","keywords":["hast","mdx","rehype","unist"],"homepage":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes#readme","bugs":{"url":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/issues"},"repository":{"type":"git","url":"git+https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes.git"},"funding":"https://github.com/sponsors/remcohaszing","license":"MIT","author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"sideEffects":false,"type":"module","exports":"./dist/hast-util-properties-to-mdx-jsx-attributes.js","scripts":{"prepack":"tsc --build","pretest":"tsc --build","test":"c8 node --enable-source-maps dist/hast-util-properties-to-mdx-jsx-attributes.test.js"},"dependencies":{"@types/estree":"^1.0.0","@types/hast":"^3.0.0","estree-util-value-to-estree":"^3.0.0","mdast-util-mdx-jsx":"^3.0.0","property-information":"^7.0.0","style-to-js":"^1.0.0"},"devDependencies":{"@remcohaszing/eslint":"^13.0.0","@types/node":"^25.0.0","c8":"^9.0.0","prettier":"^3.0.0","remark-cli":"^12.0.0","remark-preset-remcohaszing":"^3.0.0","typescript":"^5.0.0","unist-util-visit":"^5.0.0"},"_id":"hast-util-properties-to-mdx-jsx-attributes@1.1.1","_integrity":"sha512-MMrAoGgvhYULEqMB/r6AlcVz1D3Cyml/9cMB2NIqZsIsEJ+XEXPMqH0gjba8dVs9AnQUYvPReAS+OIYx4ip+Ug==","_resolved":"/home/runner/work/hast-util-properties-to-mdx-jsx-attributes/hast-util-properties-to-mdx-jsx-attributes/hast-util-properties-to-mdx-jsx-attributes-1.1.1.tgz","_from":"file:hast-util-properties-to-mdx-jsx-attributes-1.1.1.tgz","_nodeVersion":"24.13.1","_npmVersion":"11.8.0","dist":{"integrity":"sha512-MMrAoGgvhYULEqMB/r6AlcVz1D3Cyml/9cMB2NIqZsIsEJ+XEXPMqH0gjba8dVs9AnQUYvPReAS+OIYx4ip+Ug==","shasum":"b3f2a185650ea733dab932223ab0a871cedc6b6d","tarball":"https://registry.npmjs.org/hast-util-properties-to-mdx-jsx-attributes/-/hast-util-properties-to-mdx-jsx-attributes-1.1.1.tgz","fileCount":8,"unpackedSize":20019,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/hast-util-properties-to-mdx-jsx-attributes@1.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDo7oFdpXXQg3R2ZlJWL6B13hZt9xUUOYrY1K3tIqb0kwIhAN7SMHU7pMBWzsYwTHMjLDXXVwPEXotsoeChLnMpGDRD"}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:a801d122-ab56-486f-9b5e-704103403209"}},"directories":{},"maintainers":[{"name":"remcohaszing","email":"remcohaszing@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hast-util-properties-to-mdx-jsx-attributes_1.1.1_1772629196027_0.05350707444579483"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-22T17:38:11.800Z","modified":"2026-03-04T12:59:56.489Z","1.0.0":"2024-03-22T17:38:11.938Z","1.0.1":"2025-02-19T14:01:27.152Z","1.1.1":"2026-03-04T12:59:56.189Z"},"bugs":{"url":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/issues"},"author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"license":"MIT","homepage":"https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes#readme","keywords":["hast","mdx","rehype","unist"],"repository":{"type":"git","url":"git+https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes.git"},"description":"Transform hast properties into mdxJsxAttribute nodes","maintainers":[{"name":"remcohaszing","email":"remcohaszing@gmail.com"}],"readme":"# hast-util-properties-to-mdx-jsx-attributes\n\n[![github actions](https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/actions/workflows/ci.yaml/badge.svg)](https://github.com/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/actions/workflows/ci.yaml)\n[![codecov](https://codecov.io/gh/remcohaszing/hast-util-properties-to-mdx-jsx-attributes/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/hast-util-properties-to-mdx-jsx-attributes)\n[![npm version](https://img.shields.io/npm/v/hast-util-properties-to-mdx-jsx-attributes)](https://www.npmjs.com/package/hast-util-properties-to-mdx-jsx-attributes)\n[![npm downloads](https://img.shields.io/npm/dm/hast-util-properties-to-mdx-jsx-attributes)](https://www.npmjs.com/package/hast-util-properties-to-mdx-jsx-attributes)\n\nTransform [hast](https://github.com/syntax-tree/hast)\n[properties](https://github.com/syntax-tree/hast#properties) to a list of\n[`mdxJsxAttribute`](https://github.com/syntax-tree/mdast-util-mdx-jsx#mdxjsxattribute) nodes.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  - [`propertiesToMdxJsxAttributes(properties, options?)`](#propertiestomdxjsxattributesproperties-options)\n- [Compatibility](#compatibility)\n- [License](#license)\n\n## Installation\n\n```sh\nnpm install hast-util-properties-to-mdx-jsx-attributes\n```\n\n## Usage\n\n`propertiesToMdxJsxAttributes` takes [hast](https://github.com/syntax-tree/hast)\n[properties](https://github.com/syntax-tree/hast#properties), and transform them to a list of\n[`mdxJsxAttribute`](https://github.com/syntax-tree/mdast-util-mdx-jsx#mdxjsxattribute) nodes. This\nis useful when creating an MDX plugin where you want to enhance a hast element with JSX specific\nfeatures, but you don’t want to transform all child nodes.\n\nFor example, this plugin prefixes all `id` attributes on hast elements with the `id` prop passed to\nthe MDX document.\n\n```ts\nimport type { Root } from 'hast'\nimport type { Plugin } from 'unified'\n\nimport { propertiesToMdxJsxAttributes } from 'hast-util-properties-to-mdx-jsx-attributes'\nimport { visit } from 'unist-util-visit'\n\nconst rehypeMdxPrefixId: Plugin<[], Root> = () => (ast) => {\n  visit(ast, 'element', (element, index, parent) => {\n    let hasId = false\n    const replacement = {\n      type: 'mdxJsxFlowElement',\n      name: element.tagName,\n      attributes: propertiesToMdxJsxAttributes(element.properties, {\n        transform(name, value) {\n          hasId = true\n\n          return {\n            type: 'BinaryExpression',\n            operator: '+',\n            left: { type: 'Identifier', name: 'id' },\n            right: {\n              type: 'MemberExpression',\n              computed: false,\n              optional: false,\n              object: { type: 'Identifier', name: 'props' },\n              property: { type: 'Literal', value }\n            }\n          }\n        }\n      }),\n      children: element.children\n    }\n\n    if (hasId) {\n      parent!.children[index!] = replacement\n    }\n  })\n}\n\nexport default rehypeMdxPrefixId\n```\n\n## API\n\n### `propertiesToMdxJsxAttributes(properties, options?)`\n\nTransform [hast](https://github.com/syntax-tree/hast)\n[properties](https://github.com/syntax-tree/hast#properties) to a list of\n[`mdxJsxAttribute`](https://github.com/syntax-tree/mdast-util-mdx-jsx#mdxjsxattribute) nodes.\n\n#### Arguments\n\n- `properties` ([`Properties`](https://github.com/syntax-tree/hast#properties)) — The hast\n  properties to transform.\n- `options` (`object`) — Additional options to pass. The following options are supported:\n  - `elementAttributeNameCase` (`'html' | 'react'`) — The casing to use for attribute names. This\n    should match the `elementAttributeNameCase` option specified in the\n    [MDX options](https://mdxjs.com/packages/mdx/#processoroptions). (Default: `'react'`)\n  - `space` (`'html' | 'svg'`) — The space the hast properties are in. (Default: `'html'`)\n  - `transform` (`function`) — A function to transform an attribute value. The function gets called\n    with the name of the MDX JSX attribute that’s being generated, the value that would be used if\n    no transform function is passed, and the value as it was in the hast properties. It should\n    return an [ESTree](https://github.com/estree/estree) expression or string to represent the\n    value, or `null` or `undefined` to generate an attribute with no value.\n\n#### Returns\n\nThe hast properties as a list of\n[`mdxJsxAttribute`](https://github.com/syntax-tree/mdast-util-mdx-jsx#mdxjsxattribute) nodes.\n\n## Compatibility\n\nThis project is compatible with Node.js 16 or greater.\n\n## License\n\n[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)\n","readmeFilename":"README.md"}