-->

Anki - What should I hook to add my own field desc

2019-07-24 19:03发布

问题:

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?

回答1:

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.



标签: python hook Anki