Inconsistency in how image paths are handled between markdown links and img hrefs #6403
Closed
7 tasks done
Labels
bug
An error in the Docusaurus core causing instability or issues with its execution
closed: working as intended
This issue is intended behavior, there's no need to take any action.
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
(I'd be happy to work on this issue if someone can point me in the right direction to get started)
It could be argued this is not a bug, but it is certainly unintuitive behaviour that makes things a little harder to work with.
Consider a folder in
docs
that contains a markdown file and an image (this is a pattern that I think could be pretty comon - each docs page contains its own folder of images, i.e. co-locating images with their associated document, if they are specific to the document, rather than shared across the site):The following markdown snippet will correctly render the image:
As this works. GitHub also correctly renders this in pull requests etc.
I think the user would expect that the following would also work:
This form might be used if you want to control the style/width of an image. The snippet above also renders correctly in a GitHub markdown preview in a code change.
However, instead we have to use this form:
This works - however it is unintuitive that this form has to be used given that the pure markdown version works with relative paths properly. It also means that typical markdown previewing tools (such as GitHub's own markdown renderer) fail to render the images. This just makes the process of working with images that are co-located with documents a bit more painful.
I love the tool - I'm migrating Effective Shell to Docusaurus at the moment - one of the reasons I prefer it to Hugo is that I don't have to use weird platform specific features (like
relref
in Hugo) - I can just use plain old markdown links. But thisimg
behaviour is a little odd. I understand it's a low priority issue with a simple workaround, but feels like the entire tool would be a little more user friendly (especially for complex folder structures like mine) if it was possible to use plain old relative paths inimg
tags.An example of this inconsistency (which also shows how GitHub fails to render the
img
tags properly) is at: https://github.com/dwmkerr/effective-shell/blob/main/effective-shell/docs/01-transitioning-to-the-shell/01-getting-started/index.mdPlease see the sandbox at: https://codesandbox.io/s/serene-butterfly-fz6tk?file=/docs/image-issue/image-issue.md
Steps to reproduce
Please see above, or the code at:
Expected behavior
Image tags would be able to reference images using relative paths without any special treatment.
Actual behavior
Image tags that reference images in relative paths require us to use
require
- this fails to preview in many common markdown renderers - such as GitHub's own renderer, meaning we are more likely to make mistakes when using these paths.Your environment
effective-shell
Reproducible demo
https://github.com/dwmkerr/effective-shell/tree/main/effective-shell
Self-service
The text was updated successfully, but these errors were encountered: