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

MrR*_*ROY 66 markdown github

伙计们

我想在github中的Markdown文件中显示一些图像.我发现它的工作原理如下:

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

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

我试着用这个:

![Figure 1-1](images/figure 1-1.png "Figure 1-1")
Run Code Online (Sandbox Code Playgroud)

它适用于我的本地磁盘,但不适用于github.

有谁知道这个问题?谢谢.

MrR*_*ROY 118

我自己找到了答案.

只需简单地将?raw = true附加到图像网址即可:

![](images/table 1-1.png?raw=true)
Run Code Online (Sandbox Code Playgroud)

  • 当直接在 GitHub 上查看 Markdown 文件时,这对我有用,但不适用于项目主页上显示的 README.markdown 文件。 (2认同)

foz*_*foz 11

我只是遇到了同样的问题,结果是由URL中的空格引起的.手动将URL空间编码为%20固定空间.

所以使用你的例子我改变了:

![](images/table 1-1.png)
Run Code Online (Sandbox Code Playgroud)

至:

![](images/table%201-1.png)
Run Code Online (Sandbox Code Playgroud)

编辑:我向github询问了这个问题,自从他们转移到渲染Markdown 的新规范以来,这是预期的行为.规范明确禁止URI中的空格,因为现在使用空格将URI与可选图像标题分开.规范的相关部分在这里:

https://github.github.com/gfm/#example-471 - 即使用尖括号括起来,目的地也不能包含空格或换行符

  • 从那时起他们一定改变了规范,因为现在如果用尖括号括起来,则允许空格。https://github.github.com/gfm/#example-497 (2认同)