souvikinator / notion-to-md

Convert notion pages, block and list of blocks to markdown (supports nesting and custom parsing)
https://www.npmjs.com/package/notion-to-md
MIT License
1.08k stars 90 forks source link

Added support for numbered lists #35

Closed raphtlw closed 2 years ago

raphtlw commented 2 years ago

This fixes issue #18 and even supports nested list items.

I solved this problem by introducing a new hook function that runs after each block's children is listed. I then "inject" a new property into the block object number, which just increments from 1 to max, and then in the rendering stage, use the property to render the numbered list bullets.

Result:

Screenshot 2022-06-21 at 2 19 36 AM Screenshot 2022-06-21 at 2 19 53 AM

🎉

souvikinator commented 2 years ago

This doesn't seem to work. Here is the output:

Notion:

image

Result:

image
souvikinator commented 2 years ago

Hey @raphtlw, my bad. By mistake I merged this PR. I have reverted your commits, feel free to create a new PR.

raphtlw commented 2 years ago

@souvikinator Could you try using the NPM package I published containing my changes? It worked for me and I'm even using it in production.

souvikinator commented 2 years ago

It's still not working. The whole thing is still in bullet format. That's weird. Can you share an example from production where I can see how it is being rendered?

raphtlw commented 2 years ago

@souvikinator Apologies, my dumbass was drunk and thought it was a good idea to remove the function call that adds the numbers to the bullet points 😆 I'll create another pull request and test the fix once more.

raphtlw commented 2 years ago

It worked in development for me, not production and I was just puzzled as to why that was the case, turns out, the development build still had the function call, but not the one in production

raphtlw commented 2 years ago

@souvikinator I've created a new PR #38 which fixes this issue, and includes a link where it's being used in production. Once again, thank you for creating this package, it helps a lot.

P.S. The drunk thing was just a joke, I just missed a minor detail by accident as I wanted to quickly go to sleep.

souvikinator commented 2 years ago

😂 no worries. I'll test it locally and let you know.