make sure we load css on model init

This commit is contained in:
Damien Elmes 2011-03-22 14:54:59 +09:00
parent 9d52196949
commit 4477e21369
3 changed files with 6 additions and 4 deletions

View file

@ -466,7 +466,8 @@ select id from cards where fid in (select id from facts where mid = ?)""",
format = format.replace("cloze:", "ca:") format = format.replace("cloze:", "ca:")
fields = runFilter("mungeFields", fields, model, gname, data, self) fields = runFilter("mungeFields", fields, model, gname, data, self)
html = anki.template.render(format, fields) html = anki.template.render(format, fields)
d[type] = runFilter("mungeQA", html, fields, model, gname, data, self) d[type] = runFilter(
"mungeQA", html, type, fields, model, gname, data, self)
return d return d
def _qaData(self, where=""): def _qaData(self, where=""):

View file

@ -32,7 +32,7 @@ def stripLatex(text):
text = text.replace(match.group(), "") text = text.replace(match.group(), "")
return text return text
def mungeQA(html, fields, model, gname, data, deck): def mungeQA(html, type, fields, model, gname, data, deck):
"Convert TEXT with embedded latex tags to image links." "Convert TEXT with embedded latex tags to image links."
for match in regexps['standard'].finditer(html): for match in regexps['standard'].finditer(html):
html = html.replace(match.group(), _imgLink(deck, match.group(1))) html = html.replace(match.group(), _imgLink(deck, match.group(1)))

View file

@ -61,8 +61,9 @@ class Model(object):
self.name, self.name,
self.fields, self.fields,
self.templates, self.templates,
self.conf) = self.deck.db.first(""" self.conf,
select mod, name, flds, tmpls, conf from models where id = ?""", self.id) self.css) = self.deck.db.first("""
select mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
self.fields = simplejson.loads(self.fields) self.fields = simplejson.loads(self.fields)
self.templates = simplejson.loads(self.templates) self.templates = simplejson.loads(self.templates)
self.conf = simplejson.loads(self.conf) self.conf = simplejson.loads(self.conf)