{"id":13478237,"url":"https://github.com/wooorm/mdxjs-rs","last_synced_at":"2025-05-14T08:09:27.994Z","repository":{"id":61722771,"uuid":"554374380","full_name":"wooorm/mdxjs-rs","owner":"wooorm","description":"Compile MDX to JavaScript in Rust","archived":false,"fork":false,"pushed_at":"2025-05-08T07:17:10.000Z","size":346,"stargazers_count":466,"open_issues_count":2,"forks_count":15,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-08T07:38:35.930Z","etag":null,"topics":["commonmark","gfm","javascript","markdown","mdx","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/mdxjs/","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/wooorm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":"funding.yml","license":"license","code_of_conduct":".github/code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/support.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"wooorm"}},"created_at":"2022-10-19T17:53:13.000Z","updated_at":"2025-05-08T07:17:12.000Z","dependencies_parsed_at":"2022-10-20T12:15:12.566Z","dependency_job_id":"5143ba1d-f34f-4a54-ad12-1bfb62902bd2","html_url":"https://github.com/wooorm/mdxjs-rs","commit_stats":{"total_commits":151,"total_committers":6,"mean_commits":"25.166666666666668","dds":"0.22516556291390732","last_synced_commit":"ec13c46f51cd9a3a0d1e35d224e2a8104fa1e047"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fmdxjs-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fmdxjs-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fmdxjs-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooorm%2Fmdxjs-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wooorm","download_url":"https://codeload.github.com/wooorm/mdxjs-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"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":["commonmark","gfm","javascript","markdown","mdx","rust"],"created_at":"2024-07-31T16:01:54.448Z","updated_at":"2025-05-14T08:09:22.986Z","avatar_url":"https://github.com/wooorm.png","language":"Rust","funding_links":["https://github.com/sponsors/wooorm","https://opencollective.com/unified","https://github.com/sponsors/unifiedjs"],"categories":["Rust","Projects"],"sub_categories":[],"readme":"# mdxjs-rs\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![GitHub][repo-badge]][repo]\n[![docs.rs][docs-badge]][docs]\n[![crates.io][crate-badge]][crate]\n\nCompile MDX to JavaScript in Rust.\n\n## When should I use this?\n\nYou can use this crate when you’re dealing with the Rust language and want\nto compile MDX to JavaScript.\nTo parse the MDX format to a syntax tree, use [`markdown-rs`][markdown-rs] instead.\n\nThis project does not yet support plugins.\nTo benefit from the unified (remark and rehype) ecosystem, use\n[`@mdx-js/mdx`][mdx-js].\n\n## What is this?\n\nThis Rust crate works exactly like the npm package [`@mdx-js/mdx`][mdx-js].\nIt uses the Rust crates [`markdown-rs`][markdown-rs] and [SWC][] to deal with the\nmarkdown and JavaScript inside MDX.\n\n## Questions\n\n*   to learn MDX, see [`mdxjs.com`][mdx-site]\n*   for the API, see the [crate docs][docs]\n*   for questions, see [Discussions][chat]\n*   to help, see [contribute][] or [sponsor][] below\n\n## Contents\n\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n*   [Project](#project)\n    *   [Test](#test)\n    *   [Version](#version)\n    *   [Security](#security)\n    *   [Contribute](#contribute)\n    *   [Sponsor](#sponsor)\n    *   [Thanks](#thanks)\n*   [License](#license)\n\n## Install\n\nWith [Rust][] (rust edition 2018+, ±version 1.56+), install with `cargo`:\n\n```sh\ncargo add mdxjs\n```\n\n## Use\n\n```rs\nextern crate mdxjs;\n\nfn main() -\u003e Result\u003c(), markdown::message::Message\u003e {\n    println!(\n        \"{}\",\n        mdxjs::compile(\n            r###\"\nimport {Chart} from './snowfall.js'\nexport const year = 2018\n\n# Last year’s snowfall\n\nIn {year}, the snowfall was above average.\nIt was followed by a warm spring which caused\nflood conditions in many of the nearby rivers.\n\n\u003cChart year={year} color=\"#fcb32c\" /\u003e\n\"###,\n            \u0026Default::default()\n        )?\n    );\n\n    Ok(())\n}\n```\n\nYields (prettified):\n\n```javascript\nimport {Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs} from 'react/jsx-runtime'\nimport {Chart} from './snowfall.js'\nexport const year = 2018\n\nfunction _createMdxContent(props) {\n  const _components = Object.assign({h1: 'h1', p: 'p'}, props.components)\n  return _jsxs(_Fragment, {\n    children: [\n      _jsx(_components.h1, {children: 'Last year’s snowfall'}),\n      '\\n',\n      _jsxs(_components.p, {\n        children: [\n          'In ',\n          year,\n          ', the snowfall was above average.\\nIt was followed by a warm spring which caused\\nflood conditions in many of the nearby rivers.'\n        ]\n      }),\n      '\\n',\n      _jsx(Chart, {year: year, color: '#fcb32c'})\n    ]\n  })\n}\n\nfunction MDXContent(props = {}) {\n  const {wrapper: MDXLayout} = props.components || {}\n  return MDXLayout\n    ? _jsx(MDXLayout, Object.assign({}, props, {children: _jsx(_createMdxContent, props)}))\n    : _createMdxContent(props)\n}\n\nexport default MDXContent\n```\n\n## API\n\n`mdxjs-rs` exposes\n[`compile`](https://docs.rs/mdxjs/latest/mdxjs/fn.compile.html),\n[`JsxRuntime`](https://docs.rs/mdxjs/latest/mdxjs/enum.JsxRuntime.html),\n[`Options`](https://docs.rs/mdxjs/latest/mdxjs/struct.Options.html),\nand a few other structs and enums.\n\nSee the [crate docs][docs] for more info.\n\n## Project\n\n### Test\n\n`mdxjs-rs` is tested with a lot of tests.\nThese tests reach all branches in the code, which means that this project has\n100% code coverage.\n\nThe following bash scripts are useful when working on this project:\n\n*   run examples:\n    ```sh\n    RUST_BACKTRACE=1 cargo run --example lib\n    ```\n*   format:\n    ```sh\n    cargo fmt \u0026\u0026 cargo fix\n    ```\n*   lint:\n    ```sh\n    cargo fmt --check \u0026\u0026 cargo clippy --all-targets\n    ```\n*   test:\n    ```sh\n    RUST_BACKTRACE=1 cargo test\n    ```\n*   docs:\n    ```sh\n    cargo doc --document-private-items\n    ```\n\n### Version\n\n`mdxjs-rs` follows [SemVer](https://semver.org).\n\n### Security\n\nMDX is a programming language.\nIt is JavaScript.\nIt is not safe to let people you don’t trust write MDX.\n\n### Contribute\n\nSee [`contributing.md`][contributing] for ways to help.\nSee [`support.md`][support] for ways to get help.\nSee [`code-of-conduct.md`][coc] for how to communicate in and around this\nproject.\n\n### Sponsor\n\nSupport this effort and give back by sponsoring:\n\n*   [GitHub Sponsors](https://github.com/sponsors/wooorm)\n    (personal; monthly or one-time)\n*   [OpenCollective](https://opencollective.com/unified) or\n    [GitHub Sponsors](https://github.com/sponsors/unifiedjs)\n    (unified; monthly or one-time)\n\n### Thanks\n\nSpecial thanks go out to:\n\n*   [Vercel][] for funding the initial development\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n[build-badge]: https://github.com/wooorm/mdxjs-rs/workflows/main/badge.svg\n\n[build]: https://github.com/wooorm/mdxjs-rs/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/mdxjs-rs.svg\n\n[coverage]: https://codecov.io/github/wooorm/mdxjs-rs\n\n[repo-badge]: https://img.shields.io/badge/GitHub-wooorm%2Fmdxjs--rs-brightgreen\n\n[repo]: https://github.com/wooorm/mdxjs-rs\n\n[docs-badge]: https://img.shields.io/docsrs/mdxjs\n\n[docs]: https://docs.rs/mdxjs/\n\n[crate-badge]: https://img.shields.io/crates/v/mdxjs\n\n[crate]: https://crates.io/crates/mdxjs/\n\n[chat]: https://github.com/wooorm/mdxjs-rs/discussions\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[mdx-js]: https://mdxjs.com/packages/mdx/\n\n[mdx-site]: https://mdxjs.com\n\n[markdown-rs]: https://github.com/wooorm/markdown-rs\n\n[swc]: https://swc.rs\n\n[rust]: https://www.rust-lang.org\n\n[vercel]: https://vercel.com\n\n[contribute]: #contribute\n\n[sponsor]: #sponsor\n\n[contributing]: .github/contribute.md\n\n[support]: .github/support.md\n\n[coc]: .github/code-of-conduct.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fmdxjs-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooorm%2Fmdxjs-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooorm%2Fmdxjs-rs/lists"}