# 暗黑模式下几乎无法阅读的代码高亮

**URL:** https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334
**Category:** Bug
**Tags:** accessibility
**Created:** [2022年五月6日 15:06 UTC](https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334 "2022-05-06T15:06:58Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hugovk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hugovk/32/256348_2.png) [@hugovk](https://meta.discourse.org/u/hugovk)
#### Post date: [2022年五月6日 15:06 UTC](https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334/1 "2022-05-06T15:06:58Z")

</div>

在 Python Discourse 上，使用暗模式的代码块时，一些高亮显示使代码难以阅读。

例如：

```python
class do(partial):
    def __rmatmul__ (self, iterables):
        self.results = tuple(map(self, iterables))

```

看起来像这样，其中 `tuple` 和 `map` 几乎看不见：

 ![image](https://global.discourse-cdn.com/meta/original/4X/8/b/f/8bf38080905b8e56be762e40166d488f7659e62b.png)

（在第一个三反引号后添加 `python` 没有区别。）

Chrome 的开发者工具报告的对比度为 1.2，而 [最低 AA 指南为 4.5 和 7.0](https://web.dev/color-and-contrast-accessibility/?utm_source=devtools)：

_[由于新用户限制，已删除屏幕截图]_

（WAVE Web 可访问性评估工具无法在该页面上运行。） _[由于新用户限制，已删除链接]_

这是使用默认 Discourse 设置的情况。

我知道可以选择其他主题，但请您确保默认的语法高亮在暗模式下也能正常工作？这也是一个可访问性问题。

原始讨论地址：

> **[Almost invisible colors in dark mode syntax highlighting](https://discuss.python.org/t/almost-invisible-colors-in-dark-mode-syntax-highlighting/12027?u=hugovk)**
>
> In dark mode syntax highlighting some text colors are almost impossible to read. See for example the callable identifiers tuple and map here: It is almost impossible to distinguish the dark color of the text from the grey background. Could you...

谢谢！☺

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2022年五月9日 07:28 UTC](https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334/2 "2022-05-09T07:28:55Z")

</div>

我们会解决这个样式的！感谢告知 ❤

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [2022年五月18日 13:59 UTC](https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334/12 "2022-05-18T13:59:43Z")

</div>

感谢 @hugovk 报告此问题。

此拉取请求修复了深色主题的突出显示颜色。

> <https://github.com/discourse/discourse/pull/16859>
>
> Colour for hljs-builtin-name highlight wasn't very readable in dark mode
> https:…//meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334/8
> 
> before ("tuple" & "map"):
> \<img width="697" alt="image" src="https://user-images.githubusercontent.com/101828855/169048399-356745d5-f5c8-40d5-8816-8742a4c7eff5.png"\>
> 
> after:
> \<img width="712" alt="image" src="https://user-images.githubusercontent.com/101828855/169048330-e8edcf6d-8635-482d-8f76-b4946dba880e.png"\>

此主题将在几天后关闭。

---

<div class="post-metadata">

### Author: ![hugovk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hugovk/32/256348_2.png) [@hugovk](https://meta.discourse.org/u/hugovk)
#### Post date: [2022年五月18日 19:36 UTC](https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334/13 "2022-05-18T19:36:48Z")

</div>

谢谢您快速的响应和修复！🚀

---

<div class="post-metadata">

### Author: ![chapoi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapoi/32/537252_2.png) [@chapoi](https://meta.discourse.org/u/chapoi)
#### Post date: [2022年五月21日 07:00 UTC](https://meta.discourse.org/t/almost-unreadable-code-highlighting-in-dark-mode/226334/14 "2022-05-21T07:00:33Z")

</div>

此主题在 2 天后自动关闭。不再允许回复。
