Metadata-Version: 2.1
Name: notion-blockify
Version: 0.1.1
Summary: Convert Markdown to Notion blocks
Author-email: Minseong Kim <emeraldgoose@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Minseong Kim
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/emeraldgoose/notion-blockify
Keywords: notion,markdown,converter,blocks
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

# notion-blockify
`notion-blockify` is a Python library that converts Markdown into Notion API–compatible block structures.

## Installation
```
pip install notion-blockify
```

## Usage
```
from notion_blockify import Blockizer

markdown = """
# Heading 1
This is paragraph.
"""

blocks = Blockizer().convert(markdown)
```

## Supported Blocks
### Headings
```
# Heading 1
## Heading 2
### Heading 3
```
### Lists

> Note: The block that allows children is limited to a maximum of two levels of nesting by the Notion API.

**bulleted list**
```
- bulleted list 1
  - bulleted list 2
    - bulleted list 3
```

**numbered list**
```
1. numbered list 1
    1. numbered list 2
        1. numbered list 3
```

### Table
```
| Col1 | Col2 | Col3 |
|------|------|------|
| A    | B    | C    |
```

### Quote
```
> Quote
```

### Code
    ```cpp
    #include <iostream>
    using namespace std;
    int main() {
        cout<<"hello world"<<endl;
        return 0;
    }
    ```

    ```python
    print('hello')
    ```

    ```
    plain text
    ```

### Horizontal Line
```
---
```

### Image
```
![Alt](Image url)
```

If an `<img>` tag is used on its own or wrapped inside a `<figure>` tag, it will be converted into an image block. If a `<figcaption>` tag is present inside the `<figure>`, its content will be added below the image in _italic_.

```
<img src="image url">

<figure>
    <img src="image url">
</figure>

<figure>
    <img src="image url">
    <figcaption>caption text</figcaption>
</figure>
```

### Latex
```
$$ E = mc^2 $$
```

### TODO
```
[x] checked
[] not checked
[ ] not checked
```

### Text Style
**bold**
```
**bold**
__bold__
```
**italic**
```
*italic*
_italic_
```
~~strikethrough~~
```
~~strikethrough~~
```
`code`
```
`code`
```


## Examples
If you are using the [notion-client](https://github.com/ramnes/notion-sdk-py) library, you can create a page.

> Note: The Notion API does not allow more than 100 blocks in a single request. Exceeding this limit will result in an error.   
> If you need to add more than 100 blocks, split them into multiple requests and append them sequentially to the same parent block or page.

### Create a page in a Notion page
```python
import os
from notion_blockify import Blockizer
from notion_client import Client

with open('example.md', 'r') as f:
    text = f.read()

blocks = Blockizer().convert(text)

notion = Client(auth=os.environ["NOTION_API_KEY"])
my_page = notion.pages.create(
    **{
        "parent": {"page_id": NOTION_PAGE_ID},
        "properties: {"title": [{"text": {"content": PAGE_TITLE}}]},
        "children": blocks
    }
)
```

### Create a page in a Notion database
```python
import os
from notion_blockify import Blockizer
from notion_client import Client

with open('example.md', 'r') as f:
    text = f.read()

blocks = Blockizer().convert(text)

notion = Client(auth=os.environ["NOTION_API_KEY"])
my_page = notion.pages.create(
    **{
        "parent": {"page_id": NOTION_DATABASE_ID},
        "properties: {
            "Name": {
                "title": [
                    {"text": {"content": PAGE_TITLE}}
                ]
            },
            "Food group": {"select": {"name": "Vegetable"}},
            "Price": {"number": 2.5},
        },
        "children": blocks
    }
)
```
