Closed alglez closed 8 months ago
I think your solution can solve this issue.
I'm interested in how the data becomes without space. Cause I can see that space in many other softwares. Could you provide more details like the sample data and the code/software you use?
Hi,
I was using trilium_py to import md files from joplin. While testing I realize that some images were not uploaded correctly. Those md are directly joplin generated. So i check the Html file generated by markdown2.markdown and realize that the imgs in question are not detected because based on the regex expression there is a missing white space.
I decided to create an small md example and attach it. In the first example all the images are correctly rendered (but it's not because is detecting all the images, but because all the images are pointing to the same file) in the exampleTwo.md, "example 2" and "example 3" are not imported correctly because those are not detected by the regex expression. examplemd.zip
this:
[<img width="400" height="262" src="./calvin_hobbes-2.jpg"/>](https://news.artnet.com/app/news-upload/2015/01/CalvinHobbes1.jpg)
it's translated to this in html:
<p><a href="https://news.artnet.com/app/news-upload/2015/01/CalvinHobbes1.jpg"><img width="400" height="262" src="./calvin_hobbes-2.jpg"/></a></p>
and this:
<img width="400" height="262" src="./calvin_hobbes-3.jpg"/>
is translated to this:
<p><img width="400" height="262" src="./calvin_hobbes-3.jpg"/></p>
But if you can test the exampleTwo.md let me know if you experience the same problem.
` Name: trilium-py Version: 0.8.6
Name: markdown2 Version: 2.4.12
python version: 3.11.6`
Hi, thank you for providing the detailed reproduction process and examples. I see you've made several test examples, that could really help.
But I'm on vacation now, and do not have a computer at hand. I will have a good look at this once I come back.
I've just applied the fix and published a new version.
Perfect.
There are certain images that are not recognized correctly when importing markdown files.
<p><img width="736" height="414" src="../certainpath.jpg"/></p>
that is due to the fact that the regex expression in
pat = '<img (.*?) />'
is expecting a white space just before "/>". And that is not always the case (even with though all the code is generated by markdown2markdown.the simplest solution is to change that line to:
pat = '<img (.*?)/>'
But i'm not sure that that change could generate problems with other images (not that i can think of)