Crates.io | notion2pandoc |
lib.rs | notion2pandoc |
version | 0.5.1 |
source | src |
created_at | 2022-09-20 13:13:05.888736 |
updated_at | 2023-02-19 08:33:13.693516 |
description | convert Notion page to Pandoc AST |
homepage | |
repository | https://github.com/ho-oto/notion2pandoc |
max_upload_size | |
id | 669896 |
size | 1,673,312 |
notion2pandoc is a simple CLI tool to convert Notion page to Pandoc AST by using Notion API.
notion2pandoc outputs Pandoc AST serialized in JSON to stdout. Combining with the Pandoc CLI, You can get Notion pages formatted in your favorite markup format supported by Pandoc, as follows.
notion2pandoc -i ${NOTION_PAGE_ID} -s ${NOTION_API_SECRET} | pandoc --from json --to {html,markdown,...}
notion2pandoc outputs pandoc-types-1.23. Validation is done by using Pandoc 3.0.1.
Instead of taking an output of curl
or something like that from stdin, notion2pandoc is implemented to take an API secret and call the Notion API internally.
This is because the current version of Notion API requires multiple API calls to retrieve the entire page.
The API allows us to retrieve a list of the blocks that make up a page. However, when the number of blocks exceeds 100, the API must be called again with pagination. When a block has child blocks, another API call is necessary to retrieve their contents.
notion2pandoc simply ignore blocks with following Block Type Object.
notion2pandoc dose not generate table of contents.
Instead, you can check if a page contains a block with table_of_contents
type by looking at toc
value of meta data in generated AST.
MIT