Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update color scheme to meet WCAG #25

Open
hidde opened this issue Mar 16, 2022 · 6 comments
Open

Update color scheme to meet WCAG #25

hidde opened this issue Mar 16, 2022 · 6 comments

Comments

@hidde
Copy link

hidde commented Mar 16, 2022

It appears the current color scheme in the highlighter doesn't meet WCAG color contrast requirements. I'd like to contribute updates to the colors.

In whatwg/whatwg.org#392, I worked on color contrast issues in WHATWG, and syntax highlights are one of the issues we haven't yet tackled there.

I don't have strong preferences around color schemes, my suggestion would be to use a11y-syntax-highlighting as that meets WCAG.

@tabatkins
Copy link
Owner

Oh yeah, those colors look good to me.

@hidde
Copy link
Author

hidde commented Mar 17, 2022

Cool! Have done a first stab in #26, but getting some unexpected results when testing it out.

What would a better way (than manually) to convert Prism-compatible syntax styles to Pygments?

@tabatkins
Copy link
Owner

Ah, I've got a code snippet squirreled away in Bikeshed for that:

    # To regen the styles, edit and run the below
    # from pygments import token
    # from pygments import style
    # class PrismStyle(style.Style):
    #    default_style = "#000000"
    #    styles = {
    #        token.Name: "#0077aa",
    #        token.Name.Tag: "#669900",
    #        token.Name.Builtin: "noinherit",
    #        token.Name.Variable: "#222222",
    #        token.Name.Other: "noinherit",
    #        token.Operator: "#999999",
    #        token.Punctuation: "#999999",
    #        token.Keyword: "#990055",
    #        token.Literal: "#000000",
    #        token.Literal.Number: "#000000",
    #        token.Literal.String: "#a67f59",
    #        token.Comment: "#708090"
    #    }
    # print formatters.HtmlFormatter(style=PrismStyle).get_style_defs('.highlight')

@hidde
Copy link
Author

hidde commented Mar 18, 2022

I saw this, but I wasn't sure where/how to run it? (I am not super familiar with Python)

How do I prepare this file to run it (eg where do I put the Prism styles and how can I map from Prism token names to Pygments token names) and where do I run it?

Thanks!

@tabatkins
Copy link
Owner

Ah, so if you have pygments installed you can just run this from an independent script. But I already know how to do that, so if you could swap in the colors I'll do the rest.

@hidde
Copy link
Author

hidde commented Mar 18, 2022

Ok this is ready to go in #26 !

I have updated the colors that are inside the comments, and the ones outside of it, but if you're generating them we can throw my changes outside of the comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants