mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
preserve image filenames when stripping html
- also do this for the sort field
This commit is contained in:
parent
1af487a1d4
commit
8cf072c735
2 changed files with 5 additions and 4 deletions
|
@ -3,7 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from anki.utils import fieldChecksum, intTime, \
|
from anki.utils import fieldChecksum, intTime, \
|
||||||
joinFields, splitFields, stripHTML, timestampID, guid64
|
joinFields, splitFields, stripHTMLMedia, timestampID, guid64
|
||||||
|
|
||||||
class Note(object):
|
class Note(object):
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ from notes where id = ?""", self.id)
|
||||||
self._preFlush()
|
self._preFlush()
|
||||||
self.mod = mod if mod else intTime()
|
self.mod = mod if mod else intTime()
|
||||||
self.usn = self.col.usn()
|
self.usn = self.col.usn()
|
||||||
sfld = stripHTML(self.fields[self.col.models.sortIdx(self._model)])
|
sfld = stripHTMLMedia(self.fields[self.col.models.sortIdx(self._model)])
|
||||||
tags = self.stringTags()
|
tags = self.stringTags()
|
||||||
csum = fieldChecksum(self.fields[0])
|
csum = fieldChecksum(self.fields[0])
|
||||||
res = self.col.db.execute("""
|
res = self.col.db.execute("""
|
||||||
|
@ -134,7 +134,8 @@ insert or replace into notes values (?,?,?,?,?,?,?,?,?,?,?)""",
|
||||||
for flds in self.col.db.list(
|
for flds in self.col.db.list(
|
||||||
"select flds from notes where csum = ? and id != ? and mid = ?",
|
"select flds from notes where csum = ? and id != ? and mid = ?",
|
||||||
csum, self.id or 0, self.mid):
|
csum, self.id or 0, self.mid):
|
||||||
if stripHTML(splitFields(flds)[0]) == stripHTML(self.fields[0]):
|
if stripHTMLMedia(
|
||||||
|
splitFields(flds)[0]) == stripHTMLMedia(self.fields[0]):
|
||||||
return 2
|
return 2
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ def checksum(data):
|
||||||
|
|
||||||
def fieldChecksum(data):
|
def fieldChecksum(data):
|
||||||
# 32 bit unsigned number from first 8 digits of sha1 hash
|
# 32 bit unsigned number from first 8 digits of sha1 hash
|
||||||
return int(checksum(stripHTML(data).encode("utf-8"))[:8], 16)
|
return int(checksum(stripHTMLMedia(data).encode("utf-8"))[:8], 16)
|
||||||
|
|
||||||
# Temp files
|
# Temp files
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
Loading…
Reference in a new issue