You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
707 B
23 lines
707 B
def makeExtension(configs=None) :
|
|
return MathExtension()
|
|
|
|
from markdown.inlinepatterns import Pattern
|
|
import markdown, urllib
|
|
|
|
class MathPattern(Pattern):
|
|
def __init__(self,md):
|
|
Pattern.__init__(self,"\$\$(.*?)\$\$",md)
|
|
def handleMatch(self, m):
|
|
|
|
texcode=m.group(2)
|
|
el = markdown.util.etree.Element('img')
|
|
el.attrib["src"]="tex.cgi?"+self.unescape(texcode.replace(' ','%20'))
|
|
|
|
el.attrib["alt"]=self.unescape(texcode)
|
|
el.attrib["class"]='tex'
|
|
return el
|
|
|
|
class MathExtension(markdown.Extension):
|
|
def extendMarkdown(self, md, md_globals):
|
|
md.inlinePatterns.add('math', MathPattern(md), '<image_link')
|
|
|
|
|