# This is a patch for MathModePlugin.orig to update it to MathModePlugin # # To apply this patch: # STEP 1: Chdir to the source directory. # STEP 2: Run the 'applypatch' program with this patch file as input. # # If you do not have 'applypatch', it is part of the 'makepatch' package # that you can fetch from the Comprehensive Perl Archive Network: # http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz # In the above URL, 'x' should be 2 or higher. # # To apply this patch without the use of 'applypatch': # STEP 1: Chdir to the source directory. # STEP 2: Run the 'patch' program with this file as input. # #### End of Preamble #### #### Patch data follows #### diff -c 'MathModePlugin.orig/data/TWiki/MathModePlugin.txt' 'MathModePlugin/data/TWiki/MathModePlugin.txt' Index: ./data/TWiki/MathModePlugin.txt *** ./data/TWiki/MathModePlugin.txt Wed Jun 5 16:36:01 2002 --- ./data/TWiki/MathModePlugin.txt Thu Aug 8 15:03:45 2002 *************** *** 40,45 **** --- 40,48 ---- * Debug plugin: (See output in =data/debug.txt=) * Set DEBUG = 0 + * Path to =latex2html= + * Set LATEX2HTMLEXE = latex2html + ---+++ Plugin Installation Instructions * Download the archive, and unzip in the =twiki= directory. diff -c 'MathModePlugin.orig/lib/TWiki/Plugins/MathModePlugin.pm' 'MathModePlugin/lib/TWiki/Plugins/MathModePlugin.pm' Index: ./lib/TWiki/Plugins/MathModePlugin.pm *** ./lib/TWiki/Plugins/MathModePlugin.pm Wed Jun 5 16:31:14 2002 --- ./lib/TWiki/Plugins/MathModePlugin.pm Thu Aug 8 15:02:14 2002 *************** *** 85,90 **** --- 85,93 ---- #this variable will point to the init file used by latex2html my $L2H_INIT_FILEPATH = ''; + # path to latex2html executable + my $L2H_EXE = 'latex2html'; + #this variable gives the length of the hash code. If you switch to a different #hash function, you will likely have to change this my $HASH_CODE_LENGTH = 32; *************** *** 119,124 **** --- 122,130 ---- # Get plugin debug flag $debug = &TWiki::Func::getPreferencesFlag( "MATHMODEPLUGIN_DEBUG" ); + # Get path to executable + $L2H_EXE = &TWiki::Func::getPreferencesValue( "MATHMODEPLUGIN_LATEX2HTMLEXE" ) || 'latex2html'; + # Plugin correctly initialized &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin::initPlugin( $web.$topic ) is OK" ) if $debug; *************** *** 171,197 **** # Here we check if we saw any math, try to delete old files, render new math, and clean up ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! &TWiki::Func::writeDebug( "- MathModePlugin::endRenderingHandler( $web.$topic )" ) if $debug; #my @revinfo = &TWiki::Func::getRevisionInfo($web, $topic, "", 0); ! #&TWiki::Func::writeDebug( "- MathModePlugin: @revinfo" ) if $debug; #check if there was any math in this document return unless scalar( keys( %hashed_math_strings ) ); #get the full path of this topic's attachment directory my $path = &TWiki::Func::getPubDir() . "/$web/$topic"; ! &TWiki::Func::writeDebug( "Path to attachment dir: $path" ) if $debug; #does the topic's attachment directory exist? if( -e $path ) { #if it's not really a directory, we can't do anything return unless ( -d $path ); ! &TWiki::Func::writeDebug( "Directory already exists." ) if $debug; } else { #create the directory if it didn't exist return unless mkdir( $path ); ! &TWiki::Func::writeDebug( "Made the directory successfully" ) if $debug; } #move into this page's attachment directory return unless chdir( $path ); --- 177,203 ---- # Here we check if we saw any math, try to delete old files, render new math, and clean up ### my ( $text ) = @_; # do not uncomment, use $_[0] instead ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin::endRenderingHandler( $web.$topic )" ) if $debug; #my @revinfo = &TWiki::Func::getRevisionInfo($web, $topic, "", 0); ! #&TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: @revinfo" ) if $debug; #check if there was any math in this document return unless scalar( keys( %hashed_math_strings ) ); #get the full path of this topic's attachment directory my $path = &TWiki::Func::getPubDir() . "/$web/$topic"; ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Path to attachment dir: $path" ) if $debug; #does the topic's attachment directory exist? if( -e $path ) { #if it's not really a directory, we can't do anything return unless ( -d $path ); ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Directory already exists." ) if $debug; } else { #create the directory if it didn't exist return unless mkdir( $path ); ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Made the directory successfully" ) if $debug; } #move into this page's attachment directory return unless chdir( $path ); *************** *** 203,209 **** #look for existing images, delete old ones foreach my $fn ( <*.$EXT> ) { ! &TWiki::Func::writeDebug( "Found an image: $fn" ) if $debug; #is the filename the same length as one of our images? if( length( $fn ) == $HASH_CODE_LENGTH + 1 + length( $EXT ) ) { my $copy = $fn; --- 209,215 ---- #look for existing images, delete old ones foreach my $fn ( <*.$EXT> ) { ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Found an image: $fn" ) if $debug; #is the filename the same length as one of our images? if( length( $fn ) == $HASH_CODE_LENGTH + 1 + length( $EXT ) ) { my $copy = $fn; *************** *** 221,233 **** #delete the old image #pathologically, if there were an image in this directory with a long filename #that matches an MD5 hash code, we would delete it unintentionally. Oh well ! &TWiki::Func::writeDebug( "Deleting old image that I think belongs to me: $fn" ) if $debug; #the glob returns tainted data, so we need to untaint using a special regexp (see the perlsec man page) if( $fn =~ /^([-\@\w.]+)$/ ) { $fn = $1; # $fn now untainted unlink( $fn ); } else { ! &TWiki::Func::writeDebug( "How the hell did this happen? $fn" ) if $debug; } } } --- 227,239 ---- #delete the old image #pathologically, if there were an image in this directory with a long filename #that matches an MD5 hash code, we would delete it unintentionally. Oh well ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Deleting old image that I think belongs to me: $fn" ) if $debug; #the glob returns tainted data, so we need to untaint using a special regexp (see the perlsec man page) if( $fn =~ /^([-\@\w.]+)$/ ) { $fn = $1; # $fn now untainted unlink( $fn ); } else { ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: How the hell did this happen? $fn" ) if $debug; } } } *************** *** 257,267 **** close( MATHOUT ); #run latex2html on the latex file we generated, using the init file and redirecting the output ! system( "latex2html -init_file $L2H_INIT_FILEPATH $LATEXFILENAME > /dev/null" ); #rename the files to the hash code, so we can uniquely identify them while( (my $key, my $value) = each( %hash_code_mapping ) ) { ! &TWiki::Func::writeDebug( "Renaming $LATEXBASENAME/$value to $key.$EXT" ) if $debug; rename( "$LATEXBASENAME/$value", "$key.$EXT" ); } --- 263,273 ---- close( MATHOUT ); #run latex2html on the latex file we generated, using the init file and redirecting the output ! system( "$L2H_EXE -init_file $L2H_INIT_FILEPATH $LATEXFILENAME > /dev/null" ); #rename the files to the hash code, so we can uniquely identify them while( (my $key, my $value) = each( %hash_code_mapping ) ) { ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Renaming $LATEXBASENAME/$value to $key.$EXT" ) if $debug; rename( "$LATEXBASENAME/$value", "$key.$EXT" ); } *************** *** 273,279 **** $fn = $1; # $fn now untainted unlink( "$LATEXBASENAME/$fn" ); } else { ! &TWiki::Func::writeDebug( "How the hell did this happen? $fn" ) if $debug; } } #remove the directory latex2html creates --- 279,285 ---- $fn = $1; # $fn now untainted unlink( "$LATEXBASENAME/$fn" ); } else { ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: How the hell did this happen? $fn" ) if $debug; } } #remove the directory latex2html creates *************** *** 284,290 **** #clear the hash table of math strings %hashed_math_strings = (); %own_line_equation = (); ! &TWiki::Func::writeDebug( "Math strings reset, done." ) if $debug; } # ========================= --- 290,296 ---- #clear the hash table of math strings %hashed_math_strings = (); %own_line_equation = (); ! &TWiki::Func::writeDebug( "- TWiki::Plugins::MathModePlugin: Math strings reset, done." ) if $debug; } # ========================= #### End of Patch data #### #### ApplyPatch data follows #### # Data version : 1.0 # Date generated : Thu Aug 8 15:04:29 2002 # Generated by : makepatch 2.00 # Recurse directories : Yes # p 'data/TWiki/MathModePlugin.txt' 4416 1028833425 0100644 # p 'lib/TWiki/Plugins/MathModePlugin.pm' 10864 1028833334 0100644 #### End of ApplyPatch data #### #### End of Patch kit [created: Thu Aug 8 15:04:29 2002] #### #### Checksum: 236 9513 13823 ####