zmp-notion-exporter


Namezmp-notion-exporter JSON
Version 0.2.1 PyPI version JSON
download
home_pageNone
SummaryThis is the utility library to export the markdown, html and pdf files from the notion pages
upload_time2025-02-12 09:54:20
maintainerNone
docs_urlNone
authorKilsoo Kang
requires_python<4.0,>=3.11
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # zmp-notion-exporter

![Platform Badge](https://img.shields.io/badge/platform-zmp-red)
![Component Badge](https://img.shields.io/badge/component-exporter-red)
![CI Badge](https://img.shields.io/badge/ci-github_action-green)
![License Badge](https://img.shields.io/badge/license-MIT-green)
![PyPI - Version](https://img.shields.io/pypi/v/zmp-notion-exporter)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/zmp-notion-exporter)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/zmp-notion-exporter)
![PyPI - Wheel](https://img.shields.io/pypi/wheel/zmp-notion-exporter)

<!-- ![Language Badge](https://img.shields.io/badge/language-python-blue)
![Version Badge](https://img.shields.io/badge/version-^3.12-blue) -->

The zmp-notion-expoter is the utility library to export the Mardown, HTML and PDF files from the notion pages.

# Goals
This is the utility project for the Cloud Z MP manual system

# Examples
## Export to markdown
include all sub pages of the root notion page
```python
import os
import time

from dotenv import load_dotenv

from zmp_notion_exporter import NotionPageExporter, extract_notion_page_id

load_dotenv()

notion_token = os.environ.get("NOTION_TOKEN", "")

if not notion_token:
    raise ValueError("NOTION_TOKEN is not set")


root_page_url = "https://www.notion.so/cloudzcp/Cloud-Z-CP-193b7135d33b801a942fd1706edcb026?pvs=4"  # Cloud Z CP

output_dir = ".output"

exporter = NotionPageExporter(
    notion_token=notion_token,
    root_page_id=extract_notion_page_id(root_page_url),
    root_output_dir=output_dir,
)

start_time = time.time()

path = exporter.markdown(include_subpages=True)

print(path)

end_time = time.time()

print("-" * 100)
print(f"Export took {end_time - start_time:.2f} seconds")
print("-" * 100)

# Output sample
.output/docs/Cloud_Z_CP/v2.0
----------------------------------------------------------------------------------------------------
Export took 33.75 seconds
```

## Export to markdown files of the specific page
```python
import os
import time

from dotenv import load_dotenv

from zmp_notion_exporter import NotionPageExporter, extract_notion_page_id

load_dotenv()

notion_token = os.environ.get("NOTION_TOKEN", "")

if not notion_token:
    raise ValueError("NOTION_TOKEN is not set")


root_page_url = "https://www.notion.so/cloudzcp/Cloud-Z-CP-193b7135d33b801a942fd1706edcb026?pvs=4"  # Cloud Z CP
target_page_urls = [
    "https://www.notion.so/cloudzcp/Getting-Started-Sample-Page-193b7135d33b80e0954fc9e52d94291a?pvs=4",  # Getting Started Sample Page
    "https://www.notion.so/v2-0-193b7135d33b803ba24bdccaaa8496f5?pvs=4",  # v2.0
]

output_dir = ".output"

exporter = NotionPageExporter(
    notion_token=notion_token,
    root_page_id=extract_notion_page_id(root_page_url),
    root_output_dir=output_dir,
)

start_time = time.time()

path = exporter.markdown(
    page_id=extract_notion_page_id(target_page_urls[2]), include_subpages=False
)

print(path)

docs_node, static_image_node = exporter.get_output_nodes()
docs_node.print_pretty(include_leaf_node=True)
static_image_node.print_pretty(include_leaf_node=False)

end_time = time.time()

print("-" * 100)
print(f"Export took {end_time - start_time:.2f} seconds")
print("-" * 100)

# Output sample
.output/docs/Cloud_Z_CP/v2.0
.output/
└── docs/
    └── Cloud_Z_CP/
        └── v2.0/
            └── Supported_Notion_Blocks_for_Manual
            └── Unsupported_Blocks_for_Manual
            └── Tutorials/
                └── 1_Gettting
                └── 2_Getting
            └── Installation
            └── FAQ
            └── Release_Notes
        └── v3.0
.output/
└── static/
    └── image/
        └── Cloud_Z_CP/
            └── v2.0/
                └── Tutorials/
----------------------------------------------------------------------------------------------------
Export took 33.75 seconds


# directory and files check
$ tree .output
.output
├── docs
│   └── Cloud_Z_CP
│       └── v2.0
│           ├── FAQ.md
│           ├── Installation.md
│           ├── Release_Notes.md
│           ├── Supported_Notion_Blocks_for_Manual.md
│           ├── Tutorials
│           │   ├── 1_Gettting.md
│           │   └── 2_Getting.md
│           └── Unsupported_Blocks_for_Manual.md
└── static
    └── image
        └── Cloud_Z_CP
            └── v2.0
                ├── 193b7135-d33b-808b-87de-dc5707394d08_docling_processing.png
                ├── 193b7135-d33b-80b3-b2e8-fecf91125711.png
                ├── 197b7135-d33b-80c6-b11e-eb25b76008d6.png
                ├── Tutorials
                └── wildcard-shinhan-cloudzcp-net-cert.yaml
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "zmp-notion-exporter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Kilsoo Kang",
    "author_email": "kilsoo75@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e1/b4/c6c896866e5ed6768f0e778008fda67e6b9f6d1d40e506c73d26954a8975/zmp_notion_exporter-0.2.1.tar.gz",
    "platform": null,
    "description": "# zmp-notion-exporter\n\n![Platform Badge](https://img.shields.io/badge/platform-zmp-red)\n![Component Badge](https://img.shields.io/badge/component-exporter-red)\n![CI Badge](https://img.shields.io/badge/ci-github_action-green)\n![License Badge](https://img.shields.io/badge/license-MIT-green)\n![PyPI - Version](https://img.shields.io/pypi/v/zmp-notion-exporter)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/zmp-notion-exporter)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/zmp-notion-exporter)\n![PyPI - Wheel](https://img.shields.io/pypi/wheel/zmp-notion-exporter)\n\n<!-- ![Language Badge](https://img.shields.io/badge/language-python-blue)\n![Version Badge](https://img.shields.io/badge/version-^3.12-blue) -->\n\nThe zmp-notion-expoter is the utility library to export the Mardown, HTML and PDF files from the notion pages.\n\n# Goals\nThis is the utility project for the Cloud Z MP manual system\n\n# Examples\n## Export to markdown\ninclude all sub pages of the root notion page\n```python\nimport os\nimport time\n\nfrom dotenv import load_dotenv\n\nfrom zmp_notion_exporter import NotionPageExporter, extract_notion_page_id\n\nload_dotenv()\n\nnotion_token = os.environ.get(\"NOTION_TOKEN\", \"\")\n\nif not notion_token:\n    raise ValueError(\"NOTION_TOKEN is not set\")\n\n\nroot_page_url = \"https://www.notion.so/cloudzcp/Cloud-Z-CP-193b7135d33b801a942fd1706edcb026?pvs=4\"  # Cloud Z CP\n\noutput_dir = \".output\"\n\nexporter = NotionPageExporter(\n    notion_token=notion_token,\n    root_page_id=extract_notion_page_id(root_page_url),\n    root_output_dir=output_dir,\n)\n\nstart_time = time.time()\n\npath = exporter.markdown(include_subpages=True)\n\nprint(path)\n\nend_time = time.time()\n\nprint(\"-\" * 100)\nprint(f\"Export took {end_time - start_time:.2f} seconds\")\nprint(\"-\" * 100)\n\n# Output sample\n.output/docs/Cloud_Z_CP/v2.0\n----------------------------------------------------------------------------------------------------\nExport took 33.75 seconds\n```\n\n## Export to markdown files of the specific page\n```python\nimport os\nimport time\n\nfrom dotenv import load_dotenv\n\nfrom zmp_notion_exporter import NotionPageExporter, extract_notion_page_id\n\nload_dotenv()\n\nnotion_token = os.environ.get(\"NOTION_TOKEN\", \"\")\n\nif not notion_token:\n    raise ValueError(\"NOTION_TOKEN is not set\")\n\n\nroot_page_url = \"https://www.notion.so/cloudzcp/Cloud-Z-CP-193b7135d33b801a942fd1706edcb026?pvs=4\"  # Cloud Z CP\ntarget_page_urls = [\n    \"https://www.notion.so/cloudzcp/Getting-Started-Sample-Page-193b7135d33b80e0954fc9e52d94291a?pvs=4\",  # Getting Started Sample Page\n    \"https://www.notion.so/v2-0-193b7135d33b803ba24bdccaaa8496f5?pvs=4\",  # v2.0\n]\n\noutput_dir = \".output\"\n\nexporter = NotionPageExporter(\n    notion_token=notion_token,\n    root_page_id=extract_notion_page_id(root_page_url),\n    root_output_dir=output_dir,\n)\n\nstart_time = time.time()\n\npath = exporter.markdown(\n    page_id=extract_notion_page_id(target_page_urls[2]), include_subpages=False\n)\n\nprint(path)\n\ndocs_node, static_image_node = exporter.get_output_nodes()\ndocs_node.print_pretty(include_leaf_node=True)\nstatic_image_node.print_pretty(include_leaf_node=False)\n\nend_time = time.time()\n\nprint(\"-\" * 100)\nprint(f\"Export took {end_time - start_time:.2f} seconds\")\nprint(\"-\" * 100)\n\n# Output sample\n.output/docs/Cloud_Z_CP/v2.0\n.output/\n\u2514\u2500\u2500 docs/\n    \u2514\u2500\u2500 Cloud_Z_CP/\n        \u2514\u2500\u2500 v2.0/\n            \u2514\u2500\u2500 Supported_Notion_Blocks_for_Manual\n            \u2514\u2500\u2500 Unsupported_Blocks_for_Manual\n            \u2514\u2500\u2500 Tutorials/\n                \u2514\u2500\u2500 1_Gettting\n                \u2514\u2500\u2500 2_Getting\n            \u2514\u2500\u2500 Installation\n            \u2514\u2500\u2500 FAQ\n            \u2514\u2500\u2500 Release_Notes\n        \u2514\u2500\u2500 v3.0\n.output/\n\u2514\u2500\u2500 static/\n    \u2514\u2500\u2500 image/\n        \u2514\u2500\u2500 Cloud_Z_CP/\n            \u2514\u2500\u2500 v2.0/\n                \u2514\u2500\u2500 Tutorials/\n----------------------------------------------------------------------------------------------------\nExport took 33.75 seconds\n\n\n# directory and files check\n$ tree .output\n.output\n\u251c\u2500\u2500 docs\n\u2502   \u2514\u2500\u2500 Cloud_Z_CP\n\u2502       \u2514\u2500\u2500 v2.0\n\u2502           \u251c\u2500\u2500 FAQ.md\n\u2502           \u251c\u2500\u2500 Installation.md\n\u2502           \u251c\u2500\u2500 Release_Notes.md\n\u2502           \u251c\u2500\u2500 Supported_Notion_Blocks_for_Manual.md\n\u2502           \u251c\u2500\u2500 Tutorials\n\u2502           \u2502   \u251c\u2500\u2500 1_Gettting.md\n\u2502           \u2502   \u2514\u2500\u2500 2_Getting.md\n\u2502           \u2514\u2500\u2500 Unsupported_Blocks_for_Manual.md\n\u2514\u2500\u2500 static\n    \u2514\u2500\u2500 image\n        \u2514\u2500\u2500 Cloud_Z_CP\n            \u2514\u2500\u2500 v2.0\n                \u251c\u2500\u2500 193b7135-d33b-808b-87de-dc5707394d08_docling_processing.png\n                \u251c\u2500\u2500 193b7135-d33b-80b3-b2e8-fecf91125711.png\n                \u251c\u2500\u2500 197b7135-d33b-80c6-b11e-eb25b76008d6.png\n                \u251c\u2500\u2500 Tutorials\n                \u2514\u2500\u2500 wildcard-shinhan-cloudzcp-net-cert.yaml\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This is the utility library to export the markdown, html and pdf files from the notion pages",
    "version": "0.2.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77808d97dc33851480b5f98c7ee6cc5934d12b5082f5e92bad4716cd8b453a0c",
                "md5": "7ff089097104bf7087a74c3b2c7180e7",
                "sha256": "61ab2eef23fe71388643c5c0c5b93da03bcd811f06661638a7620531c19ff29c"
            },
            "downloads": -1,
            "filename": "zmp_notion_exporter-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7ff089097104bf7087a74c3b2c7180e7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 17583,
            "upload_time": "2025-02-12T09:54:18",
            "upload_time_iso_8601": "2025-02-12T09:54:18.606266Z",
            "url": "https://files.pythonhosted.org/packages/77/80/8d97dc33851480b5f98c7ee6cc5934d12b5082f5e92bad4716cd8b453a0c/zmp_notion_exporter-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1b4c6c896866e5ed6768f0e778008fda67e6b9f6d1d40e506c73d26954a8975",
                "md5": "56af14513c2799349e267298de9a1cce",
                "sha256": "42c657a024fc89a900599f90f4e855129838ab7fb71772c31d86b1495376f85b"
            },
            "downloads": -1,
            "filename": "zmp_notion_exporter-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "56af14513c2799349e267298de9a1cce",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 16359,
            "upload_time": "2025-02-12T09:54:20",
            "upload_time_iso_8601": "2025-02-12T09:54:20.623541Z",
            "url": "https://files.pythonhosted.org/packages/e1/b4/c6c896866e5ed6768f0e778008fda67e6b9f6d1d40e506c73d26954a8975/zmp_notion_exporter-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-12 09:54:20",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "zmp-notion-exporter"
}
        
Elapsed time: 1.13449s