{"id":18961678,"url":"https://github.com/trialanderrororg/rehype-notion","last_synced_at":"2026-04-01T16:30:17.153Z","repository":{"id":130692368,"uuid":"607887997","full_name":"TrialAndErrorOrg/rehype-notion","owner":"TrialAndErrorOrg","description":"Plugin for `rehype` to turn HTML into Notion blocks","archived":false,"fork":false,"pushed_at":"2023-03-14T22:30:09.000Z","size":38,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-01T04:52:45.033Z","etag":null,"topics":["abstract","ast","syntax","tree","unified"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TrialAndErrorOrg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/funding.yml","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":"tefkah"}},"created_at":"2023-02-28T21:58:24.000Z","updated_at":"2023-03-29T20:10:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"447960a9-5437-41ac-b321-efdd237e055d","html_url":"https://github.com/TrialAndErrorOrg/rehype-notion","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Frehype-notion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Frehype-notion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Frehype-notion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TrialAndErrorOrg%2Frehype-notion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TrialAndErrorOrg","download_url":"https://codeload.github.com/TrialAndErrorOrg/rehype-notion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239958283,"owners_count":19724925,"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":["abstract","ast","syntax","tree","unified"],"created_at":"2024-11-08T14:14:00.859Z","updated_at":"2026-04-01T16:30:17.113Z","avatar_url":"https://github.com/TrialAndErrorOrg.png","language":"TypeScript","funding_links":["https://github.com/sponsors/tefkah"],"categories":[],"sub_categories":[],"readme":"\u003e **Note**\n\u003e This repository is automatically generated from the [main parser monorepo](https://github.com/TrialAndErrorOrg/parsers). Please submit any issues or pull requests there.\n\n# rehype-notion\n\n[![npm version](https://badge.fury.io/js/rehype-notion.svg)](https://badge.fury.io/js/rehype-notion) [![npm downloads](https://img.shields.io/npm/dm/rehype-notion.svg)](https://www.npmjs.com/package/rehype-notion)\n\n[![npm version](https://img.shields.io/npm/v/rehype-notion.svg)](https://www.npmjs.com/package/rehype-notion)\n[![npm downloads](https://img.shields.io/npm/dm/rehype-notion.svg)](https://www.npmjs.com/package/rehype-notion)\n\nPlugin for `rehype` to turn HTML into Notion blocks\n\n## Contents\n\n*   [rehype-notion](#rehype-notion)\n    *   [Contents](#contents)\n    *   [What is this?](#what-is-this)\n    *   [When should I use this?](#when-should-i-use-this)\n    *   [Install](#install)\n    *   [Use](#use)\n    *   [API](#api)\n        *   [`default()`](#default)\n            *   [Signature](#signature)\n            *   [Parameters](#parameters)\n            *   [Returns](#returns)\n        *   [`Options`](#options)\n            *   [Properties](#properties)\n                *   [`hastToMdastOptions?`](#hasttomdastoptions)\n                *   [`markdownToNotionOptions?`](#markdowntonotionoptions)\n                *   [`mdastToMarkdownOptions?`](#mdasttomarkdownoptions)\n        *   [`Block`](#block)\n    *   [Security](#security)\n    *   [Related](#related)\n    *   [License](#license)\n\n## What is this?\n\nA compiler plugin for [rehype][rehype] that transforms a `[hast][hast]` syntax tree into Notion blocks.\n\n## When should I use this?\n\nYou want to convert HTML to Notion blocks but want control over the conversion process. If you just want to convert HTML to Notion blocks, you should use [html-to-notion-blocks][html-to-notion-blocks] instead.\n\n## Install\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install as\n\n```bash\npnpm add rehype-notion\n# or with yarn\n# yarn add rehype-notion\n# or with npm\n# npm install rehype-notion\n```\n\n## Use\n\n```ts\nimport { unified } from 'unified'\nimport rehypeParse from 'rehype-parse'\nimport rehypeNotion from 'rehype-notion'\n\nconst html = `\n  \u003ch1\u003eHeading\u003c/h1\u003e\n  \u003cp\u003eParagraph\u003c/p\u003e\n`\n\nconst notionBlocks = unified().use(rehypeParse).use(rehypeNotion).processSync(html).result\n\n// or with options and async\n\nconst vfile = await unified()\n  .use(parse)\n  .use(\n    rehypeNotion,\n    //  {\n    //    hastToMdastOptions: {...}\n    //    mdastToMarkdownOptions: {...}\n    //    markdownToNotionOptions: {...}\n    //  }\n  )\n  .process(html).result\n\nconst notionBlocks = vfile.result\n\nconsole.log(notionBlocks)\n// [\n//   {\n//     object: 'block',\n//     type: 'heading_1',\n//     heading_1: {\n//       rich_text: [\n//         {\n//           annotations: {\n//             bold: false,\n//             italic: false,\n//             strikethrough: false,\n//             underline: false,\n//             code: false,\n//             color: 'default'\n//           },\n//           text: {\n//             content: 'Heading',\n//             link: null\n//           }\n//           type: 'text',\n//         }\n//       ]\n//     }\n//   },\n//   {\n//     object: 'block',\n//     type: 'paragraph',\n//     paragraph: {\n//       rich_text: [\n//         {\n//           annotations: {\n//             bold: false,\n//             italic: false,\n//             strikethrough: false,\n//             underline: false,\n//             code: false,\n//             color: 'default'\n//           },\n//           text: {\n//             content: 'Paragraph',\n//             link: null\n//           }\n//           type: 'text'\n//         }\n//       ]\n//     }\n//   }\n// ]\n```\n\n## API\n\n***\n\n### `default()`\n\nA plugin is a function.\nIt configures the processor and in turn can receive options.\nPlugins can configure processors by interacting with parsers and compilers\n(at `this.Parser` or `this.Compiler`) or by specifying how the syntax tree\nis handled (by returning a `Transformer`).\n\n#### Signature\n\n```ts\ndefault(this: Processor\u003cvoid, Root, Root, BlockObjectRequest[]\u003e | Processor\u003cvoid, Comment, Comment, BlockObjectRequest[]\u003e | Processor\u003cvoid, DocType, DocType, BlockObjectRequest[]\u003e | Processor\u003cvoid, Element, Element, BlockObjectRequest[]\u003e | Processor\u003cvoid, Text, Text, BlockObjectRequest[]\u003e, ...settings: [Options] | [void] | []): void;\n```\n\n#### Parameters\n\n| Name | Type | Description |\n| :------ | :------ | :------ |\n| `this` | `Processor`\u003c`void`, `Root`, `Root`, `BlockObjectRequest`[]\u003e | `Processor`\u003c`void`, `Comment`, `Comment`, `BlockObjectRequest`[]\u003e | `Processor`\u003c`void`, `DocType`, `DocType`, `BlockObjectRequest`[]\u003e | `Processor`\u003c`void`, `Element`, `Element`, `BlockObjectRequest`[]\u003e | `Processor`\u003c`void`, `Text`, `Text`, `BlockObjectRequest`[]\u003e | - |\n| `...settings` | [[`Options`](modules.md#options)] | [`void`] | [] | Configuration for plugin.   Plugins typically receive one options object, but could receive other and   more values.   Users can also pass a boolean instead of settings: `true` (to turn   a plugin on) or `false` (to turn a plugin off).   When a plugin is turned off, it won’t be called.    When creating your own plugins, please accept only a single object!   It allows plugins to be reconfigured and it helps users to know that every   plugin accepts one options object. |\n\n#### Returns\n\n`void`\n\nPlugins can return a `Transformer` to specify how the syntax tree is\nhandled.\n\nDefined in:  node\\_modules/.pnpm/unified\\@10.1.2/node\\_modules/unified/index.d.ts:531\n\n***\n\n### `Options`\n\n#### Properties\n\n##### `hastToMdastOptions?`\n\n\u003e `Options`\n\nDefined in:  [src/lib/rehype-notion.ts:29](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/notion/rehype-notion/src/lib/rehype-notion.ts#L29)\n\n##### `markdownToNotionOptions?`\n\n\u003e `BlocksOptions`\n\nDefined in:  [src/lib/rehype-notion.ts:31](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/notion/rehype-notion/src/lib/rehype-notion.ts#L31)\n\n##### `mdastToMarkdownOptions?`\n\n\u003e `MdastToMarkdownOptions`\n\nDefined in:  [src/lib/rehype-notion.ts:30](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/notion/rehype-notion/src/lib/rehype-notion.ts#L30)\n\n***\n\n### `Block`\n\n\u003e `AppendBlockChildrenParameters`[`\"children\"`][`number`]\n\nDefined in:  [src/lib/rehype-notion.ts:13](https://github.com/TrialAndErrorOrg/parsers/blob/main/libs/notion/rehype-notion/src/lib/rehype-notion.ts#L13)\n\n## Security\n\nUse of `rehypeNotion` can open you up to a [cross-site scripting (XSS)][xss] attack. If you are processing user input, be sure to use a HTML sanitizer, such as [rehype-sanitize][rehype-sanitize].\n\n## Related\n\n*   [html-to-notion-blocks][html-to-notion-blocks]\n    *   Convert HTML to Notion blocks without constructing the procssing pipeline yourself\n*   [@tryfabric/martian](https://github.com/@tryfabric/martian)\n    *   Convert Markdown to Notion blocks using a simple API\n*   [rehype-sanitize][rehype-sanitize]\n*   [rehype][rehype]\n    — HTML processor powered by plugins part of the [unified][unified] collective\n\n## License\n\n[GPL-3.0-or-later](LICENSE) © Thomas F. K. Jorna\n\n[unified]: https://unifiedjs.com\n\n[unifiedgh]: https://github.com/unifiedjs/unified\n\n[xast-from-xml]: https://github.com/syntax-tree/xast-util-from-xml\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[rejour]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour\n\n[rejour-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-parse\n\n[rejour-stringify]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-stringify\n\n[rejour-move-abstract]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-move-abstract\n\n[rejour-meta]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-meta\n\n[rejour-relatex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-relatex\n\n[relatex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex\n\n[relatex-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/relatex-parse\n\n[jast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jast\n\n[jast-util-to-texast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jast-util-to-texast\n\n[jastscript]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jastscript\n\n[texast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/texast\n\n[texast-util-to-latex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/texast-util-to-latex\n\n[hast]: https://github.com/syntax-tree/hast\n\n[xast]: https://github.com/syntax-tree/xast\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[mdast-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown\n\n[latex-utensils]: https://github.com/tamuratak/latex-utensils\n\n[latexjs]: https://github.com/latexjs/latexjs\n\n[reoff]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff\n\n[reoff-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-parse\n\n[reoff-rejour]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-rejour\n\n[ooxast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast\n\n[ooxast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast-util-to-jast\n\n[rehype-notion]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/notion/rehype-notion\n\n[html-to-notion-blocks]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/notion/html-to-notion-blocks\n\n[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrialanderrororg%2Frehype-notion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrialanderrororg%2Frehype-notion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrialanderrororg%2Frehype-notion/lists"}