{"_id":"@astro-notion/notion-rehype","name":"@astro-notion/notion-rehype","dist-tags":{"latest":"1.2.0"},"versions":{"1.2.0":{"name":"@astro-notion/notion-rehype","version":"1.2.0","description":"Rehype plugin to transform Notion blocks to HAST nodes","main":"dist/index.js","type":"module","repository":{"url":"git+ssh://git@github.com/astro-notion/notion-rehype.git"},"keywords":["notion","rehype","unified","plugin","html"],"author":{"name":"ntcho"},"contributors":[{"name":"Kherrisan"},{"name":"Mongkii"}],"license":"MIT","devDependencies":{"@notionhq/client":"^3.0.1","@types/hast":"^2.3.4","hast":"^1.0.0","prettier":"^3.5.3","rehype-raw":"^6.1.1","rehype-stringify":"^9.0.3","typescript":"^4.7.4","unified":"^10.1.2","vfile":"^5.3.4"},"scripts":{"clean":"rm -rf dist","build":"pnpm run clean && tsc --build","build:watch":"tsc --watch"},"_id":"@astro-notion/notion-rehype@1.2.0","types":"./dist/index.d.ts","bugs":{"url":"https://github.com/astro-notion/notion-rehype/issues"},"homepage":"https://github.com/astro-notion/notion-rehype#readme","_integrity":"sha512-wEPaOBwG6XbyCjSRvIsa5hwQ9UVHXBArQJtXhEUYIC1qG7PlLqaoVRQk543/ZM8eC+Agqa2qY35eInnOa0QKQw==","_resolved":"/private/var/folders/db/zqkdk_gj3sxd_125sfsyf4t40000gn/T/5885241ac6daa0dea72e3d132cfe99fc/astro-notion-notion-rehype-1.2.0.tgz","_from":"file:astro-notion-notion-rehype-1.2.0.tgz","_nodeVersion":"22.15.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-wEPaOBwG6XbyCjSRvIsa5hwQ9UVHXBArQJtXhEUYIC1qG7PlLqaoVRQk543/ZM8eC+Agqa2qY35eInnOa0QKQw==","shasum":"1fa226dbf9061456ed5c72d7cec38b6aefedfcbe","tarball":"https://registry.npmjs.org/@astro-notion/notion-rehype/-/notion-rehype-1.2.0.tgz","fileCount":65,"unpackedSize":50228,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCTqNqEC0a0siEDmfYAGclI9kf89CJyiGarjQPBGhlNAAIgZ92Ig4BiegyjxAi5n3CxXuI8xIqpUZVLRlaPcXpL4GY="}]},"_npmUser":{"name":"ntcho","email":"ntcho13@gmail.com"},"directories":{},"maintainers":[{"name":"ntcho","email":"ntcho13@gmail.com"},{"name":"chlorinec","email":"kiritoclzh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/notion-rehype_1.2.0_1769660430573_0.6107750973950152"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-29T04:20:30.518Z","1.2.0":"2026-01-29T04:20:30.731Z","modified":"2026-01-29T04:20:30.935Z"},"maintainers":[{"name":"ntcho","email":"ntcho13@gmail.com"},{"name":"chlorinec","email":"kiritoclzh@gmail.com"}],"description":"Rehype plugin to transform Notion blocks to HAST nodes","homepage":"https://github.com/astro-notion/notion-rehype#readme","keywords":["notion","rehype","unified","plugin","html"],"repository":{"url":"git+ssh://git@github.com/astro-notion/notion-rehype.git"},"contributors":[{"name":"Kherrisan"},{"name":"Mongkii"}],"author":{"name":"ntcho"},"bugs":{"url":"https://github.com/astro-notion/notion-rehype/issues"},"license":"MIT","readme":"# notion-rehype\n\nTurn Notion blocks(from API) into rehype(hast), so you can make the most of the rich rehype ecosystem.\n\n## Usage\n\n```js\nimport { unified } from 'unified';\nimport notionRehype from 'notion-rehype';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeStringify from 'rehype-stringify';\n\nconst notionBlocks = [\n  {\n    // ... some properties omitted\n    type: 'paragraph',\n    paragraph: {\n      // ... some properties omitted\n      rich_text: [{ plain_text: 'This is a Notion paragraph' }],\n    },\n  },\n];\n\nconst processor = unified()\n  .use(notionRehype) // Parse Notion blocks to rehype AST\n  .use(rehypeKatex) // Then you can use any rehype plugins to enrich the AST\n  .use(rehypeStringify); // Turn AST to HTML string\n\n// Due to the limitation of the `.process()` method,\n// notion blocks should be passed in with a wrapper `{ data: xxx }`;\nconst vFile = unifiedInst.process({ data: notionBlocks });\n// Or you can pass a string in.\n// The plugin will use JSON.parse to parse any string argument.\nconst vFile = unifiedInst.process(JSON.stringify(notionBlocks));\n\nconst html = vFile.toString(); // get the output HTML string\nassert(html === '<p>This is a Notion paragraph</p>');\n```\n\n## Plugin Options\n\nThe plugin offers many options to customize the output, you can set options in this way: `.use(notionRehype, { ...options })`\n\n| Option                | Type                                                         | Default Value   | Description                                                                                                                                                                                                                                                                                                                                                                           |\n| --------------------- | ------------------------------------------------------------ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| notionPrefix          | string                                                       | `'notion-'`     | The prefix of the classes and attributes that relates to Notion. e.g. `<section class=\"notion-callout\"><section>`, the `'notion-'` is the prefix.                                                                                                                                                                                                                                     |\n| enableNestedParagraph | boolean                                                      | `false`         | Should paragraph elements supports nesting. If true, the paragraph element which has children will turn into `<div>` instead of `<p>`, since the `<p>` element doesn't allow nesting. Which might leads to lower accessibility                                                                                                                                                        |\n| enableBlockId         | boolean                                                      | `false`         | Should add block id info to DOM or not. If true, the DOMs will have a `data-{prefix}-block-id` attribute.                                                                                                                                                                                                                                                                             |\n| convertRawHtml        | `(richTextObj: any) => string \\| false \\| undefined \\| null` | `undefined`     | A function to test should a `block.[type].rich_text` item turn to raw HTML. If should, this function returns the raw HTML value. e.g. `convertRawHtml: (richTextObj) => richTextObj.plain_text.startsWith('@@') ? richTextObj.plain_text.slice(2) : null`, will render like this: Notion Block: `'TEST. @@<span>test</span>. TEST'` -> Result: `<p>TEST. <span>test</span>. TEST</p`> |\n| pageReference         | `{ [pageId: string]: any }`                                  | `{}`            | Used in link_to_page blocks, since the blocks don't contain page metadatas, the info should be passed in from the outside.                                                                                                                                                                                                                                                            |\n| footnoteReference     | `{ [blockId: string]: any }`                                 | `{}`            | **[NOT STABLE - this option will change anytime following Notion Comment API changes. Use it at your own rick]** If a block has a 'footnote placeholder' (a rich_text item which is **inline code** and **text is `[^]`**), it will search for the relevant block comments, and use the comments as footnote for placeholder.                                                         |\n| footnoteTitle         | string                                                       | `'Footnotes' `  | The Footnote Title. If set to `<hr>`, will render a hr element rather than a h2 title.                                                                                                                                                                                                                                                                                                |\n| footnoteBackLabel     | string                                                       | `'Back to ref'` | The title and aria text for a footnote's 'go back' icon.                                                                                                                                                                                                                                                                                                                              |\n\n## TODO\n\n- [ ] Types support\n- [ ] Unit tests\n- [ ] Engineering (ESLint, Prettier, …etc.)\n","readmeFilename":"README.md","_rev":"1-8bb6362bb0e22ba06936cd8686d872d0"}