3

Similarly to {{field}} and {{text:field}}, I am trying to create my own field descriptor. In order to do this, I need to know what function to hook. I do not know whether Anki pre-compiles cards into HTML or produces them on-the-fly during study, so I don't know where to begin to look for this function - I haven't found any existing add-ons that do this so I can't look at how they implemented it.

What function should I hook to implement special field descriptors in cards?

wizzwizz4
  • 6,140
  • 2
  • 26
  • 62

1 Answers1

3

Anki pre-compiles to HTML, and I have found the function that deals with "Moustache tags" in template.py.

By registering the hook fmod_<modifier> with a function taking a filter parameter txt and (fixed) parameters extra, content, tag and tag_name one can register a modifier for that name.

That last parameter, tag_name, is probably the one you want, as it is a string that contains everything between the {{ and }} marks.

wizzwizz4
  • 6,140
  • 2
  • 26
  • 62