From 8cfc6823a7a74d20d0f32000f3b967de770d1a9f Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Mon, 1 Nov 2021 15:27:45 +0100 Subject: Prohibit contrast degradation for styles via test (#1919) Web accessibility is important. Unfortunately currently many pygments styles have rules with poor contrasts. This commit introduces a test case that fails if the minimum contrast of a style gets worse, e.g: E AssertionError: contrast degradation for style 'borland' E The following rules have a contrast lower than the required 2.9: E E * 1.90 Token.Text.Whitespace E * 2.80 Token.Generic.Heading E * 2.30 Token.Generic.Subheading E E assert not 1.9 < 2.9 This is accomplished by storing the current minimum contrasts in ./tests/contrast/min_contrasts.json. When you improve a minimum contrast the test fails with: E AssertionError: congrats, you improved a contrast! please run ./scripts/update_contrasts.py E assert not 1.9 > 0.9 Running the script as instructed updates the JSON file, making the test pass. New styles are required to meet the WCAG AA contrast minimum of 4.5. First commit to address #1718. --- AUTHORS | 1 + 1 file changed, 1 insertion(+) (limited to 'AUTHORS') diff --git a/AUTHORS b/AUTHORS index 9fc03933..849c7245 100644 --- a/AUTHORS +++ b/AUTHORS @@ -246,5 +246,6 @@ Other contributors, listed alphabetically, are: * Fabian Neumann -- CDDL lexer * Thomas Duboucher -- CDDL lexer * Philipp Imhof -- Pango Markup formatter +* Martin Fischer -- WCAG contrast testing Many thanks for all contributions! -- cgit v1.2.1