{"id":16579095,"url":"https://github.com/craftzdog/react-codemirror-runmode","last_synced_at":"2025-04-30T22:14:16.985Z","repository":{"id":25741577,"uuid":"106373899","full_name":"craftzdog/react-codemirror-runmode","owner":"craftzdog","description":"Syntax highlighting for react, utilizing CodeMirror's parser","archived":false,"fork":false,"pushed_at":"2025-04-30T21:42:35.000Z","size":1409,"stargazers_count":35,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-30T22:14:11.990Z","etag":null,"topics":["codemirror","react","syntax"],"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/craftzdog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-10-10T05:53:08.000Z","updated_at":"2025-03-22T01:18:07.000Z","dependencies_parsed_at":"2023-01-14T03:19:28.693Z","dependency_job_id":"52cf45c1-92a8-4168-882c-3766e18fe6d8","html_url":"https://github.com/craftzdog/react-codemirror-runmode","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":0.4411764705882353,"last_synced_commit":"120b49b86bef1114ca5f27fd11bf35786bb3335f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-codemirror-runmode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-codemirror-runmode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-codemirror-runmode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/craftzdog%2Freact-codemirror-runmode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/craftzdog","download_url":"https://codeload.github.com/craftzdog/react-codemirror-runmode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251789618,"owners_count":21644086,"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":["codemirror","react","syntax"],"created_at":"2024-10-11T22:16:54.778Z","updated_at":"2025-04-30T22:14:16.966Z","avatar_url":"https://github.com/craftzdog.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-codemirror-runmode\n\nSyntax highlighter for React, using CodeMirror 6.\nIt automatically loads [the language metadata](https://github.com/codemirror/language-data) and dynamically loads language parser modules based on the specified language.\n\n## Installation\n\n```sh\nnpm install --save react-codemirror-runmode\n```\n\n## Usage\n\n```javascript\nimport { oneDarkHighlightStyle } from '@codemirror/theme-one-dark'\nimport { Highlighter } from 'react-codemirror-runmode'\nimport React from 'react'\nimport ReactDOM from 'react-dom/client'\n\nconst code = 'const x = 123'\n\nReactDOM.createRoot(document.getElementById('app')!).render(\n  \u003cHighlighter lang=\"js\" theme={oneDarkHighlightStyle}\u003e\n    {code}\n  \u003c/Highlighter\u003e\n)\n```\n\n## Theming\n\nYou can apply custom themes using CodeMirror's theme system. This component uses [`HighlightStyle`](https://codemirror.net/docs/ref#language.HighlightStyle) objects to apply styles, which you can customize or replace.\n\n## Reference\n\n### `Highlighter`\n\nProps:\n\n- `lang`: `string` - The name of the language\n- `theme`: [`Highlighter`](https://lezer.codemirror.net/docs/ref/#highlight.Highlighter) - The highlight style\n- `children`: `string` - The code to highlight\n\n### `highlightCode\u003cOutput\u003e(languageName, input, highlightStyle, callback): Promise\u003cOutput[]\u003e`\n\nParameters:\n\n- `languageName`: `string` - The name of the language\n- `input`: `string` - The code to highlight\n- `highlighter`: [`Highlighter`](https://lezer.codemirror.net/docs/ref/#highlight.Highlighter) - The highlight style\n- `callback`: `(text: string, style: string | null, from: number, to: number) =\u003e Output)` - A callback function that converts the parsed tokens\n\n### `getCodeParser(languageName, defaultLanguage?): Promise\u003cParser | null\u003e`\n\nParameters:\n\n- `languageName: string` - The name of the language\n- `defaultLanguage?: Language` - A fallback language (Optional)\n\n## License\n\nMIT License. Developed by Takuya Matsuyama \u003chi@craftz.dog\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Freact-codemirror-runmode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcraftzdog%2Freact-codemirror-runmode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcraftzdog%2Freact-codemirror-runmode/lists"}