Quansight-Labs / accessible-pygments

♿ Accessible pygments themes
https://quansight-labs.github.io/accessible-pygments/
BSD 3-Clause "New" or "Revised" License
12 stars 5 forks source link

Update code to not get images from placeholder.com #51

Closed Carreau closed 7 months ago

Carreau commented 7 months ago

It has been bought by a new company and images might not hold forever. Use local pngs to do that.

Fixes #44

Carreau commented 7 months ago

I'm tempted to immediately update this script to create local 20x20 images and not rely on external providers.

Carreau commented 7 months ago

The script to create those images is trivial:

from PIL import Image

width, height = 20, 20

def hex_to_rgb(hex_string):
    hex_string = hex_string.lstrip("#")
    r = int(hex_string[0:2], 16)
    g = int(hex_string[2:4], 16)
    b = int(hex_string[4:6], 16)
    return (r, g, b)

hex_color = "#ccff44"
rgb_color = hex_to_rgb(hex_color)

image = Image.new("RGB", (width, height), rgb_color)

image.save("colored_image.png")
Carreau commented 7 months ago

Ok, let's try with local png, it seem to work. I also thought of using just a <div style="width: 20px; height: 20px; background-color: red;"></div>, like This ->

<-, but it is sanitized by github.

Carreau commented 7 months ago

Rendering won't work in the PR, you have to look at the fork:

https://github.com/Carreau/accessible-pygments/tree/rr/a11y_pygments/a11y_high_contrast_dark

Also strangely the contrast is not the same, but the colors have not changes. ~~@gabalafou any idea why ? ~~ (never mind)

Carreau commented 7 months ago

Should have addressed the comments and rebase/squashed to avoid having large intermediate commits.