Skip to content

Fix numbered list rendering #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

zephraph
Copy link

@zephraph zephraph commented May 18, 2020

fixes #4.

Before

image

(Notice that only child numbering is correct)

After

image

The current way numbered lists are rendered resulted in every list item being wrapped in an ol. This is likely due to the weird way notion renders these number lists.

A list isn't actually hierarchical as one might expect. There isn't a top level list block that contains sub block entries. Rather notion just infers that grouped numbered list items on the same level are related to the same group.

To achieve this I updated the logic of the NotionRenderer to have a reducer that goes over a block's child content and groups list items into what I've termed as a BlockGroup. A BlockGroup can specify it's own wrapper (like ul or ol) to group related items in.

I'll comment more in line.

@timolins timolins self-requested a review May 21, 2020 08:57
@timolins
Copy link
Member

timolins commented May 21, 2020

Thank you for your pull request! Good work at getting at the bottom of the problem.

I did some research as well and checked out how Notion handles lists inside their HTML export. As it turns out, they render the list the same way as we currently do it. They just add a start="N" attribute on each list.
In our case, we can calculate the current index by looking up the current block inside the parents contents list. #6

What's great about your implementation is that it yields semantically correct HTML. That's not given with this solution. It just looks correct.

Nevertheless, I'd prefer the Notion way, since it's quite a minimal solution and doesn't affect the rendering logic that much. What do you think?

@zephraph
Copy link
Author

I’m good with that 👍

@zephraph zephraph closed this May 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numbered lists aren't working
2 participants