{"id":1891,"library":"accessible-pygments","title":"Accessible Pygments Styles","description":"A collection of accessible Pygments styles, currently at version 0.0.5. It provides themes that meet WCAG 2.1 color contrast requirements, aiming to make syntax highlighting more inclusive for users with low vision or color blindness. The library is actively maintained with regular minor releases adding new themes and improvements.","status":"active","version":"0.0.5","language":"python","source_language":"en","source_url":"https://github.com/Quansight-Labs/accessible-pygments","tags":["accessibility","pygments","syntax highlighting","themes","WCAG"],"install":[{"cmd":"pip install accessible-pygments","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Provides the core syntax highlighting engine that accessible-pygments extends with new styles.","package":"Pygments"}],"imports":[{"note":"Importing the package registers its styles with Pygments, making them available by name. You do not typically import specific style classes directly for usage.","symbol":"accessible_pygments","correct":"import accessible_pygments"}],"quickstart":{"code":"from pygments import highlight\nfrom pygments.lexers import PythonLexer\nfrom pygments.formatters import HtmlFormatter\nimport accessible_pygments # This registers the styles\n\ncode_to_highlight = \"\"\"\ndef greet(name):\n    print(f\"Hello, {name}!\")\n\ngreet(\"World\")\n\"\"\"\n\n# Choose an accessible style, e.g., 'a11y-light', 'github-dark-colorblind'\nstyle_name = 'a11y-light'\n\n# Create an HTML formatter with the chosen accessible style\nformatter = HtmlFormatter(style=style_name, full=True, encoding='utf-8')\n\n# Highlight the code\nhighlighted_code = highlight(\n    code_to_highlight,\n    PythonLexer(),\n    formatter\n)\n\n# The highlighted_code is now a bytes object (due to encoding='utf-8' in full=True mode)\n# Decode to string if you want to print or save to a text file\nprint(highlighted_code.decode('utf-8'))\n\n# To save to an HTML file (example)\n# with open(\"highlighted_code.html\", \"wb\") as f:\n#     f.write(highlighted_code)","lang":"python","description":"This example demonstrates how to highlight Python code using the `a11y-light` style from `accessible-pygments`. The key is to import `accessible_pygments` to register its styles, then refer to the style by its string name when creating a Pygments formatter. The `full=True` option generates a complete HTML document including the stylesheet."},"warnings":[{"fix":"Upgrade to version 0.0.3 or newer to benefit from WCAG 2.1 compliant color contrast. Review your applications to ensure the new color schemes meet your visual and accessibility requirements.","message":"Version 0.0.3 included critical fixes to the highlighting colors across all themes. Users upgrading from versions prior to 0.0.3 should expect visual changes in their highlighted code, as older versions may have had incorrect or less accessible color contrasts.","severity":"breaking","affected_versions":"<0.0.3"},{"fix":"Ensure `accessible-pygments` is in your documentation's dependencies. In your `conf.py`, set `pygments_style = \"your-accessible-style-name\"`.","message":"When using `accessible-pygments` styles in Sphinx documentation, the style is specified as a string in `conf.py` (e.g., `pygments_style = \"a11y-light\"`). Do not attempt to import a Python class for the style directly into `conf.py`. The `accessible-pygments` package must be installed in the Sphinx environment.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use the string name of the desired accessible style when initializing Pygments formatters.","message":"Pygments styles are referenced by their string names (e.g., `'a11y-light'`) in `HtmlFormatter(style='...')`. Do not attempt to directly import and pass a style class from `accessible_pygments` to the formatter (e.g., `HtmlFormatter(style=A11yLight)`). The package automatically registers these names upon import.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-30T22:33:51.281Z","next_check":"2026-07-08T00:00:00.000Z","problems":[{"fix":"Ensure the package is installed by running 'pip install accessible-pygments'.","cause":"The 'accessible-pygments' package is not installed or is installed incorrectly.","error":"ModuleNotFoundError: No module named 'accessible_pygments'"},{"fix":"Verify the correct theme name and import it accordingly, e.g., 'from accessible_pygments.styles import a11y_dark'.","cause":"The theme 'a11y_dark' is not available in the 'accessible_pygments' package.","error":"ImportError: cannot import name 'a11y_dark' from 'accessible_pygments'"},{"fix":"Ensure the theme is correctly installed and registered in Pygments by checking the 'accessible_pygments' documentation.","cause":"Attempting to use a theme that is not properly registered or is missing.","error":"TypeError: 'NoneType' object is not callable"},{"fix":"Ensure you are using a correct style name provided by `accessible-pygments`, such as 'a11y-light' or 'github-dark', in your Pygments `HtmlFormatter` instantiation or Sphinx `conf.py` setting. Refer to the `accessible-pygments` documentation for a list of available themes.","cause":"You have specified a Pygments style name (e.g., 'non_existent_style') that does not exist or is not correctly registered within Pygments, or you have misspelled a valid `accessible-pygments` theme name.","error":"pygments.util.ClassNotFound: No style found for name 'non_existent_style'"},{"fix":"On Debian/Ubuntu, install `python3-dev` (or `python-dev` for Python 2). On RedHat/CentOS, install `python3-devel` (or `python-devel`). On macOS, ensure Xcode command line tools are installed (`xcode-select --install`).","cause":"This compilation error occurs during installation (often when installing a dependency with C extensions) because the Python development headers are missing on your system.","error":"error: 'Python.h' file not found"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.0.5","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Quansight-Labs/accessible-pygments","docs":null,"changelog":null,"pypi":"https://pypi.org/project/accessible-pygments/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","serialization"],"base_url":null,"auth_type":null,"install_checks":{"last_tested":"2026-05-30","tag":null,"tag_description":null,"installed_version":"0.0.5","pypi_latest":"0.0.5","is_stale":false,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"28.6M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2,"import_time_s":null,"mem_mb":null,"disk_size":"29M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"31.3M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.2,"import_time_s":null,"mem_mb":null,"disk_size":"32M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"23.1M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.1,"import_time_s":null,"mem_mb":null,"disk_size":"24M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"22.9M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.1,"import_time_s":null,"mem_mb":null,"disk_size":"23M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"28.1M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":2.5,"import_time_s":null,"mem_mb":null,"disk_size":"29M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"accessible-pygments","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-25","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]},"_links":{"self":"https://checklist.day/api/registry/accessible-pygments","v1":"https://checklist.day/v1/registry/accessible-pygments","v1_install":"https://checklist.day/v1/registry/accessible-pygments/install","v1_imports":"https://checklist.day/v1/registry/accessible-pygments/imports","v1_compatibility":"https://checklist.day/v1/registry/accessible-pygments/compatibility","v1_quickstart":"https://checklist.day/v1/registry/accessible-pygments/quickstart","docs":"https://checklist.day/docs"}}