def Xtest_generate_image_from_latex(self):
     # image is 19 high on my system.. assume it's alright for now
     #m = re.match(r'<img alt="a" class="equation" src="images/([^"]*)" width="10" height="8">',
     m = re.match(r'<img alt="a" class="equation" src="images/([^"]+)" width="10" height="',
                  replaceInlineLatex('$a$', 17, 0.0, 1.03))
     # image tag generated ?
     self.assert_(m)
     # latexwiki image dir writable ?
     self.assert_(os.access(IMAGEDIR, os.W_OK))
     # image file exists ? XXX could have been created by a previous run
     self.assert_(os.access(os.path.join(IMAGEDIR,m.group(1)), os.R_OK)) 
예제 #2
0
    def preRender(self, page, text=None):
        t = text or (page.document() + '\n' + MIDSECTIONMARKER + self.preRenderMessages(page))
        (b,t) = replacePamphlet(page,t)
	# Render remaining out-of-band text as stx+latex (axiom version)
        latexTemplate = None
        latexTemplatePage = getattr(page.folder(),
                                    'LatexTemplate', None)
        if latexTemplatePage:
            latexTemplate = latexTemplatePage.text()
        t = replaceInlineLatex(t, getattr(page.folder(),'latex_font_size',defaultcharsizepx), \
                                  getattr(page.folder(),'latex_align_fudge',0), 
                                  getattr(page.folder(),'latex_res_fudge',1.03), latexTemplate)
        t = page.applyWikiLinkLineEscapesIn(t)
        # Be more generous in STX for links...so they can contain equations
        t = re.sub(r'(^| )(?ms)"([^"]*)":(http://[-:A-Za-z0-9_,./\?=@#~&%()]*?)([.!?,;](?= )|(?= )|$)',\
            r'\1<a href="\3">\2</a>\4',t)
        t = self.format(t)
        t = page.markLinksIn(t)
        t = self.protectEmailAddresses(page,t)
        return '<div class="latexwiki">\n' + b + t + '\n</div>\n'
예제 #3
0
    def preRender(self, page, text=None):
	global savePre
	savePre=[]
        reConsts = re.DOTALL+re.MULTILINE

        def hidePre(x):
            global savePre
            savePre.append(x.group(0))
            return '<pre></pre>'

        def restorePre(x):
            global savePre
            first,savePre = savePre[0],savePre[1:]
            return first

        latexTemplate = None
        latexTemplatePage = getattr(page.folder(),
                                    'LatexTemplate', None)
        if latexTemplatePage:
            latexTemplate = latexTemplatePage.text()
        t = text or (page.document() + '\n' + MIDSECTIONMARKER + self.preRenderMessages(page))
        # PROTECT all preformatted areas from LaTeX, Axiom etc.
	savePre=[]
	t = re.sub(r'<pre(?: .*?)?>.*?</pre>',hidePre,t,reConsts)
        # replace latex and also axiom, reduce, maxima etc. markup
        t = replaceInlineLatex(t, getattr(page.folder(),'latex_font_size',defaultcharsizepx), \
                                  getattr(page.folder(),'latex_align_fudge',0), 
                                  getattr(page.folder(),'latex_res_fudge',1.03), latexTemplate)
        t = re.sub(r'<pre></pre>',restorePre,t,reConsts)
        # PROTECT all preformatted areas from stx
	savePre=[]
	t = re.sub(r'<pre(?: .*?)?>.*?</pre>',hidePre,t,reConsts)
        t = page.applyWikiLinkLineEscapesIn(t)
        # Be more generous in STX for links...so they can contain equations
        t = re.sub(r'(^| )(?ms)"([^"]*)":(http://[-:A-Za-z0-9_,./\?=@#~&%()]*?)([.!?,;](?= )|(?= )|$)',\
            r'\1<a href="\3">\2</a>\4',t)
        t = self.format(t)
        t = page.markLinksIn(t)
        t = self.protectEmailAddresses(page,t)
        t = re.sub(r'<pre></pre>',restorePre,t,reConsts)
        return '<div class="latexwiki">\n' + t + '\n</div>\n'