fix: do not prepend bg: to noinherit style directives (#4939)

Pygments does not understand a "background" of `noinherit`, only
`noinherit` -- so if we are setting `noinherit`, even for a background
color, we do not prepend `bg:`
This commit is contained in:
Gil Forsyth 2022-09-15 09:48:43 -04:00 committed by GitHub
parent 84405423df
commit 7365ad1bc0
Failed to generate hash of commit
2 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,24 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* ``pygments`` startup crash when incorrect prepending ``bg:`` to ``noinherit``
style directives
**Security:**
* <news item>

View file

@ -177,7 +177,10 @@ def color_name_to_pygments_code(name, styles):
fgcolor = color
else:
fgcolor = styles[getattr(Color, color)]
res = "bg:" + fgcolor
if fgcolor == "noinherit":
res = "noinherit"
else:
res = f"bg:{fgcolor}"
else:
# have regular, non-background color
mods = parts["modifiers"]