Cobertos / md2notion

A better Notion.so Markdown importer
MIT License
654 stars 65 forks source link

Add support for inline math equation and block math equation #20

Closed magic3007 closed 3 years ago

magic3007 commented 3 years ago

Now Notion has supported the inline math equation and the block math equation. Is it possible to add support for inline markdown math equation like $x=x+1$ and block math equation like $$ E=mc^2 $$

wongsingfo commented 3 years ago

mistletoe supports parsing math equation and notion-py seems to provide the equation block. It should be easy to add this feature (x

FYI: https://github.com/miyuchina/mistletoe/blob/8f2f0161b2af92f8dd25a0a55cb7d437a67938bc/mistletoe/latex_token.py https://github.com/jamalex/notion-py/blob/b7041ade477c1f59edab1b6fc025326d406dd92a/notion/block.py#L568

Cobertos commented 3 years ago

I don't really want to add a bunch of non-standard Markdown extensions to the default library, but providing an API to add such extensions seems fine. It sounds like @wongsingfo might have already messed with this a bit

wongsingfo commented 3 years ago

I found that it appears to be hard to add the inlined equation (though adding equation block is quite simple). The bottleneck is that the notion-py library does not provide a way to convert markdown into notion api format or vice versa. Specifically, notion-py depends on commonmark, which is a "strongly defined and highly compatible specification of Markdown" and doesn't support equations. It seems that everyone tries to avoid non-standard markdown extensions when possible...

storopoli commented 3 years ago

Also looking forward for math support! 🤗

Cobertos commented 3 years ago

Bumped the version and merged @EgorDm 's PR. The upstream PR is in as well.