Anki/anki/stdmodels.py
Damien Elmes 9e35e4acf2 template and cloze changes
While writing the documentation I realized that the default templates were
somewhat overwhelming. So I've moved the default settings into the card css,
and moved the css into a separate attribute which gets combined with the
question and answer templates.

Also:
- Detect cloze references directly rather than the conditional wrapper
- Add the cloze css to the template
2011-12-17 19:42:30 +09:00

53 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
# Copyright: Damien Elmes <anki@ichi2.net>
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from anki.lang import _
models = []
# Basic
##########################################################################
def addBasicModel(col):
mm = col.models
m = mm.new(_("Basic"))
fm = mm.newField(_("Front"))
mm.addField(m, fm)
fm = mm.newField(_("Back"))
mm.addField(m, fm)
t = mm.newTemplate(_("Forward"))
t['qfmt'] = "{{Front}}"
t['afmt'] = t['qfmt'] + "\n\n<hr id=answer>\n\n{{Back}}"
mm.addTemplate(m, t)
mm.add(m)
return m
models.append((_("Basic"), addBasicModel))
# Cloze
##########################################################################
def addClozeModel(col):
mm = col.models
m = mm.new(_("Cloze"))
fm = mm.newField(("Text"))
mm.addField(m, fm)
fm = mm.newField(_("Notes"))
mm.addField(m, fm)
for i in range(8):
n = i+1
t = mm.newTemplate(_("Cloze") + " %d" % n)
fmt = "{{cloze:%d:Text}}%%s" % n
t['css'] += """
.cloze {
font-weight: bold;
color: blue;
}"""
t['qfmt'] = fmt % ""
t['afmt'] = fmt % "\n{{Notes}}"
mm.addTemplate(m, t)
mm.add(m)
return m
models.append((_("Cloze"), addClozeModel))