Пример #1
0
    def save(self):
        self.slug = slugify(self.title)

        temp11 = sanitizeInput(self.body_page1_col1)
        markdown11 = markdown2.markdown(temp11[0], extras=['fenced-code-blocks'])
        self.body_page1_col1_html = reconstructMath(markdown11, temp11[1])
        temp12 = sanitizeInput(self.body_page1_col2)
        markdown12 = markdown2.markdown(temp12[0], extras=['fenced-code-blocks'])
        self.body_page1_col2_html = reconstructMath(markdown12, temp12[1])
        temp21 = sanitizeInput(self.body_page2_col1)
        markdown21 = markdown2.markdown(temp21[0], extras=['fenced-code-blocks'])
        self.body_page2_col1_html = reconstructMath(markdown21, temp21[1])
        temp22 = sanitizeInput(self.body_page2_col2)
        markdown22 = markdown2.markdown(temp22[0], extras=['fenced-code-blocks'])
        self.body_page2_col2_html = reconstructMath(markdown22, temp22[1])

        super(Post,self).save()
Пример #2
0
#Some simple test strings.
test='This is a test string with \\$ some escaped $2+3$ and some non-escaped $\\$$ characters.  I hope we can find a pattern to work on this \\$$\\$ ugly$ bitch.  We had better include some $$ double $ like this $$ as well just in case.'
dtest="""This one will start off with some dobule $$ 2+4$ = 3$$, just to make shit diffiult."""
ptest = """ Let's put a few instances of the $0$ placeholder in $23+2$ just to see $0$ if it $$ $0$ $ $$ gets picked up.  Oh and don't forget a few which are escaped \\$0$ $23$"""

import libs.markdown2Mathjax.lib.markdown2Mathjax as m
tmp=m.sanitizeInput(test)
tmpd=m.sanitizeInput(dtest)
tmpp=m.sanitizeInput(ptest)

if m.reconstructMath(tmp[0],tmp[1])==test:
    print "PASS"
if m.reconstructMath(tmpd[0],tmpd[1])==dtest:
    print "PASS"
if m.reconstructMath(tmpp[0],tmpp[1])==ptest:
    print "PASS"