{"id":13449817,"url":"https://github.com/inokawa/remark-slate-transformer","last_synced_at":"2025-04-08T12:10:45.841Z","repository":{"id":38387308,"uuid":"299468533","full_name":"inokawa/remark-slate-transformer","owner":"inokawa","description":"remark plugin to transform remark syntax tree (mdast) to Slate document tree, and vice versa. Made for WYSIWYG markdown editor.","archived":false,"fork":false,"pushed_at":"2025-01-31T17:14:07.000Z","size":32867,"stargazers_count":109,"open_issues_count":15,"forks_count":23,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T11:05:54.181Z","etag":null,"topics":["markdown","mdast","react","remark","remark-plugin","slate","slatejs","unified","wysiwyg"],"latest_commit_sha":null,"homepage":"https://inokawa.github.io/remark-slate-transformer/","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/inokawa.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},"funding":{"github":["inokawa"]}},"created_at":"2020-09-29T01:01:05.000Z","updated_at":"2025-03-18T12:57:42.000Z","dependencies_parsed_at":"2023-02-12T04:16:02.158Z","dependency_job_id":"a798f2a4-cd9a-4899-8f38-ba82b9f52f5f","html_url":"https://github.com/inokawa/remark-slate-transformer","commit_stats":{"total_commits":421,"total_committers":7,"mean_commits":"60.142857142857146","dds":0.3586698337292161,"last_synced_commit":"ebf8e1909fce3535d514f6af57615d9746a1424a"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-slate-transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-slate-transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-slate-transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inokawa%2Fremark-slate-transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inokawa","download_url":"https://codeload.github.com/inokawa/remark-slate-transformer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247838445,"owners_count":21004580,"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":["markdown","mdast","react","remark","remark-plugin","slate","slatejs","unified","wysiwyg"],"created_at":"2024-07-31T06:00:57.698Z","updated_at":"2025-04-08T12:10:45.817Z","avatar_url":"https://github.com/inokawa.png","language":"TypeScript","funding_links":["https://github.com/sponsors/inokawa"],"categories":["Uncategorized","Running the update","TypeScript"],"sub_categories":["Uncategorized","By Popularity"],"readme":"# remark-slate-transformer\n\n![npm](https://img.shields.io/npm/v/remark-slate-transformer) ![npm](https://img.shields.io/npm/dw/remark-slate-transformer) ![check](https://github.com/inokawa/remark-slate-transformer/workflows/check/badge.svg) ![demo](https://github.com/inokawa/remark-slate-transformer/workflows/demo/badge.svg)\n\n[remark](https://github.com/remarkjs/remark) plugin to transform remark syntax tree ([mdast](https://github.com/syntax-tree/mdast)) to [Slate](https://github.com/ianstormtaylor/slate) document tree, and vice versa. Made for WYSIWYG markdown editor.\n\n[remark](https://github.com/remarkjs/remark) is popular markdown parser/serializer which data structure can be converted to what used in [rehype](https://github.com/rehypejs/rehype), [retext](https://github.com/retextjs/retext) and so on. [Slate](https://github.com/ianstormtaylor/slate) is fully customizable rich text editor built on [React](https://github.com/facebook/react). Connect both 2 worlds should be great...\n\n## Support\n\nThis plugin supports slate 0.50+.\nThe data structure is described [here](https://docs.slatejs.org/concepts/02-nodes).\nslate ~0.47.9 was supported until 0.8.1.\n\nAll nodes in [mdast](https://github.com/syntax-tree/mdast) syntax tree are supported, including nodes created with...\n\n- [remark-gfm](https://github.com/remarkjs/remark-gfm)\n- [remark-frontmatter](https://github.com/remarkjs/remark-frontmatter)\n- `math` and `inlineMath` from [remark-math](https://github.com/remarkjs/remark-math).\n\nAnd also have experimental support for [custom AST](https://github.com/inokawa/remark-slate-transformer#support-custom-ast).\n\n## Demo\n\nhttps://inokawa.github.io/remark-slate-transformer/\n\n## Install\n\n```sh\nnpm install remark-slate-transformer\n```\n\n### Supported unified versions\n\n| remark-slate-transformer | unified          |\n| ------------------------ | ---------------- |\n| \u003e=0.9.0                  | \u003e=11.0.0         |\n| \u003e=0.7.0 \u003c0.9.0           | \u003e=10.1.0 \u003c11.0.0 |\n| \u003e=0.5.0 \u003c0.7.0           | \u003e=10.0.0         |\n| \u003c0.5.0                   | \u003c10.0.0          |\n\n## Usage\n\n### Transform remark to slate\n\n```javascript\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport { remarkToSlate } from \"remark-slate-transformer\";\n\nconst processor = unified().use(markdown).use(remarkToSlate);\n\nconst text = \"# hello world\";\n\nconst value = processor.processSync(text).result;\nconsole.log(value);\n```\n\n### Transform slate to remark\n\n```javascript\nimport { unified } from \"unified\";\nimport stringify from \"remark-stringify\";\nimport { slateToRemark } from \"remark-slate-transformer\";\n\nconst processor = unified().use(stringify);\n\nconst value = ...; // value passed to slate editor\n\nconst ast = processor.runSync(slateToRemark(value));\nconst text = processor.stringify(ast);\nconsole.log(text);\n```\n\n### Support custom AST\n\n```js\nimport { unified } from \"unified\";\nimport markdown from \"remark-parse\";\nimport stringify from \"remark-stringify\";\nimport { remarkToSlate, slateToRemark } from \"remark-slate-transformer\";\n\nconst text = \"# hello world\";\nconst r2s = unified()\n  .use(markdown)\n  .use(remarkToSlate, {\n    // If you use TypeScript, install `@types/mdast` for autocomplete.\n    overrides: {\n      // This overrides `type: \"heading\"` builder of remarkToSlate\n      heading: (node, next) =\u003e ({\n        type: \"head\",\n        dep: node.depth,\n        // You have to call next if the node have children\n        children: next(node.children),\n      }),\n      // Unknown type from community plugins can be handled\n      foo: (node, next) =\u003e ({ type: \"foo\", value: node.bar }),\n    },\n  });\nconst value = r2s.processSync(text).result;\nconsole.log(value);\n\nconst s2r = unified().use(stringify);\nconst ast = s2r.runSync(\n  slateToRemark(value, {\n    overrides: {\n      head: (node, next) =\u003e ({\n        type: \"heading\",\n        depth: node.dep,\n        children: next(node.children),\n      }),\n      foo: (node, next) =\u003e ({ type: \"foo\", bar: node.value }),\n    },\n  })\n);\nconst text = s2r.stringify(ast);\nconsole.log(text);\n```\n\n### Utilities\n\nTransformer utilities `mdastToSlate` and `slateToMdast` are also exported for more fine-tuned control.\n\n## Contribute\n\nAll contributions are welcome.\nIf you find a problem, feel free to create an [issue](https://github.com/inokawa/remark-slate-transformer/issues) or a [PR](https://github.com/inokawa/remark-slate-transformer/pulls).\n\n### Making a Pull Request\n\n1. Fork this repo.\n2. Run `npm install`.\n3. Commit your fix.\n4. Add tests to cover the fix.\n5. Make a PR and confirm all the CI checks passed.\n\n## Related projects\n\n- [remark-docx](https://github.com/inokawa/remark-docx)\n- [remark-pdf](https://github.com/inokawa/remark-pdf)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finokawa%2Fremark-slate-transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finokawa%2Fremark-slate-transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finokawa%2Fremark-slate-transformer/lists"}