Closed vinoff closed 5 months ago
I am using Apy to create some anki cards that have code in them (python). The code shows with a white background. I would like it to have a dark background, according to some dark-mode color scheme, such as monokai or gruvbox or whatever. Anything dark, really..
This is supported, yes. I did not add support to change the theme, but it should already by Monokai, I think.
Is this something done on apy or anki itself? How?
It is done by apy while converting from Markdown to HTML, here: https://github.com/lervag/apy/blob/50ee12a09004c38bec7e895dd7e3fb7229a387e6/src/apyanki/fields.py#L238-L254
I'm not sure how much Python you know, so it's hard to know at which level of detail I should explain things.
It may be easier to answer your question if you are somewhat more specific. For instance, you could give some concrete example of the card content you want.
On input.md, I have the following:
Then I import using apy (apy add-from-file input.md) and I see the following on Anki desktop:
I am using Anki desktop:
Version 24.04 (429bc9e1)
Python 3.11.8 Qt 6.7.0 PyQt 6.7.0.dev2404081550
You see that white background in the code? I would like that to be using some dark color scheme, dark background. Does this not happen on your apy/anki? Any idea what I am doing wrong?
You see that white background in the code? I would like that to be using some dark color scheme, dark background. Does this not happen on your apy/anki? Any idea what I am doing wrong?
Good question. I believe it may be using a light colorscheme to contrast it from your already dark scheme of Anki. Can you check how it looks in Anki if you force light scheme in Anki desktop?
Ok, so: this is the part that specifies the colorscheme used for the highlighting:
Perhaps I should let this be configurable.
After you did apy add-from-file ...
, you can do apy review tag:tag1
. It will give you a note browser where you can edit and update change/update/delete your notes. The menu keys are listed at the top. Continue until you reach the note in your example. From there:
p
action)?You see that white background in the code? I would like that to be using some dark color scheme, dark background. Does this not happen on your apy/anki? Any idea what I am doing wrong?
Good question. I believe it may be using a light colorscheme to contrast it from your already dark scheme of Anki. Can you check how it looks in Anki if you force light scheme in Anki desktop?
This is with light mode:
apy review tag:tag1
Here is a screenshot:
And here is the html:
Thanks!
I think there are two important points here:
I believe your issue can be resolved if I added a new option to the config file.
Thanks!
I think there are two important points here:
* We can specify the colorscheme to use for the code blocks. * The colorscheme will not be dynamic, it will look the same in both light and dark mode.
I believe your issue can be resolved if I added a new option to the config file.
That would be great! And btw, thanks for Apy! Other than this hiccup, it really is everything I was looking for!
That would be great! And btw, thanks for Apy! Other than this hiccup, it really is everything I was looking for!
Thanks, I'm glad to hear that! It has been a huge improvement to my own workflow for creating and managing my Anki notes, and I'm glad to hear it can be useful to others as well!
I believe my latest commit should provide the desired feature. Please test it. Let me know if you need guidance.
I was just testing but no changes, though I just reinstalled using pip.. I suppose pip pulls from the releases though, right?
Ah, yes, sorry; I only pushed to the repo - I didn't make a new release. I'll push to pypi tomorrow or Sunday. If you want to test from the repo, you can do:
git clone https://github.com/lervag/apy
cd apy
pipx install -f .
Hey @lervag.
I tested it and it seems to be working correctly.
There was just one issue that may or may not have something to do with apy: https://github.com/ankidroid/Anki-Android/issues/16227, but it seems to have been fixed by Anki-Droid and also is fixable with css as I commented in that issue.
Would it be possible for you to do a release of apy, so I can properly install this?
Would it be possible for you to do a release of apy, so I can properly install this?
Yes, sorry - I've bumped to v0.15.3 and published. I'm new to the pypi thing; feel free to remind me again in the future if you should notice I forget it again!
I tested it and it seems to be working correctly.
Great, glad to hear it!
There was just one issue that may or may not have something to do with apy: ankidroid/Anki-Android#16227, but it seems to have been fixed by Anki-Droid and also is fixable with css as I commented in that issue.
Yes and no - this is not really due to apy, it's more about how the code blocks are converted from markdown to html. The markdown
library uses pygments
and will give a code block the .codehilite
class. My own settings for .codehilite
are as follows:
.codehilite, .codehilitetable {
margin: auto;
display: inline-block;
text-align: left;
}
.codehilite pre, .codehilitetable pre {
margin: 0;
font-size: 14px;
background-color: #eee;
}
.mobile .night_mode .codehilite pre {
background-color: #303030;
}
I am using Apy to create some anki cards that have code in them (python). The code shows with a white background. I would like it to have a dark background, according to some dark-mode color scheme, such as monokai or gruvbox or whatever. Anything dark, really..
Is this something done on apy or anki itself? How?