{"id":15013659,"url":"https://github.com/remcohaszing/rehype-mdx-code-props","last_synced_at":"2025-06-14T17:34:06.215Z","repository":{"id":171098339,"uuid":"647444371","full_name":"remcohaszing/rehype-mdx-code-props","owner":"remcohaszing","description":"A rehype MDX plugin for interpreting markdown code meta as props","archived":false,"fork":false,"pushed_at":"2024-06-21T15:47:01.000Z","size":890,"stargazers_count":42,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-14T08:41:22.746Z","etag":null,"topics":["hast","html","markdown","mdx","rehype","rehype-plugin","unified"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remcohaszing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-30T19:52:32.000Z","updated_at":"2025-04-13T20:39:22.000Z","dependencies_parsed_at":"2024-01-17T17:31:44.593Z","dependency_job_id":"bc5565e5-8266-411b-a8b1-7abb579f1527","html_url":"https://github.com/remcohaszing/rehype-mdx-code-props","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":"0.040000000000000036","last_synced_commit":"83c34155b7c12de00d43f6079a4ccf132f4477d2"},"previous_names":["remcohaszing/rehype-mdx-code-props"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/remcohaszing/rehype-mdx-code-props","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Frehype-mdx-code-props","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Frehype-mdx-code-props/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Frehype-mdx-code-props/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Frehype-mdx-code-props/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remcohaszing","download_url":"https://codeload.github.com/remcohaszing/rehype-mdx-code-props/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remcohaszing%2Frehype-mdx-code-props/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259855362,"owners_count":22922286,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hast","html","markdown","mdx","rehype","rehype-plugin","unified"],"created_at":"2024-09-24T19:44:37.438Z","updated_at":"2025-06-14T17:34:06.192Z","avatar_url":"https://github.com/remcohaszing.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rehype-mdx-code-props\n\n[![github actions](https://github.com/remcohaszing/rehype-mdx-code-props/actions/workflows/ci.yaml/badge.svg)](https://github.com/remcohaszing/rehype-mdx-code-props/actions/workflows/ci.yaml)\n[![codecov](https://codecov.io/gh/remcohaszing/rehype-mdx-code-props/branch/main/graph/badge.svg)](https://codecov.io/gh/remcohaszing/rehype-mdx-code-props)\n[![npm version](https://img.shields.io/npm/v/rehype-mdx-code-props)](https://www.npmjs.com/package/rehype-mdx-code-props)\n[![npm downloads](https://img.shields.io/npm/dm/rehype-mdx-code-props)](https://www.npmjs.com/package/rehype-mdx-code-props)\n\nA [rehype](https://github.com/rehypejs/rehype) [MDX](https://mdxjs.com) plugin for interpreting\nmarkdown code meta as props.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  - [`rehypeMdxCodeProps`](#rehypemdxcodeprops)\n- [Compatibility](#compatibility)\n- [License](#license)\n\n## Installation\n\n```sh\nnpm install rehype-mdx-code-props\n```\n\n## Usage\n\nThis plugin interprets markdown code block metadata as JSX props.\n\nFor example, given a file named `example.mdx` with the following content:\n\n````markdown\n```js copy filename=\"awesome.js\" onOpen={props.openDemo} {...props}\nconsole.log('Everything is awesome!')\n```\n````\n\nThe following script:\n\n```js\nimport { readFile } from 'node:fs/promises'\n\nimport { compile } from '@mdx-js/mdx'\nimport rehypeMdxCodeProps from 'rehype-mdx-code-props'\n\nconst { value } = await compile(await readFile('example.mdx'), {\n  jsx: true,\n  rehypePlugins: [rehypeMdxCodeProps]\n})\nconsole.log(value)\n```\n\nRoughly yields:\n\n```jsx\nexport default function MDXContent(props) {\n  return (\n    \u003cpre copy filename=\"awesome.js\" onOpen={props.openDemo} {...props}\u003e\n      \u003ccode className=\"language-js\"\u003e{\"console.log('Everything is awesome!');\\n\"}\u003c/code\u003e\n    \u003c/pre\u003e\n  )\n}\n```\n\nThe `\u003cpre /\u003e` element doesn’t support those custom props. Use custom\n[components](https://mdxjs.com/docs/using-mdx/#components) to give the props meaning.\n\n\u003e **Note** This plugin transforms the [`hast`](https://github.com/syntax-tree/hast) (HTML) nodes\n\u003e into JSX. After running this plugin, they can no longer be processed by other plugins. To combine\n\u003e it with other plugins, such as syntax highlighting plugins, `rehype-mdx-code-props` must run last.\n\n## API\n\nThis package has a default export `rehypeMdxCodeProps`.\n\n### `rehypeMdxCodeProps`\n\nAn MDX rehype plugin for transforming markdown code meta into JSX props.\n\n#### Options\n\n- `elementAttributeNameCase` (`'html' | 'react'`): The casing to use for attribute names. This\n  should match the `elementAttributeNameCase` value passed to MDX. (Default: `'react'`)\n- `tagName` (`'code' | 'pre'`): The tag name to add the attributes to. (Default: `'pre'`)\n\n## Compatibility\n\nThis plugin works with Node.js 16 or greater and MDX 3.\n\n## License\n\n[MIT](LICENSE.md) © [Remco Haszing](https://github.com/remcohaszing)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremcohaszing%2Frehype-mdx-code-props","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremcohaszing%2Frehype-mdx-code-props","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremcohaszing%2Frehype-mdx-code-props/lists"}