mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -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
|
# not cached yet
|
||||||
self.updateCard(index)
|
self.updateCard(index)
|
||||||
s = self.columns[index.column()][1](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("<br />", u" ")
|
s = s.replace("<br />", u" ")
|
||||||
s = s.replace("\n", u" ")
|
s = s.replace("\n", u" ")
|
||||||
s = stripHTML(s)
|
|
||||||
s = re.sub("\[sound:[^]]+\]", "", s)
|
s = re.sub("\[sound:[^]]+\]", "", s)
|
||||||
s = s.replace("&", "&")
|
s = stripHTML(s)
|
||||||
s = s.strip()
|
s = s.strip()
|
||||||
return QVariant(s)
|
return QVariant(s)
|
||||||
else:
|
else:
|
||||||
return QVariant()
|
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):
|
def headerData(self, section, orientation, role):
|
||||||
if orientation == Qt.Vertical:
|
if orientation == Qt.Vertical:
|
||||||
return QVariant()
|
return QVariant()
|
||||||
|
|
Loading…
Reference in a new issue