Cobertos / md2notion

A better Notion.so Markdown importer
MIT License
657 stars 66 forks source link

Fix image block error #2

Closed sankoshine closed 4 years ago

sankoshine commented 4 years ago

Image blocks were always giving "can't add image to inline context" error.

All image block are treated as span tokens and should be wrapped as children of a paragraph, which is a block token. So every time render_image is called, a render_paragraph is following.

Cobertos commented 4 years ago

@sankoshine Do you have a copy of the markdown you were trying to convert? It would be nice to add a test for this issue doesn't crop up in the future.

I going to have to give this some more thought. We definitely want to convert images in paragraphs, but it would be nice to have this be less specific to one corner case of markdown and see where the underlying problem is (perhaps treating paragraphs as dummy containers until the very end of conversion...)

sankoshine commented 4 years ago

I tried your hexo example and found even the simplest markdown doesn't work:

---
title: "foo"
date: 2010-04-24 17:06:00
tags:
categories: 
---

![bar](img1.jpg)
Cobertos commented 4 years ago

Odd, I must've fucked up something pretty bad in the last update, I'll have to make sure I add more comprehensive unit tests and add a more general smoke testy sort of case in there.

Cobertos commented 4 years ago

@sankoshine Alright, this should be fixed in v1.1.0. This actually fixes a bunch of corner cases too including images embedded in text like **text![]()text** where previously it would just throw.

Cobertos commented 4 years ago

Going to close this as the fix has been applied. Thank you for the report and effort!