jamalex / jamalex/notion-py

add_new doesn't handle markdown for nested blocks

Open
#53 6 comments 1 reaction 0 assignees View on GitHub
left open for discussion
Dominant language
Python
Stars
4.4k
Forks
470
PR merge metrics
No merged PRs in 30d

Description

### Description
The readme mentions that the add_new method handles markdown formatting (and it does for some markdown elements like bold and italics) but it doesn't handle markdown for other "nested" blocks
```
page.children.add_new(TextBlock, title='Testing 1, 2, 3...\n - Testing \n - Another \n * [ ] Heres one more')
```
#### Results in 1 block of text:
Testing 1, 2, 3...

Testing

Another
[ ] Heres one more

#### Ideally it should result in 4 blocks like this:
Testing 1, 2, 3...
- Testing
- Another
* [ ] Heres one more
---
I've done some testing and these are the supported/unsupported markdown lists that I can gather:

#### Supported Markdown
- Bold
- Italics
- Links
- Inline code (`code`)

#### Unsupported Markdown
- Todos
- Lists (bullets, ordered lists, etc.)
- Headers
- Multi-line code blocks
- Horizontal rules

---
Since TextBlock is explicitly text, the current behavior makes sense, however maybe a new Block class is a better approach to handle the unique markdown parsing. Something like:
```
page.children.add_new(MarkdownBlock, title='Testing 1, 2, 3...\n - Testing \n - Another \n * [ ] Heres one more')
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the add_new method and the TextBlock behavior described in the issue, then trace how nested markdown is parsed into page blocks. Compare the current supported formatting with the requested lists, todos, headers, code blocks, and horizontal rules. Done means the chosen approach produces separate blocks for the example without regressing existing inline markdown handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, python
Domain
api, content
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.