mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
include latex in alt tags of generated image
This commit is contained in:
parent
b533c99375
commit
6071f8e209
2 changed files with 8 additions and 3 deletions
|
@ -120,10 +120,10 @@ def imageForLatex(deck, latex, build=True):
|
||||||
|
|
||||||
def imgLink(deck, latex, build=True):
|
def imgLink(deck, latex, build=True):
|
||||||
"Parse LATEX and return a HTML image representing the output."
|
"Parse LATEX and return a HTML image representing the output."
|
||||||
latex = mungeLatex(deck, latex)
|
munged = mungeLatex(deck, latex)
|
||||||
(ok, img) = imageForLatex(deck, latex, build)
|
(ok, img) = imageForLatex(deck, munged, build)
|
||||||
if ok:
|
if ok:
|
||||||
return '<img src="%s">' % img
|
return '<img src="%s" alt="%s">' % (img, latex)
|
||||||
else:
|
else:
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,11 @@ def stripHTML(s):
|
||||||
s = entsToTxt(s)
|
s = entsToTxt(s)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
def stripHTMLAlt(s):
|
||||||
|
"Strip HTML, preserving img alt text."
|
||||||
|
s = re.sub("<img [^>]*alt=[\"']?([^\"'>]+)[\"']?[^>]*>", "\\1", s)
|
||||||
|
return stripHTML(s)
|
||||||
|
|
||||||
def stripHTMLMedia(s):
|
def stripHTMLMedia(s):
|
||||||
"Strip HTML but keep media filenames"
|
"Strip HTML but keep media filenames"
|
||||||
s = re.sub("<img src=[\"']?([^\"'>]+)[\"']? ?/?>", " \\1 ", s)
|
s = re.sub("<img src=[\"']?([^\"'>]+)[\"']? ?/?>", " \\1 ", s)
|
||||||
|
|
Loading…
Reference in a new issue