如何将屏幕截图添加到 github 存储库中的自述文件? [英] How to add screenshot to READMEs in github repository?

查看:35
本文介绍了如何将屏幕截图添加到 github 存储库中的自述文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 GitHub 存储库的 README 文件中放置屏幕截图?语法是什么?

Is it possible to place a screenshot in README file in a GitHub repository? What's the syntax?

推荐答案

如果你使用 Markdown (README.md):

If you use Markdown (README.md):

如果您的存储库中有图像,则可以使用相对 URL:

Provided that you have the image in your repo, you can use a relative URL:

![Alt text](/relative/path/to/img.jpg?raw=true "Optional Title")

如果您需要嵌入托管在别处的图片,您可以使用完整网址

If you need to embed an image that's hosted elsewhere, you can use a full URL

![Alt text](http://full/path/to/img.jpg "Optional title")

GitHub 建议您使用带有 ?raw=true 参数的相对链接,以确保分叉的存储库点正确.

GitHub recommend that you use relative links with the ?raw=true parameter to ensure forked repos point correctly.

raw=true 参数是为了确保您链接到的图像将按原样呈现.这意味着只会链接到图像,而不是该相应文件的整个 GitHub 界面.请参阅此评论 了解更多详情.

The raw=true parameter is there in order to ensure the image you link to, will be rendered as is. That means that only the image will be linked to, not the whole GitHub interface for that respective file. See this comment for more details.

查看示例:https://raw.github.com/altercation/solarized/master/README.md

如果您使用 SVG,那么您还需要将 sanitize 属性设置为 true:?raw=true&sanitize=true.(感谢@EliSherer)

If you use SVGs then you'll need to set the sanitize attribute to true as well: ?raw=true&sanitize=true. (Thanks @EliSherer)

此外,README 文件中的相关链接文档:https://help.github.com/articles/relative-links-in-readmes

Also, the documentation on relative links in README files: https://help.github.com/articles/relative-links-in-readmes

当然还有降价文档:http://daringfireball.net/projects/markdown/syntax

此外,如果您创建一个新分支 screenshots 来存储图像,您可以避免它们在 master 工作树中

Additionally, if you create a new branch screenshots to store the images you can avoid them being in the master working tree

然后您可以使用以下方法嵌入它们:

You can then embed them using:

![Alt text](/../<branch name>/path/to/image.png?raw=true "Optional Title")

这篇关于如何将屏幕截图添加到 github 存储库中的自述文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆