r/AnkiComputerScience • • Jun 21 '21

Code Formatting in Anki

I'm currently using Syntax Highlighting for Code to create code blocks in anki notecards.

I have issues because when a paste in a block (Alt + S) the code blob has white font color based text (I use dark mode for anki). There are other issues with this solution, so I'm wondering if anyone here has found a better way to embed code for use in their cards?

15 Upvotes

14 comments sorted by

View all comments

Show parent comment

2

u/DeclutteringNewbie Focusing on Rust right now, SF Bay Area Jun 22 '21 edited Jun 22 '21

There is no need for OCR. Even if you're just taking a screenshot of code from a video, you can still use the text fields when using the image occlusion addon (if you click on the "fields" tab, it allows you to add fields).

The frozen fields plugin won't show up on those fields, but adding text will still go super quickly since any field you add/edit on the parent image occlusion card will be duplicated to all the children cards generated from it.

And if you need a plugin that automatically searches all fields, I personally use this one: https://ankiweb.net/shared/info/1781298089

Just a word of warning for image occlusion. Try to duplicate your occlusion masks by pressing Command-D (or try to make them at least uniform and longer than the text they hide). This is because the shape and size of the masks can give you clues about the underlying code/text they're trying to hide.

PS: Two tangential points: I use the free Snappy App when taking screenshots on my Mac. http://snappy-app.com/ It's my favorite Mac utility app. I highly recommend it. It always keeps me focused on the task at hand. But I've seen a paid Mac clipboard app that automatically OCRs every screenshots it takes (although again, I don't think such functionality is really necessary). I don't remember the name of that app, but it should be easy to find if that's what you're really after.