Cobertos / md2notion

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

Markdown links with hyphens (-) are turned into triple em-dashes #13

Closed bessey closed 3 years ago

bessey commented 4 years ago

When I upload a document which contains a link with hyphens, e.g.:

- [G Suite User Configuration](https://wiki.blah.com/books/aws-access/page/g-suite-user-configuration)

The resulting link URL is:

https://wiki.blah.com/books/aws%E2%B8%BBaccess/page/g%E2%B8%BBsuite%E2%B8%BBuser%E2%B8%BBconfiguration

%E2%B8%BB == the triple em-dash symbol. Its breaking all my wiki links :(

Confusingly, if right click the link in Notion and choose "copy link", I get the correct hyphenated version out instead of the em-dash one. But if I just click the link, no such luck.

FWIW If I upload the Markdown file directly through Notion's UI, the bug does not occur.

I have checked with hexdump that the Markdown file I am importing from truly contains an ASCII hyphen, and it does:

> hexdump -cb "./013-Single Sign-On--AWS Federated Access.md"
...
00005a0   s   s   /   p   a   g   e   /   a   w   s   -   c   o   n   s
00005a0 163 163 057 160 141 147 145 057 141 167 163 055 143 157 156 163
...
Cobertos commented 4 years ago

Really busy with a work project but I should be able to get to this in the next week and a half.

EDIT: From my initial look, it seems like Mistletoe doesn't so anything weird (see below for default HTML renderer output)

<ul>
<li><a href="https://wiki.blah.com/books/aws-access/page/g-suite-user-configuration">G Suite User Configuration</a></li>
</ul>

My guess is this is something in notion-py's upload process...

EDIT 2: Yup... https://github.com/jamalex/notion-py/blob/master/notion/markdown.py#L122

Something funky going on with the code in there.

Might want to make a PR over there though it's less active rn IIRC. Could wait until Notion's official API comes out whenever too.

Cobertos commented 4 years ago

Seems like this is caused by https://github.com/jamalex/notion-py/issues/155

Cobertos commented 3 years ago

Looks like this got fixed in notion-py @ version 0.0.26. So that just needs a version bump and it should be good.

Cobertos commented 3 years ago

Bumped the version, this should be fixed