mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
preserve more of the old formatting on upgrade
because field formatting is always on now, users with custom font sizes/families set only on the card will still have to alter their templates and either configure the fields or replace the references with triple curly braces
This commit is contained in:
parent
09b017bb24
commit
0363cc70f4
1 changed files with 26 additions and 2 deletions
28
anki/deck.py
28
anki/deck.py
|
@ -4366,8 +4366,32 @@ or quizFontFamily is null""")
|
||||||
deck.version = 57
|
deck.version = 57
|
||||||
deck.s.commit()
|
deck.s.commit()
|
||||||
if deck.version < 61:
|
if deck.version < 61:
|
||||||
# because we've changed the way latex is handled, we're going to
|
txt = '''\
|
||||||
# need to rebuild the q/a
|
<span style="font-family: %s; font-size: %spx; color: %s;">%s</span>'''
|
||||||
|
for m in deck.models:
|
||||||
|
for cm in m.cardModels:
|
||||||
|
# embed the old font information into card templates if
|
||||||
|
# it's been customized
|
||||||
|
if (cm.questionFontFamily != "Arial" or
|
||||||
|
cm.questionFontSize != 20 or
|
||||||
|
cm.questionFontColour != "#000000"):
|
||||||
|
cm.qformat = txt % (
|
||||||
|
cm.questionFontFamily,
|
||||||
|
cm.questionFontSize,
|
||||||
|
cm.questionFontColour,
|
||||||
|
cm.qformat)
|
||||||
|
if (cm.answerFontFamily != "Arial" or
|
||||||
|
cm.answerFontSize != 20 or
|
||||||
|
cm.answerFontColour != "#000000"):
|
||||||
|
cm.aformat = txt % (
|
||||||
|
cm.answerFontFamily,
|
||||||
|
cm.answerFontSize,
|
||||||
|
cm.answerFontColour,
|
||||||
|
cm.aformat)
|
||||||
|
# fix newlines
|
||||||
|
cm.qformat = cm.qformat.replace("\n", "<br>\n")
|
||||||
|
cm.aformat = cm.aformat.replace("\n", "<br>\n")
|
||||||
|
# rebuild q/a for the above & because latex has changed
|
||||||
for m in deck.models:
|
for m in deck.models:
|
||||||
deck.updateCardsFromModel(m, dirty=False)
|
deck.updateCardsFromModel(m, dirty=False)
|
||||||
# rebuild the media db based on new format
|
# rebuild the media db based on new format
|
||||||
|
|
Loading…
Reference in a new issue