mirror of
https://github.com/ankitects/anki.git
synced 2025-12-16 00:00:59 -05: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.setPlainText(self.widgets[w].value)
|
||||||
form.textEdit.moveCursor(QTextCursor.End)
|
form.textEdit.moveCursor(QTextCursor.End)
|
||||||
d.exec_()
|
d.exec_()
|
||||||
self.widgets[w].value = (
|
w.setText(unicode(form.textEdit.toPlainText()).\
|
||||||
unicode(form.textEdit.toPlainText()).replace("\n", ""))
|
replace("\n", ""))
|
||||||
self.loadFields()
|
self.saveFields()
|
||||||
|
|
||||||
def fieldsAreBlank(self):
|
def fieldsAreBlank(self):
|
||||||
for (field, widget) in self.fields.values():
|
for (field, widget) in self.fields.values():
|
||||||
|
|
|
||||||
|
|
@ -153,12 +153,15 @@ def mungeQA(deck, txt):
|
||||||
txt = renderLatex(deck, txt)
|
txt = renderLatex(deck, txt)
|
||||||
txt = stripSounds(txt)
|
txt = stripSounds(txt)
|
||||||
def quote(match):
|
def quote(match):
|
||||||
if sys.platform.startswith("win32"):
|
match = unicode(match.group(1))
|
||||||
prefix = "file:///"
|
if match.lower().startswith("http"):
|
||||||
|
src = match
|
||||||
else:
|
else:
|
||||||
prefix = "file://"
|
if sys.platform.startswith("win32"):
|
||||||
return 'img src="%s%s"' % (
|
prefix = u"file:///"
|
||||||
prefix, os.path.join(deck.mediaDir(),
|
else:
|
||||||
unicode(match.group(1))))
|
prefix = u"file://"
|
||||||
|
src = prefix + os.path.join(deck.mediaDir(), match)
|
||||||
|
return 'img src="%s"' % src
|
||||||
txt = re.sub('img src="(.*?)"', quote, txt)
|
txt = re.sub('img src="(.*?)"', quote, txt)
|
||||||
return txt
|
return txt
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue