gregorrr / anki-auto-markdown

37 stars 9 forks source link

Code block on dark mode is weird (macOS and iOS) #14

Open hologerry opened 5 years ago

hologerry commented 5 years ago
Screen Shot 2019-09-23 at 19 50 54
suvernev-d commented 4 years ago

Have the same issue.

Problem seems to be that pygments inserts color codes directly in <span> tags, so there's no easy way to apply different CSS on them. It differs from how (now defunct) Power Format Pack used to work: by wrapping code elements in divs with classes.

So for now I just added alpha to background color of codehilite class directly in pygments style:

# Anki2/addons21/1030875226/pygments/styles/<name of your style from addon config, I use Monokai>

class MonokaiStyle(Style):
    """
    This style mimics the Monokai color scheme.
    """

    background_color = "#ffffff00" # <-- Zeroes for alpha in background
    highlight_color = "#49483e"

Though other colors still look not so good in dark mode

josh-works commented 4 years ago

It took me a bit of digging to figure out how to implement @suvernev-d's suggestion.

Here's how to implement his suggestion:

  1. In Anki, go to Tools > Addons

  2. Select the Auto Markdown package and click the Config button

  3. In the following object, make sure that colorScheme is set to monokai. (I also turned off lineNums. 2020-04-14 at 8 51 AM

  4. Click OK.

  5. The modal window will go away, you should be back on the Tools > Addons window. Click the View Files button.

  6. Open up the pygments/styles directory, and open monokai.py in your text editor: 2020-04-14 at 8 44 AM

  7. On line 23, change the value for background_color from #272822 to #ffffff00, per @suvernev-d's comment.

Restart Anki, and try using Markdown!

2020-04-14 at 8 52 AM

hologerry commented 4 years ago

@josh-works Thanks a lot!