mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
ignore parse errors due to invalid html on export
This commit is contained in:
parent
f03000d27b
commit
b8401eff22
1 changed files with 9 additions and 6 deletions
|
@ -8,7 +8,7 @@ Exporting support
|
||||||
"""
|
"""
|
||||||
__docformat__ = 'restructuredtext'
|
__docformat__ = 'restructuredtext'
|
||||||
|
|
||||||
import itertools, time, re, os
|
import itertools, time, re, os, HTMLParser
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from anki import DeckStorage
|
from anki import DeckStorage
|
||||||
from anki.cards import Card
|
from anki.cards import Card
|
||||||
|
@ -40,11 +40,14 @@ class Exporter(object):
|
||||||
self._escapeCount += 1
|
self._escapeCount += 1
|
||||||
if self._escapeCount % 100 == 0:
|
if self._escapeCount % 100 == 0:
|
||||||
self.deck.updateProgress()
|
self.deck.updateProgress()
|
||||||
s = BS(text)
|
try:
|
||||||
all = s('span', {'class': re.compile("fm.*")})
|
s = BS(text)
|
||||||
for e in all:
|
all = s('span', {'class': re.compile("fm.*")})
|
||||||
e.replaceWith("".join([unicode(x) for x in e.contents]))
|
for e in all:
|
||||||
text = unicode(s)
|
e.replaceWith("".join([unicode(x) for x in e.contents]))
|
||||||
|
text = unicode(s)
|
||||||
|
except HTMLParser.HTMLParseError:
|
||||||
|
pass
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def cardIds(self):
|
def cardIds(self):
|
||||||
|
|
Loading…
Reference in a new issue