accessible-pygments0.0.5
Published
A collection of accessible pygments styles
pip install accessible-pygments
Package Downloads
Project URLs
Requires Python
>=3.9
Accessible pygments themes
Table of contents
This package includes a collection of accessible themes for pygments based on multiple open-source syntax highlighting themes. The images below show all the themes side by side.
:sparkles: To see examples of the themes in action visit our online demo :sparkles:
Accessibility details ♿️
[!Note] What do we mean by accessible? In this context we are specifically referring to themes which meet the WCAG 2.1 criteria for color contrast. Some themes included are also color-blind friendly.
WCAG 2.1 - AAA compliant
The following themes are AAA compliant with WCAG 2.1 criteria for color contrast.
a11y-dark
a11y-high-contrast-dark
pitaya-smoothie
- Color-blind friendly.github-light
- Color-blind friendly.github-dark
- Color-blind friendly.github-light-colorblind
- Color-blind friendly.github-dark-colorblind
- Color-blind friendly.github-light-high-contrast
- Color-blind friendly.github-dark-high-contrast
- Color-blind friendly.gotthard-dark
- Color-blind friendly.
WCAG 2.1 - AA compliant
The following themes are AA compliant with WCAG 2.1 criteria for color contrast.
a11y-light
a11y-high-contrast-light
gotthard-light
- Color-blind friendly.blinds-light
- Color-blind friendly.blinds-dark
- Color-blind friendly.greative
- Accessible to most forms of colorblindness and low light settings.
Documentation 📖
Installation 💻
accessible-pygments
is available through pip and conda.
You can install it through the following commands:
conda install -c conda-forge accessible-pygments
# if you prefer using mamba
mamba install -c conda-forge accessible-pygments
pip install accessible-pygments
If you prefer to install the themes directly from the source:
# clone the repository
git clone [email protected]:Quansight-Labs/accessible-pygments.git
cd accessible-pygments
pip install .
Using the themes directly in your code or app
If you want to directly use the themes in your code, you can do so by importing the theme and passing it to the style
argument of the HtmlFormatter
class.
from pygments.formatters import HtmlFormatter
HtmlFormatter(style='a11y-light').style
<class 'accessible-pygments.A11yLight'>
Using the themes in your Sphinx documentation
-
You will need to add
accessible-pygments
as a dependency to your documentation:# for example if using a pyproject.toml file dependencies=["accessible-pygments"]
-
Modify your
conf.py
file to specify theaccessible-pygments
style:"pygments_style": "a11y-light"
-
Build your documentation as usual.
Development and contribution 🌱
You can find our contribution guides on CONTRIBUTING.md. We aim to build a safe and inclusive community, so we have a Code of Conduct that we ask everyone to follow.
Acknowledgments 🤝
We want to thank the following sources for being the source of inspiration for one or more themes that are available in this repository,
- a11y dark and light syntax highlighting.
- pitaya smoothie VSCode theme.
- github VSCode themes.
- gotthard VSCode themes.
- blinds VSCode themes.
- greative VSCode theme.
License 📑
accessible-pygments
is licensed under the OSI BSD-3 Clause license.