如何在 Github 上显示 Markdown 文件中的图像?

我想在 Github 上的 Markdown 文件中显示一些图片,我发现它是这样工作的:

![Figure 1-1](https://raw.github.com/username/repo/master/images/figure 1-1.png "Figure 1-1")

但我需要与其他人合作,所以我不想用户名和回购名称硬编码。

我试着用这个:

![Figure 1-1](images/figure 1-1.png "Figure 1-1")

它可以在我的本地磁盘上工作,但不能在 Github 上工作。

有人知道这件事吗?

78803 次浏览

I found the answer myself.

Just simply append ?raw=true to the image url will make the trick:

![](images/table 1-1.png?raw=true)

I just had the same issue and it turned out to be caused by the space in the URL. Manually URL encoding the space as %20 fixed it.

So using your example I changed:

![](images/table 1-1.png)

to:

![](images/table%201-1.png)

2021 Edit: Thanks Emilio for pointing out that the GitHub flavored markdown spec has been updated to allow spaces in filenames when the filename is enclosed inside "pointy" (angle) brackets:

The destination can only contain spaces if it is enclosed in pointy brackets
Example 498
[link](</my uri>) --> <p><a href="/my%20uri">link</a></p>

Ref: https://github.github.com/gfm/#example-498 (scroll up for description)

This works with images too so we can now also use:

![](<images/table 1-1.png>)