1

我正在尝试在我正在处理的 GitHub 项目的 README.rst 文件中包含 Shield IO 徽章。Shield IO 徽章具有编码两个链接的功能(一个在徽章的左侧,一个在徽章的右侧),我想将其包含在项目 README 中。从https://shields.io/,为了使用双链接功能,徽章必须以 HTML 编码<object>标签。reStructuredText 具有 raw 功能,可以在文件中包含 HTML 代码片段,这些文件被解析并包含在 README 中。PyCharm 解释器可以正确解析 HTML,并且存在双链接功能。但是,当我将文件推送到 GitHub 时,根本没有解析 HTML。很好奇是否有办法在 GitHub README 文件中获得此功能(不一定必须是 reStructuredText)。

例子:

.. raw:: html

       <object data="https://img.shields.io/static/v1?label=Question&message=Unanswered&color=lightgrey&link=https://stackoverflow.com/&link=https://stackoverflow.com/questions/66716288/embedding-shields-io-badge-html-in-github-readme-rst"></object>

示例徽章图片:

示例 Shield IO 徽章图像

使用双链路功能链接到 Shield IO 静态徽章:

https://img.shields.io/static/v1?label=Question&message=Unanswered&color=lightgrey&link=https://stackoverflow.com/&link=https://stackoverflow.com/questions/66716288/embedding-shields-io-徽章-html-in-github-readme-rst

4

2 回答 2

1

这是不可能的。Github 从 Markdown 和 reStructuredText 中的 SVG 中剥离链接。在 Github 上查看此问题。

如何在 GitHub 上指定左右的链接 #5593

于 2021-03-19T23:24:26.673 回答
1

如果您将 <img> 标记与 Shield.io 徽章包装在一起,并带有包含所需链接的 <a> 标记,则它可以工作。我知道在 Markdown 中使用 HTML 是不受欢迎的,但这是我发现的唯一方法,可以按照你的意愿工作。

<a href="https://stackoverflow.com/questions/66716288/embedding-shields-io-badge-html-in-github-readme-rst"><img src="https://img.shields.io/static/v1?label=Question&message=Unanswered&color=lightgrey&link=https://stackoverflow.com" /></a>
于 2021-07-29T03:44:28.867 回答