Skip to content

Commit

Permalink
Make dark colours more vivid in order to meet WCAG AA contrast.
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 committed Sep 18, 2024
1 parent 6ab63c7 commit cb8068a
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 33 deletions.
22 changes: 22 additions & 0 deletions example-code/document.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Example MarkDown Document

## Heading two

Not much to see here.

Except some ~~deleted text~~ using the [CommonMark](https://commonmark.org/)
flavour.

## Python code example

This is a simple Python code example:
```python
class MyClass:
"An uncomplicated class."

def __init__(self):
pass
```

### Heading three
That's it.
28 changes: 14 additions & 14 deletions falconry_pygments_theme/dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
# limitations under the License.

from pygments.style import Style
from pygments.token import (
Comment,
Error,
Generic,
Keyword,
Name,
Number,
Operator,
String,
Token,
)
from pygments.token import Comment
from pygments.token import Error
from pygments.token import Generic
from pygments.token import Keyword
from pygments.token import Name
from pygments.token import Number
from pygments.token import Operator
from pygments.token import String
from pygments.token import Token

from .common import bold, italic, bold_italic
from .common import bold
from .common import bold_italic
from .common import italic


class Colors:
yellow = '#ffc66d'
orange = '#c26230'
crimson = '#dc143c'
orange = '#df5a1f'
crimson = '#ed3b5f'
brown = '#bc9458'
green = '#a5c261'
pear = '#c9cc3f'
Expand Down
24 changes: 12 additions & 12 deletions falconry_pygments_theme/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
# limitations under the License.

from pygments.style import Style
from pygments.token import (
Comment,
Error,
Generic,
Keyword,
Name,
Number,
Operator,
String,
Token,
)
from pygments.token import Comment
from pygments.token import Error
from pygments.token import Generic
from pygments.token import Keyword
from pygments.token import Name
from pygments.token import Number
from pygments.token import Operator
from pygments.token import String
from pygments.token import Token

from .common import bold, italic, bold_italic
from .common import bold
from .common import bold_italic
from .common import italic


class Colors:
Expand Down
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,29 @@ license-files = ["LICENSE"]
target-version = "py38"
format.quote-style = "single"
line-length = 79

[tool.ruff.lint]
select = [
"C9",
"E",
"F",
"W",
"I"
]

[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.ruff.lint.isort]
case-sensitive = false
force-single-line = true
order-by-type = false
single-line-exclusions = [
"typing",
]
force-sort-within-sections = true

[tool.pytest]
testpaths = [
"tests",
]
13 changes: 13 additions & 0 deletions tests/test_dark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pytest

from falconry_pygments_theme.dark import Colors
from falconry_pygments_theme.dark import FalconryDarkStyle

_color_names = sorted(name for name in dir(Colors) if not name.startswith('_'))


@pytest.mark.parametrize('color_name', _color_names)
def test_contrast(contrast, color_name):
value = getattr(Colors, color_name)
if value != FalconryDarkStyle.background_color:
assert contrast(value, FalconryDarkStyle.background_color) >= 'AA'
11 changes: 4 additions & 7 deletions tests/test_light.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import pytest

from falconry_pygments_theme.light import Colors
from falconry_pygments_theme.light import FalconryLightStyle


_color_names = sorted(
name
for name in dir(Colors)
if not (name.startswith('_') or name == 'light')
)
_color_names = sorted(name for name in dir(Colors) if not name.startswith('_'))


@pytest.mark.parametrize('color_name', _color_names)
def test_contrast(contrast, color_name):
value = getattr(Colors, color_name)
assert contrast(value, Colors.light) >= 'AA'
if value != FalconryLightStyle.background_color:
assert contrast(value, FalconryLightStyle.background_color) >= 'AA'
17 changes: 17 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[tox]

envlist = ruff, py

[testenv]
deps =
pytest
commands =
pytest -v tests/ []

[testenv:ruff]
deps =
ruff
skip_install = True
commands =
ruff check
ruff format --check

0 comments on commit cb8068a

Please sign in to comment.