Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link is deleted even though no image was found #18

Closed
axelle50 opened this issue Sep 26, 2022 · 5 comments
Closed

Link is deleted even though no image was found #18

axelle50 opened this issue Sep 26, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@axelle50
Copy link

Hello

My users may introduce a mistake when writing markdown, tagging an important link as an image. As a result, the tool will try to download the html and then delete the link. Losing the link from the article is a problem.

For example in a md file containing

Important link to remember: ![](https://www.google.com/)

the link would be deleted when processing the article, resulting in the following

Important link to remember: ![](.html)

A solution to this particular case would be to raise an exception when replacing the image link if the file name is empty. In www_tools.py after line 73 in function get_filename_from_url, add

if f_name == "": raise ValueError(f'F_name is empty {req.url}')

However, the problem would persist for certain links.

Important link: ![](https://github.com/artiomn/markdown_articles_tool)
would still be replaced by
Important link: ![](markdown_articles_tool.html)

In this case it would be necessary to check the MIME type of the downloaded content before replacing the link.

@artiomn artiomn added the bug Something isn't working label Oct 1, 2022
@artiomn
Copy link
Owner

artiomn commented Oct 4, 2022

Thank you for the informative description. Now work in progress. I'll merge this bugfix with the big change.

@artiomn
Copy link
Owner

artiomn commented Oct 5, 2022

Fixed.

@artiomn
Copy link
Owner

artiomn commented Oct 5, 2022

@artiomn artiomn closed this as completed Oct 5, 2022
@axelle50
Copy link
Author

axelle50 commented Oct 6, 2022

Thank you. It seems to work fine for what I have tested so far.

@artiomn
Copy link
Owner

artiomn commented Oct 6, 2022

You're welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants