Anki - What should I hook to add my own field descriptors?

无人久伴 提交于 2019-12-12 19:18:14

问题


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.



来源:https://stackoverflow.com/questions/45660347/anki-what-should-i-hook-to-add-my-own-field-descriptors

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!