mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
if <c>...</c> in q/a format, limit display in card list to that
This commit is contained in:
parent
f5a931bb07
commit
2329baa789
1 changed files with 10 additions and 3 deletions
|
@ -88,17 +88,24 @@ class DeckModel(QAbstractTableModel):
|
|||
# not cached yet
|
||||
self.updateCard(index)
|
||||
s = self.columns[index.column()][1](index)
|
||||
s = self.limitContent(s)
|
||||
s = s.replace("<br>", u" ")
|
||||
s = s.replace("<br />", u" ")
|
||||
s = s.replace("\n", u" ")
|
||||
s = stripHTML(s)
|
||||
s = s.replace("\n", u" ")
|
||||
s = re.sub("\[sound:[^]]+\]", "", s)
|
||||
s = s.replace("&", "&")
|
||||
s = stripHTML(s)
|
||||
s = s.strip()
|
||||
return QVariant(s)
|
||||
else:
|
||||
return QVariant()
|
||||
|
||||
def limitContent(self, txt):
|
||||
if "<c>" in txt:
|
||||
matches = re.findall("(?s)<c>(.*?)</c>", txt)
|
||||
return " ".join(matches)
|
||||
else:
|
||||
return txt
|
||||
|
||||
def headerData(self, section, orientation, role):
|
||||
if orientation == Qt.Vertical:
|
||||
return QVariant()
|
||||
|
|
Loading…
Reference in a new issue