diff --git a/anki/latex.py b/anki/latex.py index 9ee72ea1a..c82dbf1e5 100644 --- a/anki/latex.py +++ b/anki/latex.py @@ -120,10 +120,10 @@ def imageForLatex(deck, latex, build=True): def imgLink(deck, latex, build=True): "Parse LATEX and return a HTML image representing the output." - latex = mungeLatex(deck, latex) - (ok, img) = imageForLatex(deck, latex, build) + munged = mungeLatex(deck, latex) + (ok, img) = imageForLatex(deck, munged, build) if ok: - return '' % img + return '%s' % (img, latex) else: return img diff --git a/anki/utils.py b/anki/utils.py index 53c646422..8675f17b6 100644 --- a/anki/utils.py +++ b/anki/utils.py @@ -133,6 +133,11 @@ def stripHTML(s): s = entsToTxt(s) return s +def stripHTMLAlt(s): + "Strip HTML, preserving img alt text." + s = re.sub("]*alt=[\"']?([^\"'>]+)[\"']?[^>]*>", "\\1", s) + return stripHTML(s) + def stripHTMLMedia(s): "Strip HTML but keep media filenames" s = re.sub("]+)[\"']? ?/?>", " \\1 ", s)