{"id":19501127,"url":"https://github.com/gitbookio/slate-hyperprint","last_synced_at":"2025-06-15T11:33:08.868Z","repository":{"id":27322894,"uuid":"110006499","full_name":"GitbookIO/slate-hyperprint","owner":"GitbookIO","description":"A library to convert Slate models to their slate-hyperscript representation","archived":false,"fork":false,"pushed_at":"2023-07-11T07:24:24.000Z","size":2345,"stargazers_count":24,"open_issues_count":23,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T05:04:32.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://GitbookIO.github.io/slate-hyperprint/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GitbookIO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-11-08T17:15:05.000Z","updated_at":"2023-07-25T14:12:41.000Z","dependencies_parsed_at":"2024-06-18T20:07:01.977Z","dependency_job_id":"73384f45-70d7-45fa-b7ac-3885e5fca53f","html_url":"https://github.com/GitbookIO/slate-hyperprint","commit_stats":{"total_commits":79,"total_committers":3,"mean_commits":"26.333333333333332","dds":"0.10126582278481011","last_synced_commit":"070504018077e1cac678d4547ad06ea4667d2a02"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitbookIO%2Fslate-hyperprint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitbookIO%2Fslate-hyperprint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitbookIO%2Fslate-hyperprint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GitbookIO%2Fslate-hyperprint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GitbookIO","download_url":"https://codeload.github.com/GitbookIO/slate-hyperprint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250912660,"owners_count":21506865,"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":[],"created_at":"2024-11-10T22:11:27.595Z","updated_at":"2025-04-25T23:30:55.314Z","avatar_url":"https://github.com/GitbookIO.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slate-hyperprint\n\n[![NPM version](https://badge.fury.io/js/slate-hyperprint.svg)](http://badge.fury.io/js/slate-hyperprint)\n\nA library to convert Slate models to their slate-hyperscript representation.\n\nYou can use `slate-hyperprint` as a library to:\n\n- Run a script to easily convert Slate tests written in Yaml/JSON to hyperscript.\n- Improve the output of unit tests by comparing hyperscript strings instead of JSON values.\n- Facilitate debugging and console logging of Slate values.\n\nSee the [online demo](https://soreine.github.io/slate-hyperprint), that converts a Slate JSON representation to a Slate hyperscript representation.\n\n# Setup\n\n```\nyarn add slate-hyperprint [--dev]\n```\n\n# Usage\n\n```js\nimport Slate from 'slate';\nimport hyperprint from 'slate-hyperprint';\n\nconsole.log(\n    hyperprint(\n        Slate.Value.create({\n            document: Slate.Document.create({\n                nodes: [\n                    Slate.Block.create({\n                        type: 'paragraph',\n                        data: { a: 1 },\n                        nodes: [\n                            Slate.Text.create('Hello')\n                        ]\n                    }\n                )]\n            })\n        })\n    )\n);\n// \u003cvalue\u003e\n//   \u003cdocument\u003e\n//     \u003cparagraph a={1}\u003e\n//       Hello\n//     \u003c/paragraph\u003e\n//   \u003c/document\u003e\n// \u003c/value\u003e\n\nhyperprint.log(...)\n// Equivalent to console.log(hyperprint(...))\n```\n\n# Options\n\n`slate-hyperprint` accepts an option object:\n\n```js\nhyperprint(value, options);\n```\n\n- `preserveKeys: boolean = false`\n  True to print node keys\n- `strict: boolean = false`\n  True to preserve empty texts and other things that the formatting would\n  otherwise omit. Useful when using hyperprint compare values in tests, because\n  the output is stricter.\n- `prettier: Object = { semi: false, singleQuote: true, tabWidth: 4 }`\n  Prettier config to use when formatting the output JSX.\n\n# Test\n\n```\nyarn run test\n```\n\n# Build\n\n```\nyarn run build\n```\n\n# CLI\n\nslate-hyperprint also export a command line interface tool that converts yaml files to jsx.\nWhen installed globally (`npm install slate-hyperprint --global`) it can be used like so:\n\n```\n$ slate-hyperprint document.yaml\n```\n\nIt will load the file, create a Slate document and print it to the console in jsx.\nNote: it will look for a `value.document`, `state.document` or `document` property.\nIt will consider the whole content as the document if none are found.\n\nYou can write the output to a file like so `slate-hyperprint input.yaml \u003e output.js`\n\nHere is a command to convert a whole bunch of yaml files in a test folder:\n\n```\n$ for file in tests/**/*.yaml; do basename=$(echo $file | sed 's/\\.yaml//'); slate-hyperprint $basename.yaml \u003e $basename.js; done;\n```\n\n# Thanks\n\nThe React equivalent [react-element-to-jsx-string](https://github.com/algolia/react-element-to-jsx-string) is and will remain a great source of inspiration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbookio%2Fslate-hyperprint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgitbookio%2Fslate-hyperprint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgitbookio%2Fslate-hyperprint/lists"}