typora / typora-issues

Bugs, suggestions or free discussions about the minimal markdown editor — Typora
https://typora.io
1.53k stars 58 forks source link

image links break if path has "?" (and likely for other characters) #4707

Open vassudanagunta opened 2 years ago

vassudanagunta commented 2 years ago

I have an image file named what now?.webp. If I embed it as an image in a Markdown file, it only displays the markup, not the image. If I rename the file and remove the "?" from the link, the image is displayed.

I tried using %3F in the markdown link path, and it still didn't work.

"?" is a legitimate character to have in a filename. This should work.


martinguenther commented 2 years ago

When writing Markdown, I add additional rendering information to images as anchor, like #no-scale in

![](media/permission-types.png#no-scale)

which is then used to manipulate the generated HTML output by Hugo, which I use for site creation.

Since I've updated to typora version 0.11.8 - coming from 0.9.? - images with anchors in the file path are no longer shown in the editor. I am sure this has worked in the past. Probably this is related to the issue reported here.

1999FordFocus commented 1 year ago

This happens to me too!

In my case, I'm using a relative image path, the path itself doesn't contain a question mark, but there is a question mark in the parent folder.

I'm pretty confused while debugging this issue, hope we could fix this asap.

abnerlee commented 1 year ago

Please escape ? char, since it is use as GET parameter in url/HTML.

vassudanagunta commented 1 year ago

@abnerlee Typora should do the escaping because:

  1. It is part of the job of rendering the Markdown file to HTML, just as is converting ** to <strong> and .md to .html.
  2. There are no GET parameters in local Markdown file to Markdown file links (links from one .md file to another)
  3. GET parameters are only relevant for HTML files (so they work when opened in a browser)
  4. You are (CORRECTLY!) not forcing us to manually convert space characters in Markdown filenames to %20 in links to those files, so why force us to convert ?? That is inconsistent and broken.

Please re-open this issue.

1999FordFocus commented 1 year ago

This also happens to an anchor link which contains a slash /.

1999FordFocus commented 5 months ago

This happens to me too!

In my case, I'm using a relative image path, the path itself doesn't contain a question mark, but there is a question mark in the parent folder.

I'm pretty confused while debugging this issue, hope we could fix this asap.

Issue detail screenshot supplement:

image