How does Card Formatting Work? Are there any tools to do global operations on decks?

DinoNerd's Avatar


06 Oct, 2019 01:45 AM

I switched to Anki around a decade ago (maybe longer), after a similar product had a forced update which did not preserve my existing decks.

Over the years, the formatting used by Anki has got ever more powerful - and also completely opaque. New notess of pre-existing types produce cards that don't look the same as existing cards. Lots and lots of blank lines get inserted, but not consistently. Unless I can regain control of card formatting, I'm pretty much going to have to abandon the idea of adding to existing decks.

At the same time, various features I was using disappeared, and my existing notes and note types were automatically converted on upgrade. After multiple generations of this, I basically can't understand the results. (They work, or did till the latest upgrade where new notes started sprouting random blank lines which can't be deleted, but I don't understand them)

The biggest problem is that I used to have note types which generated certain cards iff and only iff certain optional fields had contents. Now each of those fields has a corresponding field, and to make a new note have to either put something in both of those fields, or neither.

After some digging in the user's manual, it seems that templates are in html - with all the power of that language. CSS for example. But with additions, like {{}} for substitute-something-from-the-specific-card.

But when I actually look at my existing templates, they seem to be in LaTeX. (For some freason, all I can see is "options" for a template.)

Obviously, I love the idea of learning two of the most complex markup language in the world in order to continue adding cards to Anki. (Not!) (I do read and write an early dialect of html fluently, but that's pre-CSS - basically, I know the subset that's generally supported by markdown.)

But that seems to be what I need to do simply in order to create new (and functional) versions of the card types I already have.

I'm looking for suggestions for getting out of this mess, including:
- an alternate spaced-repetition product that can import anki decks, but doesn't want to support audio, video, and other complexities, and so can keep its interface simple. Ideally it can import _with history_
- a way to export anki decks into a documented format I can then write a computer program to translate into something useful to me and/or modify. (Best if it can also reimport them after modify them.)
- a way to convert a legacy mess into something modern that preserves the history (How often have I got this card right/wrong etc.) and ideally is automated/automatable
- do you have a simple subset that can do the job, and automated tools to both convert my existing decks to it, and avoid accidentally straying outside it in future?
- have you got anything that can e.g. merge several templates into one, with all their cards? (It seems to be hard to even change the template associated with a note, once it's created.)

I'm going to start by downloading your source code, since the product is open sources, hoping I'll find some information there. (Or at least some classes etc. I can repurpose to writing a global deck editting and note type merging tool.)

  1. Support Staff 1 Posted by Damien Elmes on 06 Oct, 2019 10:04 PM

    Damien Elmes's Avatar

    Card templates do not require LaTeX. Please have a look at the 2nd and 3rd intro video:

    and the card templates section of the manual:

    You can change cards from one note type to another using the change note type option in the browse screen.

  2. 2 Posted by Arlie Stephens on 06 Oct, 2019 10:53 PM

    Arlie Stephens's Avatar

    I did find a link to the template section, and discovered that the template language isn't actually html - it's a markup language involving {{ and }}, which accepts (some?) html in most places where it would otherwise accept plain text. (E.g. a newline is expressed as <br>.) From looking at the source repo, it's apparently a variant on something called Pystache or Mustache, which is described as a "web template system".

    That's got me a lot farther on the task of figuring out the immediate problem, which is old note types producing cards that are unreadable due to unwanted extra newlines. The eventual work around is likely to be new card types for future cards.

    But I'd still like to have all my note types fit in one window, without either scrolling or enlarging that window. And that seems to require consolidating my existing mess - which gets me back to looking for tools to operate on groups of cards, and to look at multiple card types at the same time. (I'm currently resorting to screen shots, because Anki will only show me one at a time.)

    I don't really want to be reduced to writing my own code to copy and modify Anki's sqlite database, then check if the results are still intelligible to Anki :-( But with more than 13,000 cards - probably about 5000 notes - dealing with each one manually doesn't seem reasonable.

    OTOH, the obvious workaround is to rename all my existing note types such that they'll sort at the end of the list, and create new ones that sort ahead of them, to be used for all new cards. I lose the ability to find e.g. all german nouns easily - but it would save so much time that this is what I'll probably do.

Comments are closed, but you can start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac