[LON-CAPA-cvs] cvs: modules /gerd/python convert.pl

www www at source.lon-capa.org
Wed Feb 8 20:47:38 EST 2012


www		Thu Feb  9 01:47:38 2012 EDT

  Added files:                 
    /modules/gerd/python	convert.pl 
  Log:
  Work on converter
  
  

Index: modules/gerd/python/convert.pl
+++ modules/gerd/python/convert.pl
use strict;
my $filename=shift;
open(IN,$filename) or die "No such problem $filename\n";
my $input=join('',<IN>);
close(IN);
$input=~s/\{\% processor/\n\{\% processor/gs;
$input=~s/\"\"\"\"\"\"/\"\"\"\n\"\"\"/gs;
my @lines=split(/\n/,$input);

my $output="<problem>\n<startouttext />\n";
my $mode='outtext';
foreach my $line (@lines) {
   if ($mode eq 'outtext') {
      $line=~s/<br>/<br \/>\n/gs;
      $line=~s/\{\% math eq=\"([^\"]+)\".*\}/ <m>\$$1\$<\/m>/gs;
      $output.=$line."\n";
   }
}
$output.="</problem>\n";
print $output;




More information about the LON-CAPA-cvs mailing list