{"id":13449814,"url":"https://github.com/hanford/remark-slate","last_synced_at":"2025-04-13T00:48:16.212Z","repository":{"id":38462860,"uuid":"251180050","full_name":"hanford/remark-slate","owner":"hanford","description":"Remark plugin to compile Markdown as a slate 0.50+ compatible object.","archived":false,"fork":false,"pushed_at":"2024-06-14T09:16:56.000Z","size":1008,"stargazers_count":156,"open_issues_count":25,"forks_count":42,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T00:48:06.242Z","etag":null,"topics":["markdown","remark","remark-plugins","rte","slatejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanford.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-03-30T02:19:47.000Z","updated_at":"2025-02-19T08:09:11.000Z","dependencies_parsed_at":"2023-09-25T07:00:03.534Z","dependency_job_id":"e355b994-cd5f-406e-afb6-5bdb8af3822a","html_url":"https://github.com/hanford/remark-slate","commit_stats":{"total_commits":104,"total_committers":15,"mean_commits":6.933333333333334,"dds":"0.20192307692307687","last_synced_commit":"0f3fd218e3c732341e7f2e8e274d0dc567d2c420"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanford%2Fremark-slate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanford%2Fremark-slate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanford%2Fremark-slate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanford%2Fremark-slate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanford","download_url":"https://codeload.github.com/hanford/remark-slate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650437,"owners_count":21139672,"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","remark","remark-plugins","rte","slatejs"],"created_at":"2024-07-31T06:00:57.623Z","updated_at":"2025-04-13T00:48:16.174Z","avatar_url":"https://github.com/hanford.png","language":"TypeScript","funding_links":[],"categories":["Running the update"],"sub_categories":["By Popularity"],"readme":"# remark-slate\n\n\u003e Transform the contents of a slate 0.50+ editor into markdown and back again.\n\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\n[**remark**][remark] plugin to compile Markdown as a [Slate](https://www.slatejs.org/) 0.50+ compatible object.\n\n- [Slate ➡️ Markdown:](#slate-object-to-markdown)\n- [Markdown ➡️ Slate:](#markdown-to-slate-object)\n- [Miscellaneous](#miscellaneous)\n- [Local Development](#local-development)\n  - [`npm start` or `yarn start`](#npm-start-or-yarn-start)\n  - [`npm run build` or `yarn build`](#npm-run-build-or-yarn-build)\n  - [`npm test` or `yarn test`](#npm-test-or-yarn-test)\n- [License (MIT)](#license-mit)\n\n## Usage\n\n### Slate object to Markdown:\n\n`remark-slate` exports an opinionated `serialize` function that is meant to be invoked with a `slate 0.50+` state object and will transform the object into a markdown document.\n\n```js\nimport { serialize } from 'remark-slate';\n\nexport default ({ onChange }) =\u003e {\n  const [value, setValue] = useState(initialValue);\n\n  const handleChange = useCallback((nextValue) =\u003e {\n    setValue(nextValue);\n    // serialize slate state to a markdown string\n    onChange(value.map((v) =\u003e serialize(v)).join(''));\n  }, [onChange]);\n\n  return (\n    \u003cSlate editor={editor} value={value} onChange={handleChange}\u003e\n      \u003cEditable\n        renderElement={renderElement}\n        renderLeaf={renderLeaf}\n        placeholder=\"Enter some rich text…\"\n        ...\n      /\u003e\n      ...\n    \u003c/Slate\u003e\n  );\n};\n```\n\n### Markdown to Slate object:\n\nWhen deserializing from markdown to slate, this package is meant to be used with [remark-parse](https://github.com/remarkjs/remark/tree/master/packages/remark-parse) and [unified](https://github.com/unifiedjs/unified).\n\nOur JS looks something like this:\n\n```js\nimport fs from 'fs';\nimport unified from 'unified';\nimport markdown from 'remark-parse';\nimport slate from 'remark-slate';\n\nunified()\n  .use(markdown)\n  .use(slate)\n  .process(fs.readFileSync('example.md'), (err, file) =\u003e {\n    if (err) throw err;\n    console.log({ file });\n  });\n```\n\nAnd `example.md` looks like this:\n\n```markdown\n# Heading one\n\n## Heading two\n\n### Heading three\n\n#### Heading four\n\n##### Heading five\n\n###### Heading six\n\nNormal paragraph\n\n_italic text_\n\n**bold text**\n\n~~strike through text~~\n\n[hyperlink](https://jackhanford.com)\n\n\u003e A block quote.\n\n- bullet list item 1\n- bullet list item 2\n\n1. ordered list item 1\n1. ordered list item 2\n```\n\nResults in the following Slate object\n\n\u003cdetails\u003e\u003csummary\u003eReveal\u003c/summary\u003e\n\n```json\n[\n  {\n    \"type\": \"heading_one\",\n    \"children\": [\n      {\n        \"text\": \"Heading one\"\n      }\n    ]\n  },\n  {\n    \"type\": \"heading_two\",\n    \"children\": [\n      {\n        \"text\": \"Heading two\"\n      }\n    ]\n  },\n  {\n    \"type\": \"heading_three\",\n    \"children\": [\n      {\n        \"text\": \"Heading three\"\n      }\n    ]\n  },\n  {\n    \"type\": \"heading_four\",\n    \"children\": [\n      {\n        \"text\": \"Heading four\"\n      }\n    ]\n  },\n  {\n    \"type\": \"heading_five\",\n    \"children\": [\n      {\n        \"text\": \"Heading five\"\n      }\n    ]\n  },\n  {\n    \"type\": \"heading_six\",\n    \"children\": [\n      {\n        \"text\": \"Heading six\"\n      }\n    ]\n  },\n  {\n    \"type\": \"paragraph\",\n    \"children\": [\n      {\n        \"text\": \"Normal paragraph\"\n      }\n    ]\n  },\n  {\n    \"type\": \"paragraph\",\n    \"children\": [\n      {\n        \"text\": \"italic text\",\n        \"italic\": true\n      }\n    ]\n  },\n  {\n    \"type\": \"paragraph\",\n    \"children\": [\n      {\n        \"text\": \"bold text\",\n        \"italic\": true\n      }\n    ]\n  },\n  {\n    \"type\": \"paragraph\",\n    \"children\": [\n      {\n        \"text\": \"strike through text\",\n        \"strikeThrough\": true\n      }\n    ]\n  },\n  {\n    \"type\": \"paragraph\",\n    \"children\": [\n      {\n        \"type\": \"link\",\n        \"link\": \"https://jackhanford.com\",\n        \"children\": [\n          {\n            \"text\": \"hyperkink\"\n          }\n        ]\n      }\n    ]\n  },\n  {\n    \"type\": \"block_quote\",\n    \"children\": [\n      {\n        \"type\": \"paragraph\",\n        \"children\": [\n          {\n            \"text\": \"A block quote.\"\n          }\n        ]\n      }\n    ]\n  },\n  {\n    \"type\": \"ul_list\",\n    \"children\": [\n      {\n        \"type\": \"list_item\",\n        \"children\": [\n          {\n            \"type\": \"paragraph\",\n            \"children\": [\n              {\n                \"text\": \"bullet list item 1\"\n              }\n            ]\n          }\n        ]\n      },\n      {\n        \"type\": \"list_item\",\n        \"children\": [\n          {\n            \"type\": \"paragraph\",\n            \"children\": [\n              {\n                \"text\": \"bullet list item 2\"\n              }\n            ]\n          }\n        ]\n      }\n    ]\n  },\n  {\n    \"type\": \"ol_list\",\n    \"children\": [\n      {\n        \"type\": \"list_item\",\n        \"children\": [\n          {\n            \"type\": \"paragraph\",\n            \"children\": [\n              {\n                \"text\": \"ordered list item 1\"\n              }\n            ]\n          }\n        ]\n      },\n      {\n        \"type\": \"list_item\",\n        \"children\": [\n          {\n            \"type\": \"paragraph\",\n            \"children\": [\n              {\n                \"text\": \"ordered list item 2\"\n              }\n            ]\n          }\n        ]\n      }\n    ]\n  }\n]\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n### Miscellaneous\n\nremark-slate makes some assumptions around unordered and ordered lists, the package pairs nicely with [slate-edit-list](https://github.com/productboard/slate-edit-list#readme)\n\n## Local Development\n\nBelow is a list of commands you will probably find useful.\n\n### `npm start` or `yarn start`\n\nRuns the project in development/watch mode. The project will be rebuilt upon changes.\n\nYour library will be rebuilt if you make edits.\n\n### `npm run build` or `yarn build`\n\nBundles the package to the `dist` folder.\nThe package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).\n\n### `npm test` or `yarn test`\n\nRuns the test watcher (Jest) in an interactive mode.\nBy default, runs tests related to files changed since the last commit.\n\n## License (MIT)\n\n```\nWWWWWW||WWWWWW\n W W W||W W W\n      ||\n    ( OO )__________\n     /  |           \\\n    /o o|    MIT     \\\n    \\___/||_||__||_|| *\n         || ||  || ||\n        _||_|| _||_||\n       (__|__|(__|__|\n```\n\nCopyright © 2020-present [Jack Hanford](http://jackhanford.com), jackhanford@gmail.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\u003c!-- Definitions --\u003e\n\n[downloads-badge]: https://img.shields.io/npm/dm/remark-slate.svg\n[downloads]: https://www.npmjs.com/package/remark-slate\n[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-slate.svg\n[size]: https://bundlephobia.com/result?p=remark-slate\n[remark]: https://github.com/remarkjs/remark\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanford%2Fremark-slate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanford%2Fremark-slate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanford%2Fremark-slate/lists"}