[LON-CAPA-cvs] cvs: modules /gerd/chm translate.pl

www lon-capa-cvs-allow@mail.lon-capa.org
Wed, 11 Apr 2007 14:40:37 -0000


www		Wed Apr 11 10:40:37 2007 EDT

  Modified files:              
    /modules/gerd/chm	translate.pl 
  Log:
  Deal with tables
  
  
Index: modules/gerd/chm/translate.pl
diff -u modules/gerd/chm/translate.pl:1.1 modules/gerd/chm/translate.pl:1.2
--- modules/gerd/chm/translate.pl:1.1	Wed Apr 11 10:08:10 2007
+++ modules/gerd/chm/translate.pl	Wed Apr 11 10:40:37 2007
@@ -11,10 +11,15 @@
       ($topic)=($line=~/\s+T\:\s(\w+)\s+/i);
       $topic=~s/\_/ /g;
       ($subtopic)=($line=~/\s+ST\:\s(.+)$/);
+      $intermediate='';
       next;
    }
    if ($line=~/^\s+Date\(s\)\:\s+(.+)$/) {
       $prevsem=$1;
+      if ($intable) {
+         $intermediate.="</tr>\n</table>\n";
+      }
+      $question=$intermediate;
       next;
    }
    if ($line=~/^\s+Author\:\s+(.+)$/) {
@@ -46,8 +51,25 @@
       $image=$1;
       next;
    }
-
- 
+   $intable=0;
+   foreach $subline (split(/\<RET\>/,$line)) {
+      unless ($subline=~/\w/) { next; }
+      if (($subline=~/\t/) && (!$intable)) {
+         $intermediate.="\n<table border='2'>\n<tr><td>";
+         $intable=1;
+      }
+      if (($subline!~/\t/) && ($intable)) {
+         $intermediate.="\n</table>";
+         $intable=0;
+      } 
+      if ($intable) {
+         $subline=~s/\t/\<\/td\>\<td\>/gs;
+         $subline.="</td></tr>\n<tr>";
+      } else {
+         $subline.="<br />\n";
+      }
+      $intermediate.=$subline;
+   }
 }
 writeout();
 close(IN);
@@ -69,5 +91,6 @@
     if ($discipline) { print OUT "<meta name='discipline' content='$discipline' />\n" };
     if ($reference) { print OUT "<meta name='reference' content='$reference' />\n" };
     if ($image) { print OUT "<img src='$image' />\n"; }
+    print OUT "<startouttext />$question<endouttext />\n";
     print OUT "</problem>\n";
 }