Cobertos / md2notion

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

Issue with big README file #1

Closed Klaudioz closed 4 years ago

Klaudioz commented 4 years ago

I have the following issue:

`Uploading README.md to Notion.so at page README.md Traceback (most recent call last): File "/usr/local/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/usr/local/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/upload.py", line 93, in upload(mdFile, newPage) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/upload.py", line 60, in upload rendered = convert(mdFile, notionPyRendererCls) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/upload.py", line 45, in convert return mistletoe.markdown(mdFile, notionPyRendererCls) File "/usr/local/anaconda3/lib/python3.7/site-packages/mistletoe/init.py", line 19, in markdown return renderer.render(Document(iterable)) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 53, in render rendered = self.render_maptoken.class.name File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 106, in render_document return self.renderMultiple(token.children) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 61, in renderMultiple rendered = list(flatten([self.render(t) for t in tokens])) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 61, in rendered = list(flatten([self.render(t) for t in tokens])) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 53, in render rendered = self.render_maptoken.class.name File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 218, in render_list return self.renderMultiple(token.children, passthrough=True) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 61, in renderMultiple rendered = list(flatten([self.render(t) for t in tokens])) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 61, in rendered = list(flatten([self.render(t) for t in tokens])) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 53, in render rendered = self.render_maptoken.class.name File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 247, in render_list_item 'title': self.renderMultipleToString(token.children) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 103, in renderMultipleToString return "".join([toString(t) for t in tokens]) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 103, in return "".join([toString(t) for t in tokens]) File "/usr/local/anaconda3/lib/python3.7/site-packages/md2notion/NotionPyRenderer.py", line 100, in toString raise RuntimeError(f"Can't render to string: {tokenType} inside inline element @ \n{parseStack}") RuntimeError: Can't render to string: List inside inline element @ Document.children[30]

✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,✓,List.children[1] ✓,ListItem.children[2] `

I've attached the file. Unfortunately I'm unable to debug the error. It looks like the RuntimeError is not showing the value of the variables involved.

I got the file from here: https://github.com/trimstray/test-your-sysadmin-skills/blob/master/README.md and I deleted the tables and any h4, h5 and h6.

readme.zip

Cobertos commented 4 years ago

Hmm, sounds like a nested lists issue perhaps and possibly some Markdown notion-py or Notion.so might not support.

H4-H6 should be handled by auto conversion to H3 but tables for now should be deleted, yeah.

Will take a look when I get home tonight or in the week. Thanks for the report

Cobertos commented 4 years ago

As an update to this it ended up being nested lists and I have a fix coming shortly (along with some other features).

I'll probably link to a converted version of that MD file when done. It only took like 3 seconds to convert but took > 30 minutes to upload it to Notion, as notion-py doesn't have any sort of batching feature (I don't even know if Notion.so's unofficial API even supports anything like that as of this time anyway)

Cobertos commented 4 years ago

Here's most of the MD file, it actually timed out because I fell asleep before it finished. https://www.notion.so/P-README-md-ce3c1f31ba9942f4ab4947bfa0012232

Cobertos commented 4 years ago

@Klaudioz Good to go! Should work for you now