mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add {{hint:Field}}
This commit is contained in:
parent
738ab23bec
commit
6559020d1f
2 changed files with 21 additions and 0 deletions
20
anki/template/hint.py
Normal file
20
anki/template/hint.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
import re
|
||||||
|
from anki.hooks import addHook
|
||||||
|
|
||||||
|
def hint(txt, extra, context, tag, fullname):
|
||||||
|
if not txt.strip():
|
||||||
|
return ""
|
||||||
|
# random id
|
||||||
|
domid = "hint%d" % id(txt)
|
||||||
|
return """
|
||||||
|
<a href="#"
|
||||||
|
onclick="this.style.display='none';document.getElementById('%s').style.display='block';return false;">
|
||||||
|
%s</a><div id="%s" style="display: none">%s</div>
|
||||||
|
""" % (domid, _("Show %s") % tag, domid, txt)
|
||||||
|
|
||||||
|
def install():
|
||||||
|
addHook('fmod_hint', hint)
|
|
@ -4,6 +4,7 @@ import collections
|
||||||
from anki.utils import stripHTML
|
from anki.utils import stripHTML
|
||||||
from anki.hooks import runFilter
|
from anki.hooks import runFilter
|
||||||
from anki.template import furigana; furigana.install()
|
from anki.template import furigana; furigana.install()
|
||||||
|
from anki.template import hint; hint.install()
|
||||||
from anki.lang import _
|
from anki.lang import _
|
||||||
|
|
||||||
clozeReg = r"\{\{c%s::(.*?)(::(.*?))?\}\}"
|
clozeReg = r"\{\{c%s::(.*?)(::(.*?))?\}\}"
|
||||||
|
|
Loading…
Reference in a new issue