How to display images in Markdown files on Github?

后端 未结 2 563
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 22:09

I want to display some images in a Markdown file on Github. I found it works this way:

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


        
相关标签:
2条回答
  • 2021-01-29 22:31

    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)
    
    0 讨论(0)
  • 2021-01-29 22:33

    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)
    

    Edit: I asked github about this and it is expected behaviour ever since they moved to a new spec for rendering Markdown. The spec explicitly disallows spaces in URIs, because a space is now used to separate the URI from an optional image title. The relevant part of the spec is here:

    https://github.github.com/gfm/#example-471 -- The destination cannot contain spaces or line breaks, even if enclosed in pointy brackets

    0 讨论(0)
提交回复
热议问题