mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
use a clearer name for fmtQA()
This commit is contained in:
parent
ef0a28f294
commit
17d68cc957
3 changed files with 8 additions and 8 deletions
|
@ -153,7 +153,7 @@ def minimizeHTML(s):
|
|||
'<u>\\1</u>', s)
|
||||
return s
|
||||
|
||||
def fmtQA(s):
|
||||
def htmlToTextLine(s):
|
||||
s = s.replace("<br>", " ")
|
||||
s = s.replace("<br />", " ")
|
||||
s = s.replace("<div>", " ")
|
||||
|
|
|
@ -9,7 +9,7 @@ from aqt.utils import saveGeom, restoreGeom, showWarning, askUser, shortcut, \
|
|||
tooltip, openHelp, addCloseShortcut, downArrow
|
||||
from anki.sound import clearAudioQueue
|
||||
from anki.hooks import addHook, remHook, runHook
|
||||
from anki.utils import stripHTMLMedia, fmtQA, isMac
|
||||
from anki.utils import stripHTMLMedia, htmlToTextLine, isMac
|
||||
import aqt.editor, aqt.modelchooser, aqt.deckchooser
|
||||
|
||||
class AddCards(QDialog):
|
||||
|
@ -145,7 +145,7 @@ class AddCards(QDialog):
|
|||
for nid in self.history:
|
||||
if self.mw.col.findNotes("nid:%s" % nid):
|
||||
fields = self.mw.col.getNote(nid).fields
|
||||
txt = fmtQA(", ".join(fields))
|
||||
txt = htmlToTextLine(", ".join(fields))
|
||||
if len(txt) > 30:
|
||||
txt = txt[:30] + "..."
|
||||
a = m.addAction(_("Edit \"%s\"") % txt)
|
||||
|
|
|
@ -12,7 +12,7 @@ from anki.lang import ngettext
|
|||
from aqt.qt import *
|
||||
import anki
|
||||
import aqt.forms
|
||||
from anki.utils import fmtTimeSpan, ids2str, stripHTMLMedia, fmtQA, isWin, intTime, isMac
|
||||
from anki.utils import fmtTimeSpan, ids2str, stripHTMLMedia, htmlToTextLine, isWin, intTime, isMac
|
||||
from aqt.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter, \
|
||||
saveHeader, restoreHeader, saveState, restoreState, applyStyles, getTag, \
|
||||
showInfo, askUser, tooltip, openHelp, showWarning, shortcut, mungeQA
|
||||
|
@ -234,7 +234,7 @@ class DataModel(QAbstractTableModel):
|
|||
return self.answer(c)
|
||||
elif type == "noteFld":
|
||||
f = c.note()
|
||||
return fmtQA(f.fields[self.col.models.sortIdx(f.model())])
|
||||
return htmlToTextLine(f.fields[self.col.models.sortIdx(f.model())])
|
||||
elif type == "template":
|
||||
t = c.template()['name']
|
||||
if c.model()['type'] == MODEL_CLOZE:
|
||||
|
@ -283,16 +283,16 @@ class DataModel(QAbstractTableModel):
|
|||
return self.browser.mw.col.decks.name(c.did)
|
||||
|
||||
def question(self, c):
|
||||
return fmtQA(c.q(browser=True))
|
||||
return htmlToTextLine(c.q(browser=True))
|
||||
|
||||
def answer(self, c):
|
||||
if c.template().get('bafmt'):
|
||||
# they have provided a template, use it verbatim
|
||||
c.q(browser=True)
|
||||
return fmtQA(c.a())
|
||||
return htmlToTextLine(c.a())
|
||||
# need to strip question from answer
|
||||
q = self.question(c)
|
||||
a = fmtQA(c.a())
|
||||
a = htmlToTextLine(c.a())
|
||||
if a.startswith(q):
|
||||
return a[len(q):].strip()
|
||||
return a
|
||||
|
|
Loading…
Reference in a new issue