This is how I added the [LaTeX] support:
"\"
will join line ends.
# Comment this line out. # $pageText =~ s/\\ *\r?\n/ /g; # Join lines with backslash at endThats about it i think. This is how my site looks:
#At top add this: use Digest::MD5 qw(md5 md5_hex md5_base64); #also change your #DataDir to be absolute. ie "/var/lib/wiki_database/" $IndexFile = "$DataDir/pageidx"; # List of all pages +++ $LatexDir = "$DataDir/files/latex"; ------- sub CommonMarkup { . . . s/\<pre\>((.|\n)*?)\<\/pre\>/&StorePre($1, "pre")/ige; s/\<code\>((.|\n)*?)\<\/code\>/&StorePre($1, "code")/ige; #recent addons: +++ ##matchin $$ $$ pairs / LaTeX +++ s/\$\$((.|\n)*?)\$\$/&StoreRaw(&MakeLaTeX("\$\$"."$1". "\$\$"))/ige; #this will match \begin{XXX} \end{XXX} pairs very neat... +++ my ($eq) = $_ =~ /\\begin\{(.*?)\}/; +++ s/\\begin((.|\n)*?)\\end\{.*?\}/&StoreRaw(&MakeLaTeX("\\begin" . "$1" . "\\end{$eq}"))/igem; . . } ------------ #at this point: sub StorePre { my ($html, $tag) = @_; return &StoreRaw("<$tag>" . $html . "</$tag>"); } ### Ok this part should be added: sub MakeLaTeX { my($latex) = @_; my $hash = md5_base64($latex); if(-f "$LatexDir/$hash.png" and not -z "$LatexDir/$hash.png") { #check in cache return("<img border=0 src=\"/files/latex/$hash.png\">"); } #setup rendering directory in /tmp/ my $dir = "/tmp/$hash"; mkdir($dir); qx(/bin/cp $DataDir/.latex2html-init $dir); chdir ($dir); open(FILE,"$DataDir/.template") ; my $template = ''; while(<FILE>) { $template .= $_; } $template =~ s/<math>/$latex/ige; close FILE; open (OUTFILE, ">>srender.tex"); print OUTFILE $template; close OUTFILE; qx(/usr/bin/latex2html $dir/srender.tex >$dir/error.out 2>&1); qx(/bin/cp $dir/img1.png $LatexDir/$hash.png); qx(/bin/rm -r $dir); return("<img border=0 src=\"/files/latex/$hash.png\">"); } -----
\documentclass[12pt]{article} \pagestyle{empty} \begin{document} \definecolor{color1}{rgb}{0.8,0,0} \textcolor{color1}{ $$<math>$$ } \end{document} -----
$NO_NAVIGATION = 1; $ADDRESS = ""; $TRANSPARENT_FIGURES = 0; $MATH_SCALE_FACTOR = 1.7; $INFO = 0; $ANTI_ALIAS = 0; $WHITE_BACKGROUND = 1; $IMAGE_TYPE = png; $MAX_SPLIT_DEPTH = 0; $REUSE = 2; $NEWDIR_MODE = 'd'; $NO_SUBDIR = 1; $DONT_INCLUDE .= '.pstex_t:'; sub meta_information { ""; } 1; --------
it won't really matter, the crypt() function (or actually any hashing function) will work.
Slight problem: I keep getting hashes containing "/"s which causes some problems... Once I've learned enough Perl to fix it I'll stick the solution here. -- Alex Labram
my $hash = md5_base64($latex);
$hash =~ s/\W//g;
I recently set up wikis at http://www.scarymath.org/ which run OddMuse plus a modification of this patch. Basically, I couldn't get LaTeX2HTML? to behave and besides, using it seems like overkill, so I modified the patch like so:
In MakeLaTeX?, I replaced your executions of latex2html etc. with the following:
qx(latex srender.tex); qx(dvi2bitmap -fp /var/cache/fonts/pk/ibmvga/public/cm/ -Pc -m 1.7 -t png srender.dvi); if (-f 'srender-page1.png' and not -z 'srender-page1.png') { qx(cp srender-page1.png $LatexDir?/$hash.png); } qx(/bin/rm -r $dir);
Share and Enjoy!
*I just setup my wiki on Windows XP IIS using MikTeX + ImageMagic because all latex2html, dvi2bitmap, and dvipng gave me real hard time. Now everything works for inline and displayed math, but how to make aligned math work still is a problem to me. and -- WenFongKe?