mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -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):
|
||||
"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 src="%s">' % img
|
||||
return '<img src="%s" alt="%s">' % (img, latex)
|
||||
else:
|
||||
return img
|
||||
|
||||
|
|
|
@ -133,6 +133,11 @@ def stripHTML(s):
|
|||
s = entsToTxt(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):
|
||||
"Strip HTML but keep media filenames"
|
||||
s = re.sub("<img src=[\"']?([^\"'>]+)[\"']? ?/?>", " \\1 ", s)
|
||||
|
|
Loading…
Reference in a new issue