joplin-rich-markdown icon indicating copy to clipboard operation
joplin-rich-markdown copied to clipboard

Image tags immediately followed by some text don't render

Open laurent22 opened this issue 2 years ago • 1 comments

The plugin supports IMG tags like so:

<img src=":/5d1ac6e676094f4f908c1d0a65694eff"/> 

However when it is followed by some text like this: <img src=":/5d1ac6e676094f4f908c1d0a65694eff"/>some text  it doesn't render the image, even though the preview does. This kind of text often comes up with clipped content because the markup is not quite clean.

I was about to create a pull request to fix it, but I see that the plugin purposely only considers images that are followed by a space:

https://github.com/CalebJohn/joplin-rich-markdown/blob/main/src/images.ts#L6

So I'm not sure if it's like this to go around some bug, or if we can actually remove this requirement for a space after the image?

laurent22 avatar Mar 08 '22 15:03 laurent22

It's done this way because I don't want to handle multiple images on a single line (it's the same for markdown images as well). For example, sometimes the renderer will place images together horizontally, or place text next to an image. My intention was that these situations would be covered by using the image popup on hover (I didn't think that people would use inline images much and would prefer the image hover).

I've slowly been coming around to the idea that I should remove this limitation and simply draw every image one after the other.

The first step is to remove the requirement that an image has to be alone (allow other text, but not other images). And the second step would be to start rendering all images on a line. If you're looking for a quick fix, feel free to go ahead and tweak the regex so it fits your needs. Otherwise, I'll find some time soon to drop the lonely-line requirement.

CalebJohn avatar Mar 09 '22 06:03 CalebJohn