Github Darkmode vs lightmode images and PyPi

huangapple go评论72阅读模式
英文:

Github Darkmode vs lightmode images and PyPi

问题

GitHub支持多种方式来根据深色/浅色模式显示标志。不知何故,当GitHub存储库是上传到PyPi的Python项目时,这些选项中的任何一个似乎都无法正常工作。

这是我尝试过的方法以及在PyPi上的效果:

![CoGuard Logo Dark](https://github.com/coguardio/coguard-cli/raw/master/logo_dark_mode.png#gh-dark-mode-only)![CoGuard_Light_Logo](https://github.com/coguardio/coguard-cli/raw/master/logo.png#gh-light-mode-only)

这似乎在PyPi页面上显示了与此处在Stack Overflow上显示的相同效果:

Github Darkmode vs lightmode images and PyPiGithub Darkmode vs lightmode images and PyPi

即,在PyPi页面上同时显示两个标志。

选项2:

<p align="center">
  <picture>
    <source srcset="https://github.com/coguardio/coguard-cli/raw/master/logo_dark_mode.png" media="(prefers-color-scheme: dark)">
    <img src="https://github.com/coguardio/coguard-cli/raw/master/logo.png" alt="Light mode logo" width="500">
  </picture>
</p>

在PyPi中,这看起来像下面这样:

Github Darkmode vs lightmode images and PyPi

好的,这是我向社区提出的总体问题:如何以正确的方式拥有深色/浅色标志并确保它们在GitHub和PyPi中正确显示?

英文:

GitHub supports multiple ways to have a logo displayed depending on dark/light mode. Somehow, any of these options do not seem to work well when the GitHub repository is a Python project uploaded to PyPi.

Here is what I tried, and the effects in PyPi:

![CoGuard Logo Dark](https://github.com/coguardio/coguard-cli/raw/master/logo_dark_mode.png#gh-dark-mode-only)![CoGuard_Light_Logo](https://github.com/coguardio/coguard-cli/raw/master/logo.png#gh-light-mode-only)

Which seems to show the same effect as here on Stack overflow:
Github Darkmode vs lightmode images and PyPiGithub Darkmode vs lightmode images and PyPi

I.e., both logos are displayed at the same time on the PyPi page.

Option 2:

&lt;p align=&quot;center&quot;&gt;
  &lt;picture&gt;
    &lt;source srcset=&quot;https://github.com/coguardio/coguard-cli/raw/master/logo_dark_mode.png&quot; media=&quot;(prefers-color-scheme: dark)&quot;&gt;
    &lt;img src=&quot;https://github.com/coguardio/coguard-cli/raw/master/logo.png&quot; alt=&quot;Light mode logo&quot; width=&quot;500&quot;&gt;
  &lt;/picture&gt;
&lt;/p&gt;

This looks in PyPi like the following:

Github Darkmode vs lightmode images and PyPi

Okay, here is my overarching question to the community: What is the right way to have dark/light logos AND have them correctly displayed in both GitHub and PyPi?

答案1

得分: 1

我找到了一个解决方法。
我创建了第二个README文件,然后将第二个适用于PYPI的README添加到我的Python项目的setup.cfg中。

然后,我在我的流水线中添加了一个额外的测试,以确保在标志部分之后这两个文件之间没有差异,通过确保此差异为空来实现:

diff &lt;(tail -n +8 README.md) &lt;(tail -n +3 README_PYPI.md)

英文:

I figured out a work-around.
I created a second README file, and then added to my setup.cfg of the python project the second, PYPI friendly, README.

Then I added an additional test to my pipeline which ensured that there is no diff between those files after the logo section by ensuring that this diff is empty:

diff &lt;(tail -n +8 README.md) &lt;(tail -n +3 README_PYPI.md)

huangapple
  • 本文由 发表于 2023年2月24日 12:27:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75552648.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定