mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
fix a bug with html edit, fix loading remote images
This commit is contained in:
parent
6e885557f5
commit
e617fe7df7
2 changed files with 12 additions and 9 deletions
|
@ -508,9 +508,9 @@ class FactEditor(object):
|
|||
form.textEdit.setPlainText(self.widgets[w].value)
|
||||
form.textEdit.moveCursor(QTextCursor.End)
|
||||
d.exec_()
|
||||
self.widgets[w].value = (
|
||||
unicode(form.textEdit.toPlainText()).replace("\n", ""))
|
||||
self.loadFields()
|
||||
w.setText(unicode(form.textEdit.toPlainText()).\
|
||||
replace("\n", ""))
|
||||
self.saveFields()
|
||||
|
||||
def fieldsAreBlank(self):
|
||||
for (field, widget) in self.fields.values():
|
||||
|
|
|
@ -153,12 +153,15 @@ def mungeQA(deck, txt):
|
|||
txt = renderLatex(deck, txt)
|
||||
txt = stripSounds(txt)
|
||||
def quote(match):
|
||||
if sys.platform.startswith("win32"):
|
||||
prefix = "file:///"
|
||||
match = unicode(match.group(1))
|
||||
if match.lower().startswith("http"):
|
||||
src = match
|
||||
else:
|
||||
prefix = "file://"
|
||||
return 'img src="%s%s"' % (
|
||||
prefix, os.path.join(deck.mediaDir(),
|
||||
unicode(match.group(1))))
|
||||
if sys.platform.startswith("win32"):
|
||||
prefix = u"file:///"
|
||||
else:
|
||||
prefix = u"file://"
|
||||
src = prefix + os.path.join(deck.mediaDir(), match)
|
||||
return 'img src="%s"' % src
|
||||
txt = re.sub('img src="(.*?)"', quote, txt)
|
||||
return txt
|
||||
|
|
Loading…
Reference in a new issue