include latex in alt tags of generated image

This commit is contained in:
Damien Elmes 2011-01-26 12:59:24 +09:00
parent b533c99375
commit 6071f8e209
2 changed files with 8 additions and 3 deletions

View file

@ -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

View file

@ -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)