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.11k stars 91 forks source link

(patch) check for rich_text property #24

Closed emoriarty closed 2 years ago

emoriarty commented 2 years ago

Fix for issue #23.

In order to keep support to prior versions of @notionhq/client@1.0.0, rich_text is added in the logical OR expression.

I've tested it in a personal project and it works OK.

Screen Shot 2022-03-05 at 07 07 54

Converts to:

# Heading 1

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis neque vel odio lobortis posuere nec sit amet erat. Morbi congue velit quis ante accumsan volutpat. Nam ornare enim eu metus consectetur facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut convallis erat, eget egestas magna. Nunc non orci at ante placerat pretium in id justo. Morbi a mattis lacus. Nulla tempus, massa a cursus porta, risus leo varius urna, euismod tristique ante metus vitae lacus.

## Heading 2

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis neque vel odio lobortis posuere nec sit amet erat. Morbi congue velit quis ante accumsan volutpat. Nam ornare enim eu metus consectetur facilisis. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut convallis erat, eget egestas magna. Nunc non orci at ante placerat pretium in id justo. Morbi a mattis lacus. Nulla tempus, massa a cursus porta, risus leo varius urna, euismod tristique ante metus vitae lacus.

### Heading 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla quis neque vel odio lobortis
emoriarty commented 2 years ago

Tested the patch locally and it works, however, gives compilation error. A small change on line 199 will fix the compilation error as well. Change paragraph: { text: cell }, to paragraph: { rich_text: cell },

That's funny. I did run the build script and did not see any compilation error. Perhaps, did you mean a runtime error?

Anyway, I'm pushing the change. Let me know if it works OK.

souvikinator commented 2 years ago

I did run the build script and did not see any compilation error.

Yes, the build script didn't give any errors but compiling only notion-to-md.ts using tsc command throws an error. Nvm, it's fixed now.

Thanks for reporting and contributing, I'll create a new release shortly.