{"id":13838409,"url":"https://github.com/web-infra-dev/mdx-rs","last_synced_at":"2025-03-29T19:01:29.924Z","repository":{"id":148924111,"uuid":"617366495","full_name":"web-infra-dev/mdx-rs","owner":"web-infra-dev","description":"Rust MDX compilation binding for Rspress","archived":false,"fork":false,"pushed_at":"2025-01-15T08:17:31.000Z","size":433,"stargazers_count":104,"open_issues_count":15,"forks_count":16,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-27T04:39:15.418Z","etag":null,"topics":["hacktoberfest","markdown","mdx"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/web-infra-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-03-22T08:40:18.000Z","updated_at":"2025-03-25T21:45:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"67d00e39-95a2-486c-a945-e868cc5b76b1","html_url":"https://github.com/web-infra-dev/mdx-rs","commit_stats":null,"previous_names":["web-infra-dev/mdx-rs","web-infra-dev/mdx-rs-binding"],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-infra-dev%2Fmdx-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-infra-dev%2Fmdx-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-infra-dev%2Fmdx-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-infra-dev%2Fmdx-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-infra-dev","download_url":"https://codeload.github.com/web-infra-dev/mdx-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246230504,"owners_count":20744347,"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":["hacktoberfest","markdown","mdx"],"created_at":"2024-08-04T15:01:55.807Z","updated_at":"2025-03-29T19:01:29.882Z","avatar_url":"https://github.com/web-infra-dev.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# @rspress/mdx-rs\n\nThis is a Node.js binding for MDX compilation of [Rspress](https://rspress.dev) which is a modern documentation tool based on [Rspack](https://www.rspack.org/).\n\nIt can be 10x+ faster than compiler in pure JavaScript version.The [benchmark](./benches/index.mjs) result of `@rspress/mdx-rs` vs `@mdx-js/mdx` is as follows:\n\n| Tool            | Time Spend |\n| --------------- | ---------- |\n| @rspress/mdx-rs | 977 ms     |\n| @mdx-js/mdx     | 21300 ms   |\n\nWe forked [mdxjs-rs](https://github.com/wooorm/mdxjs-rs), the Rust version of mdx compiler and customize it for Rspress, adding the following features:\n\n| Crate                                                       | Description                                                                                                                                                                               |\n| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [mdx_rs_binding](./crates/binding)                          | 🔥 Add Node.js binding so that we can use it in Node.js.                                                                                                                                  |\n| [mdx_plugin_container](./crates/plugin_container)           | Implement container grammar like `:::tip` in [@rspress/plugin-container-syntax](https://github.com/web-infra-dev/rspress/blob/main/packages/plugin-container-syntax/src/remarkPlugin.ts). |\n| [mdx_plugin_toc](./crates/plugin_toc)                       | Generate table of contents.                                                                                                                                                               |\n| [mdx_plugin_frontmatter](./crates/plugin_frontmatter)       | Parse frontmatter and export it in the esm module.                                                                                                                                        |\n| [mdx_plugin_external_link](./crates/plugin_external_link)   | Add `target=\"_blank\"` and `rel=\"noopener noreferrer\"` to external link.                                                                                                                   |\n| [mdx_plugin_header_anchor](./crates/plugin_header_anchor)   | Add anchor for every header.                                                                                                                                                              |\n| [mdx_plugin_normalize_link](./crates/plugin_normalize_link) | Normalize link to complete url base on current filepath.                                                                                                                                  |\n| [mdx_plugin_html](./crates/plugin_html)                     | Serialize hast to html string                                                                                                                                                             |\n| [slugger](./crates/slugger)                                 | Generate slug for header, port from [github-slugger](https://github.com/Flet/github-slugger).                                                                                             |\n\n## Install\n\n```bash\n# npm\nnpm install @rspress/mdx-rs\n# yarn\nyarn add @rspress/mdx-rs\n# pnpm\npnpm install @rspress/mdx-rs\n```\n\n## Usage\n\n```js\nimport { compile } from \"@rspress/mdx-rs\";\n\nasync function main() {\n  const value = `\n  # Hello World\n\n  This is a demo of @rspress/mdx-rs\n  `;\n\n  const result = await compile({\n    // The mdx content\n    value,\n    // File path of the mdx file, the compiler will determine the different syntax(md/mdx) based on the file extension\n    filepath: \"xxx.mdx\",\n    // Whether to enable development mode, default is false\n    development: true,\n    // Current working directory, can be empty string\n    root: \"\",\n  });\n\n  console.log(result);\n}\n```\n\nOf course, you can also the `compileSync` function to compile mdx synchronously, which is not recommended because it will block the event loop and slow down the compile process.\n\n```js\nimport { compileSync } from \"@rspress/mdx-rs\";\n\nfunction main() {\n  const value = `\n  # Hello World\n\n  This is a demo of @rspress/mdx-rs\n  `;\n\n  const result = compileSync({\n    // The mdx content\n    value,\n    // File path of the mdx file, can be empty string\n    filepath: \"\",\n    // Whether to enable development mode, default is false\n    development: true,\n    // Current working directory, can be empty string\n    root: \"\",\n  });\n\n  console.log(result);\n}\n```\n\n## Credits\n\nThanks to [mdxjs-rs](https://github.com/wooorm/mdxjs-rs), the awesome Rust library authored by [wooorm](https://github.com/wooorm).\n\nAlso, thanks to [napi-rs](https://github.com/napi-rs/napi-rs), authored by [Brooooooklyn](https://github.com/Brooooooklyn), which is a great solution to help us build Node.js binding for Rust.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-infra-dev%2Fmdx-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-infra-dev%2Fmdx-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-infra-dev%2Fmdx-rs/lists"}