Initial pylog latex commit

master
Stefan Krulj 15 years ago
parent 2a372300bf
commit 9477dac558
  1. 80
      pylog_latex.py

@ -0,0 +1,80 @@
#!/usr/bin/python
import os,sys,re
import urllib, cgi
import cgitb
cgitb.enable()
form = cgi.FieldStorage()
# blacklist taken from wp-latex:
# http://wordpress.org/extend/plugins/wp-latex/
blacklist=['^^',\
'afterassignment',\
'aftergroup',\
'batchmode',\
'catcode',\
'closein',\
'closeout',\
'command',\
'csname',\
'document',\
'def',\
'errhelp',\
'errcontextlines',\
'errorstopmode',\
'every',\
'expandafter',\
'immediate',\
'include',\
'input',\
'jobname',\
'loop',\
'lowercase',\
'makeat',\
'meaning',\
'message',\
'name',\
'newhelp',\
'noexpand',\
'nonstopmode',\
'open',\
'output',\
'pagestyle',\
'package',\
'pathname',\
'read',\
'relax',\
'repeat',\
'shipout',\
'show',\
'scrollmode',\
'special',\
'syscall',\
'toks',\
'tracing',\
'typeout',\
'typein',\
'uppercase',\
'write']
sys.stdout.write('Content-type: image/png\n\n')
badtex()
latex = "$$p_n=\\frac{\\pi}{n^2}$$"
def badtex():
f=open('_img/badtex.png','rb')
sys.stdout.write(f.read())
f.close()
sys.exit(0)
for word in blacklist:
if word in latex:
badtex()
if re.search("/(^|[^\\\\])\$/",latex):
badtex()
sys.exit(0)
Loading…
Cancel
Save