{"_id":"@dantehemerson2/notion-to-md","_rev":"3-b5396a1d32695a425585689f3be84df4","name":"@dantehemerson2/notion-to-md","dist-tags":{"latest":"2.2.2"},"versions":{"2.2.0":{"name":"@dantehemerson2/notion-to-md","version":"2.2.0","engines":{"node":">=12"},"main":"./build","types":"./build/index.d.ts","scripts":{"prepare":"npm run build","build":"tsc","prebuild":"npm run clean","clean":"rm -rf ./build","test":"echo \"Error: no test specified\" && exit 1"},"keywords":["notion","markdown","md","notion","notion-api","notion-to-md","notion2md"],"author":"","license":"ISC","repository":{"type":"git","url":"git+https://github.com/souvikinator/notion-to-md.git"},"bugs":{"url":"https://github.com/souvikinator/notion-to-md/issues"},"homepage":"https://github.com/souvikinator/notion-to-md#readme","description":"convert notion pages, block and list of blocks to markdown (supports nesting)","devDependencies":{"@notionhq/client":"^0.4.11","typescript":"^4.5.4"},"gitHead":"470b741e6e7c13ec6b1cf308c6fb9d5cd9e7675a","_id":"@dantehemerson2/notion-to-md@2.2.0","_nodeVersion":"12.22.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-7dgZJGU/qBplf8sGtGaDxSXdhTLQil5Wazohi/MGV+wXuc4vwrw2fTZ2qlKfXqyx+zL1TkW17izUUOFrH/4nnQ==","shasum":"32ac3922b6e3ed3495431557259efd4c01a1a0b4","tarball":"https://registry.npmjs.org/@dantehemerson2/notion-to-md/-/notion-to-md-2.2.0.tgz","fileCount":23,"unpackedSize":51972,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7YZFCRA9TVsSAnZWagAAG8EP/iYzLiCDkOEbijs8y/zi\n93A+TTp+GJe0CRS2Wrm3H5mNHRFddbaB4+I3F2faLdvMoQ69AA0+8UAj9EkG\n4zdG29HHcRL+rvu6QmVXMclnO3NQywqpRBLBgUjsKcJ6B+H/j/ZFMcU/4rUR\nCG3PVjXgoouOOE+5vlTMTNOhE1MrWuloc+OozNtKhU0aIy4wcwQ7qB5E1s1y\n+1NAgvpngmlkywxs97Fg2TWwJMksUqOB/rV2Tqd7rVhIde7BNOGkxykh6EIt\ngTKDgLRWAkAnWfKSn2ntutDXqw/+5gwwKpRf65uyeSo9Pvl+jFD6oEQqBdq+\nAYAv8Gc5yYYG7qUasJVCcYAm1iAUNHhQ1RrR2ihm0Buh1CyKspSB9PJ/JeKf\n4ll6fhHYno3Ln414d95DjswkyB9dhpluFN5HbNwvaOdjYW8MW2SwyDZ26Agm\nB1/tPTe6qtMX/JgU6y90Q9X8+6tyEvQwMBMi8j9Tbe/Ktbd1rynwLK9vYSlj\nGQmvxHmPJapNUaodoBRTPvMjVfuBjFXNGJC81R2hXyKfNk6DejXqLj+fyLDH\nE3WKtzNEByjcC8n6DBSRhX3NpZJ9knE4QQYV2WqZg6R8nQAuxZkmIGVdQS8/\n7ZtlwNEERSCvvXkb3M3GDGMkwwQrKeLfgcfvW6GgNuIwBDjRoLaVpljITJZO\nDjlg\r\n=eU5I\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEIgDx8o2wCyM6XgeGEtO6U1fjDZF+Y8Wl4ZOB6QPdMtAiEA+6XUnpH37T2N9vUAw5aKlZkxeIefZP/U0WJmy4MZD60="}]},"_npmUser":{"name":"dantehemerson2","email":"dantehemerson@outlook.com"},"directories":{},"maintainers":[{"name":"dantehemerson2","email":"dantehemerson@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notion-to-md_2.2.0_1642956356979_0.22185279772598698"},"_hasShrinkwrap":false},"2.2.1":{"name":"@dantehemerson2/notion-to-md","version":"2.2.1","engines":{"node":">=12"},"main":"./build","types":"./build/index.d.ts","scripts":{"prepare":"npm run build","build":"tsc","prebuild":"npm run clean","clean":"rm -rf ./build","test":"jest"},"keywords":["notion","markdown","md","notion","notion-api","notion-to-md","notion2md"],"author":"","license":"ISC","repository":{"type":"git","url":"git+https://github.com/souvikinator/notion-to-md.git"},"bugs":{"url":"https://github.com/souvikinator/notion-to-md/issues"},"homepage":"https://github.com/souvikinator/notion-to-md#readme","description":"convert notion pages, block and list of blocks to markdown (supports nesting)","devDependencies":{"@notionhq/client":"^0.4.12","@types/jest":"^27.4.0","jest":"^27.4.7","ts-jest":"^27.1.3","typescript":"^4.5.4"},"gitHead":"f26ec1c649d89afa0493cbca825d66f561d55a49","_id":"@dantehemerson2/notion-to-md@2.2.1","_nodeVersion":"12.22.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-1a7IwtcSQIct7Af5MPWHvp+ebn/6u9V2VPILCI1BliFgFr6EBtUnV2QgRAGR7rBdvLWQTdet9Chlsan/6oNWPg==","shasum":"8dad18155d9c6580d42f6fc707bf7102a997d0cb","tarball":"https://registry.npmjs.org/@dantehemerson2/notion-to-md/-/notion-to-md-2.2.1.tgz","fileCount":35,"unpackedSize":59788,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7ZUXCRA9TVsSAnZWagAAX48P/2SbkIqulj7fs4lYG+oA\nlGgRKTooKtx9E1gWoU/T1u7rmzoMLPtwiloQ6SmM/rjl16xk1XPH5Mx7z8hN\nMfF9u0GHsnruXGUgKDUygcKROF/5QCML/H2g1C9/w8ZNTrPw668UkcjusHyK\nx7lkxhaU5E/1QpPawziu7JAcCqCxVVGcqBNfl2sUCfPO7lZeI44of/iOOoeZ\n+Hk+mw0wtlSPvuWOdjyYNrPXgXJYVXPJb7FFvgb6h6Qwb4tZOvzpZKeYMqq9\n1vevb6V3ShBOxMtgLHQSTni7AuFCspDgWYymdDdY3cGJFrn6Atlk3HzvGQYm\nznI257HA0sm94/rZ2dVbv/idNTi4OUjkeykrAq64rXVxyU97sIPBScLSTzu0\nLb3OVmbksUeHwJiQ3B1daERF5ycCE/Ovg9iPzKX0LqjpzYenZG+jUKflxmMW\nMiUTxJBaGaI7Cwiei6cDqEwu8LNj/DlhTD00269CQUXo5pkcEiCISlhWU7ih\neQEMU3zVikWI08qlizAytKS5/m4l1hSHSLzhkteAqAZumnLvclhuKhselMyX\nx5Xd/gj9TSYRtgyr/HnvNBZOyM7aeCiLb8s0g/Cev9n73+kccgBfC7CxP6g0\nNxyTv/CUZrdj/ZC9VI9yZx++nFmYQ89VDRejzcfK47YIixtI8us/G9tKwoKy\n0m02\r\n=8Ba+\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDDLIcvgTjbVOckU5jhwRutHdz1Xixf9pV2iJNnx3ai3gIhANIKTHVA0tG22DcBD3hVlsUJFKbPM/XDe69myx+tNumb"}]},"_npmUser":{"name":"dantehemerson2","email":"dantehemerson@outlook.com"},"directories":{},"maintainers":[{"name":"dantehemerson2","email":"dantehemerson@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notion-to-md_2.2.1_1642960150939_0.015286365902569488"},"_hasShrinkwrap":false},"2.2.2":{"name":"@dantehemerson2/notion-to-md","version":"2.2.2","engines":{"node":">=12"},"main":"./build","types":"./build/index.d.ts","scripts":{"prepare":"npm run build","build":"tsc","prebuild":"npm run clean","clean":"rm -rf ./build","test":"jest"},"keywords":["notion","markdown","md","notion","notion-api","notion-to-md","notion2md"],"author":"","license":"ISC","repository":{"type":"git","url":"git+https://github.com/souvikinator/notion-to-md.git"},"bugs":{"url":"https://github.com/souvikinator/notion-to-md/issues"},"homepage":"https://github.com/souvikinator/notion-to-md#readme","description":"convert notion pages, block and list of blocks to markdown (supports nesting)","devDependencies":{"@notionhq/client":"^0.4.12","@types/jest":"^27.4.0","jest":"^27.4.7","ts-jest":"^27.1.3","typescript":"^4.5.4"},"gitHead":"52763078fa97fd0d686935c6e1c0c808d3141b50","_id":"@dantehemerson2/notion-to-md@2.2.2","_nodeVersion":"12.22.1","_npmVersion":"6.14.12","dist":{"integrity":"sha512-TfAFk2dHAfK/beP94/naPhxofLSmbK+viUPRmX/cN6MXOyXkk7tZWDcoc7O1XyTML1e4GiHwVQQy7fZcEKxG6g==","shasum":"6084752db3b6fca319b9d873396a9935ad1663e8","tarball":"https://registry.npmjs.org/@dantehemerson2/notion-to-md/-/notion-to-md-2.2.2.tgz","fileCount":35,"unpackedSize":61066,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7Zp3CRA9TVsSAnZWagAAdu0P/17zh5Qqy49IDnfZA6Jo\n4cPbPam+i6KdX+w0ATNIGfguqqn+Zz+gJ7TTzc88vtigeSYG+f7nFwFjc4nC\nTyd5sGeMGMc6h6jcsLMYzOk2yXRJonV4RR4wBm1o7fYJaraG1mmH0zV2TunH\nP0ugBbyIKQhTK/8gVwipcghA4ocZXn90RWv1RKnfHtoFiy1rWB1fbbOJXfYv\nBUgFcVaeRIDW1t6EDfJyDx86y5UlrmroPPOQUX7FaxlyA+LA8cGNCih3s4Bu\njuKaDVTiwvhgK843cTSOUGzBWEmPsG914DvuZWMWB3pjb2JYg+mo1Tbp6QkQ\nUq+928Tb66PhwiCp9perl9qv3JrVnoxhheAetepfzuaukXMZcKHEiYGSj5+t\nu/z1kVa7w5tOVDog41W1E+KEbKk3YvnI1iNnr8oLCd7hW29lbro/OVjafhma\nFP6wsarE9IC0qCUuy/Sw0DfQ+rCJEaL83B4UG7BMH0vduVv3OYNSy0KgeJW5\nNVROKXA6A5dScGu+dJUCTbkGyXClFt0YLHorkXPLURS9apZQRptKNbZ2vdyx\nfRVxzVuNSi1bG5CzHAlpOxvjdQi29/shkQ8kyavYIGgXzVOrA/ys9H1iDH4Z\n5SEwpflNL87t/5z7gSPhl8uP7nWDhJIVSPxVHSnbbZx5q/8dsusQLQ+LImCD\ndclL\r\n=I27i\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHXT7+V5VDqp8ittgofWtS8CC36fRbBtC+UWtGJ0DWsEAiBbpOihz645spResD55khsId+u/Dt3MnVvg+N8EN6BRlw=="}]},"_npmUser":{"name":"dantehemerson2","email":"dantehemerson@outlook.com"},"directories":{},"maintainers":[{"name":"dantehemerson2","email":"dantehemerson@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notion-to-md_2.2.2_1642961527635_0.7344801515557997"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-23T16:45:56.914Z","2.2.0":"2022-01-23T16:45:57.117Z","modified":"2022-04-05T02:43:04.646Z","2.2.1":"2022-01-23T17:49:11.106Z","2.2.2":"2022-01-23T18:12:07.767Z"},"maintainers":[{"name":"dantehemerson2","email":"dantehemerson@outlook.com"}],"description":"convert notion pages, block and list of blocks to markdown (supports nesting)","homepage":"https://github.com/souvikinator/notion-to-md#readme","keywords":["notion","markdown","md","notion","notion-api","notion-to-md","notion2md"],"repository":{"type":"git","url":"git+https://github.com/souvikinator/notion-to-md.git"},"bugs":{"url":"https://github.com/souvikinator/notion-to-md/issues"},"license":"ISC","readme":"<img src=\"https://imgur.com/WgXdz9r.png\" />\n\n# Notion to Markdown\n\nConvert notion pages, block and list of blocks to markdown (supports nesting) using **[notion-sdk-js](https://github.com/makenotion/notion-sdk-js)**\n\n> **Note:** Before getting started, create [an integration and find the token](https://www.notion.so/my-integrations).\n\n## Todo\n\n- [x] heading\n- [x] images\n- [x] quotes\n- [x] links\n- [x] bullets\n- [x] todo\n- [x] inline code\n- [x] code block\n- [x] strikethrough, underline, bold, italic\n- [x] nested blocks\n- [ ] pages inside pages/child page\n- [x] embeds, bookmarks, videos, files (converted to links)\n- [ ] tables\n- [x] divider\n- [x] equation block (converted to code blocks)\n- [x] convert returned markdown object to string (`toMarkdownString()`)\n- [x] typescript support\n- [ ] add tests\n\n## Install\n\n```Bash\n$ npm install notion-to-md\n```\n\n## Usage\n\n> **Note:** Details on methods can be found in [API section](https://github.com/souvikinator/notion-to-md#api)\n\n### converting markdown objects to markdown string\n\nThis is how the notion page looks for this example:\n\n![Imgur](https://imgur.com/O6bKCmH.png)\n\n```js\nconst { Client } = require(\"@notionhq/client\");\nconst { NotionToMarkdown } = require(\"notion-to-md\");\n// or\n// import {NotionToMarkdown} from \"notion-to-md\";\n\nconst notion = new Client({\n  auth: \"your integration token\",\n});\n\n// passing notion client to the option\nconst n2m = new NotionToMarkdown({ notionClient: notion });\n\n(async () => {\n  const mdblocks = await n2m.pageToMarkdown(\"target_page_id\");\n  const mdString = n2m.toMarkdownString(mdblocks);\n\n  //writing to file\n  fs.writeFile(\"test.md\", mdString, (err) => {\n    console.log(err);\n  });\n})();\n```\n\n**Output:**\n\n![output](https://imgur.com/XrUYrZ0.png)\n\n### converting page to markdown object\n\nExample notion page:\n\n![Imgur](https://imgur.com/9iqRpBl.png)\n\n```js\nconst { Client } = require(\"@notionhq/client\");\nconst { NotionToMarkdown } = require(\"notion-to-md\");\n\nconst notion = new Client({\n  auth: \"your integration token\",\n});\n\n// passing notion client to the option\nconst n2m = new NotionToMarkdown({ notionClient: notion });\n\n(async () => {\n  // notice second argument, totalPage.\n  const x = await n2m.pageToMarkdown(\"target_page_id\", 2);\n  console.log(x);\n})();\n```\n\n**Output:**\n\n```json\n[\n  {\n    \"parent\": \"# heading 1\",\n    \"children\": []\n  },\n  {\n    \"parent\": \"- bullet 1\",\n    \"children\": [\n      {\n        \"parent\": \"- bullet 1.1\",\n        \"children\": []\n      },\n      {\n        \"parent\": \"- bullet 1.2\",\n        \"children\": []\n      }\n    ]\n  },\n  {\n    \"parent\": \"- bullet 2\",\n    \"children\": []\n  },\n  {\n    \"parent\": \"- [ ] check box 1\",\n    \"children\": [\n      {\n        \"parent\": \"- [x] check box 1.2\",\n        \"children\": []\n      },\n      {\n        \"parent\": \"- [ ] check box 1.3\",\n        \"children\": []\n      }\n    ]\n  },\n  {\n    \"parent\": \"- [ ] checkbox 2\",\n    \"children\": []\n  }\n]\n```\n\n### converting list of blocks to markdown object\n\nsame notion page as before\n\n```js\nconst { Client } = require(\"@notionhq/client\");\nconst { NotionToMarkdown } = require(\"notion-to-md\");\n\nconst notion = new Client({\n  auth: \"your integration token\",\n});\n\n// passing notion client to the option\nconst n2m = new NotionToMarkdown({ notionClient: notion });\n\n(async () => {\n  // get all blocks in the page\n  const { results } = await notion.blocks.children.list({\n    block_id,\n  });\n\n  //convert to markdown\n  const x = await n2m.blocksToMarkdown(results);\n  console.log(x);\n})();\n```\n\n**Output**: same as before\n\n### Converting a single block to markdown string\n\n- only takes a single notion block and returns corresponding markdown string\n- nesting is ignored\n- independent of @notionhq/client\n\n```js\nconst { NotionToMarkdown } = require(\"notion-to-md\");\n\n// notion client not required\nconst n2m = new NotionToMarkdown();\n\nconst result = n2m.blockToMarkdown(block);\nconsole.log(result);\n```\n\n**result**:\n\n```\n![image](https://media.giphy.com/media/Ju7l5y9osyymQ/giphy.gif)\n```\n\n## API\n\n> ### `toMarkdownString(mdBlock[])`\n>\n> - takes output of `pageToMarkdown` or `blocksToMarkdown` as argument\n> - converts to markdown string.\n\n> ### `pageToMarkdown(id,totalPage)`\n>\n> - Uses `blocksToMarkdown` internally.\n> - `id`(pageid) as input and converts all the blocks in the page to corresponding markdown object\n> - `totalPage` is the retrieve block children request number i.e `page_size Maximum = totalPage * 100`.\n\n> ### totalPage\n>\n> Default value is `1` which means only `100` blocks will be converted to markdown and rest will be ignored (due to notion api limitations, ref: [#9](https://github.com/souvikinator/notion-to-md/pull/9)).\n>\n> ### How to use `totalPage` arg ?\n>\n> - if the notion page contains less than or equal `100` blocks then `totalPage` arg is not required.\n> - if the notion page contains `150` blocks then `totalPage` argument should be greater than or equal to `2` leading to `pageSize = 2 * 100` and rendering all `150` blocks.\n\n> ### `blocksToMarkdown(blocks,totalPage)`\n>\n> **Note**: requires <u>**notion-sdk-js**</u> unlike `blockToMarkdown`\n>\n> - `blocks`: array of notion blocks\n> - `totalPage`: the retrieve block children request number i.e `page_size Maximum = totalPage * 100`.\n> - deals with <u>**nested blocks**</u>\n> - uses `blockToMarkdown` internally.\n\n> ### `blockToMarkdown(block)`\n>\n> - Takes single notion block and converts to markdown string\n> - does not deal with nested notion blocks\n> - This method doesn't require the `notion-sdk-js`.\n> - Refer docs to know more about [notion blocks](https://developers.notion.com/reference/block)\n\n## Contribution\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","readmeFilename":"README.md"}