latex extension added to markdown, removed pylog_latex module and replaced by mimetex.cgi

master
Stefan Krulj 15 years ago
parent 9477dac558
commit 6d2cc547ac
  1. BIN
      mimetex.cgi
  2. 9
      pylog_action_impl.py
  3. 80
      pylog_latex.py

Binary file not shown.

@ -3,10 +3,7 @@ import urllib
from datetime import datetime
import pylog_config as cfg
import subprocess,tempfile
try:
import markdown
except:
import markdown2 as markdown
import markdown
from HTMLParser import HTMLParser
@ -37,7 +34,7 @@ def file_link(name,f,depth,hidden):
def disp_txt(path):
print '<div class="entrytext">'
f = open(path)
print markdown.markdown(f.read())
print markdown.markdown(f.read(),extensions=['math'])
f.close()
print '</div>'
@ -138,7 +135,7 @@ def prev(path):
def prev_txt(path):
fi = open(path)
txt=get_n_words(fi,40)
print '<div class="preview">'+markdown.markdown(txt[0])
print '<div class="preview">'+markdown.markdown(txt[0],extensions=['math'])
if txt[1]:
print '<i>&nbsp;...</i>'
print '</div>'

@ -1,80 +0,0 @@
#!/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