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

www lon-capa-cvs@mail.lon-capa.org
Thu, 01 Sep 2005 16:17:20 -0000


This is a MIME encoded message

--www1125591440
Content-Type: text/plain

www		Thu Sep  1 12:17:20 2005 EDT

  Modified files:              
    /modules/gerd/ct	convert.pl 
  Log:
  Cont work
  
  
--www1125591440
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20050901121720.txt"

Index: modules/gerd/ct/convert.pl
diff -u modules/gerd/ct/convert.pl:1.1 modules/gerd/ct/convert.pl:1.2
--- modules/gerd/ct/convert.pl:1.1	Thu Sep  1 11:50:42 2005
+++ modules/gerd/ct/convert.pl	Thu Sep  1 12:17:20 2005
@@ -31,3 +31,221 @@
     }
 }
 close(IN);
+for (my $i=0;$i<=$#ConceptTest;$i++) {
+    if ($ConceptTest[$i]=~/\w+/) {
+        my $line=$ConceptTest[$i];
+        $line=~s/\,(\d+)\,/\,\'$1\'\,/g;
+	my ($typeid,$intro,$postcomment,$imageid,$outro,$answertext,$answerimageid,$statusid)=split(/\'\,\'/,$line);
+        print "\n------\n".&htmlclean($intro);
+    }
+}
+
+ 
+sub latextrans {
+    my $symbolfont=shift;
+    my %latexsymb=(
+                   '&#177;' => '\pm',
+                   '&#180;' => '\times',
+                   '&#184;' => '\div',
+                   '&#210;' => '(R)',
+                   '&#211;' => '\copy',
+                   '&#216;' => '\neg',
+                   '&#226;' => '(R)',
+                   '&#227;' => '\copy',
+                   '&#166;' => 'f',
+                   'A' => '\Alpha',
+                   'B' => '\Beta',
+                   'G' => '\Gamma',
+                   'D' => '\Delta',
+                   'E' => '\Epsilon',
+                   'Z' => '\Zeta',
+                   'H' => '\Eta',
+                   'Q' => '\Theta',
+                   'I' => '\Iota',
+                   'K' => '\Kappa',
+                   'L' => '\Lambda',
+                   'M' => '\Mu',
+                   'N' => '\Nu',
+                   'X' => '\Xi',
+                   'O' => '\Omicron',
+                   'P' => '\Pi',
+                   'R' => '\Rho',
+                   'S' => '\Sigma',
+                   'T' => '\Tau',
+                   'U' => 'Y',
+                   'F' => '\Phi',
+                   'C' => '\Chi',
+                   'Y' => '\Psi',
+                   'W' => '\Omega',
+                   'a' => '\alpha',
+                   'b' => '\beta',
+                   'g' => '\gamma',
+                   'd' => '\delta',
+                   'e' => '\epsilon',
+                   'z' => '\zeta',
+                   'h' => '\eta',
+                   'q' => '\theta',
+                   'i' => '\iota',
+                   'k' => '\kappa',
+                   'l' => '\lambda',
+                   'm' => '\mu',
+                   'n' => '\nu',
+                   'x' => '\xi',
+                   'o' => '\omicron',
+                   'p' => '\pi',
+                   'r' => '\rho',
+                   'V' => '\sigmaf',
+                   's' => '\sigma',
+                   't' => '\tau',
+                   'u' => '\upsilon',
+                   'f' => '\phi',
+                   'c' => '\chi',
+                   'y' => '\psi',
+                   'w' => '\omega',
+                   'J' => '\vartheta',
+                   'j' => '\varphi',
+                   'v' => '\varpi',
+                   '&#161;' => '\Upsilon',
+                   '&#162;' => "'",
+                   '&#164;' => '/',
+                   '&#178;' => '"',
+                   '&#188;' => '\ldots',
+                   '&#192;' => '\aleph',
+                   '&#193;' => '\Im',
+                   '&#194;' => '\Re',
+                   '&#195;' => '\wp',
+                   '&#212;' => '^{TM}',
+                   '&#228;' => '^{TM}',
+                   '&#240;' => 'EUR',
+                   '&#171;' => '\leftrightarrow',
+                   '&#172;' => '\leftarrow',
+                   '&#173;' => '\uparrow',
+                   '&#174;' => '\rightarrow',
+                   '&#175;' => '\downarraw',
+                   '&#191;' => '\hookleftarrow',
+                   '&#219;' => '\Leftrightarrow',
+                   '&#220;' => '\Leftarrow',
+                   '&#221;' => '\Uparrow',
+                   '&#222;' => '\Rightarrow',
+                   '&#223;' => '\Downarrow',
+                   '&#34;' => '\forall',
+                   '&#36;' => '\exists',
+                   '&#39;' => '\ni',
+                   '&#42;' => '\ast',
+                   '&#45;' => '-',
+                   '&#64;' => '\cong',
+                   '&#92;' => '\therefore',
+                   '&#94;' => '\perp',
+                   '&#126;' => '\sim',
+                   '&#163;' => '\leq',
+                   '&#165;' => '\infty',
+                   '&#179;' => '\geq',
+                   '&#181;' => '\propto',
+                   '&#182;' => '\partial',
+                   '&#183;' => '\cdot',
+                   '&#185;' => '\not=',
+                   '&#186;' => '\equiv',
+                   '&#187;' => '\approx',
+                   '&#196;' => '\otimes',
+                   '&#197;' => '\oplus',
+                   '&#198;' => '\emptyset',
+                   '&#199;' => '\cap',
+                   '&#200;' => '\cup',
+                   '&#201;' => '\supset',
+                   '&#202;' => '\supseteq',
+                   '&#203;' => '\not\subset',
+                   '&#204;' => '\subset',
+                   '&#205;' => '\subseteq',
+                   '&#206;' => '\in',
+                   '&#207;' => '\not\in',
+                   '&#208;' => '\angle',
+                   '&#209;' => '\nabla',
+                   '&#213;' => '\prod',
+                   '&#214;' => '\surd',
+                   '&#215;' => '\cdot',
+                   '&#217;' => '\wedge',
+                   '&#218;' => '\wee',
+                   '&#229;' => '\sum',
+                   '&#242;' => '\int',
+                   '&#225;' => '\langle',
+                   '&#241;' => '\rangle',
+                   '&#224;' => '\diamondsuit',
+                   '&#167;' => '\clubsuit',
+                   '&#168;' => '\diamondsuit',
+                   '&#169;' => '\heartsuit',
+                   '&#170;' => '\spadesuit'
+                   );
+    my $output='';
+    my $char='';
+    my $entitymode=0;
+    for (my $i=0; $i<length($symbolfont); $i++) {
+        my $newchar=substr($symbolfont,$i,1);
+        $char.=$newchar;
+        if ($newchar eq '&') { $entitymode=1; }
+        if (($entitymode) && ($newchar ne ';')) { next; }
+        my $latex=$latexsymb{$char};
+        if ($latex) {
+            $output.=$latex;
+        } else {
+            $output.=$char;
+        }
+        $char='';
+        $entitymode=0;
+    }
+    return $output;
+}
+ 
+sub insidetrans {
+    my @args=@_;
+    return '<font'.$args[0].$args[1].'><m>$'.&latextrans($args[2]).'$</m>';
+}
+ 
+sub symbolfontreplace {
+    my $text=shift;
+    my @fragments=split(/\<\/font\>/si,$text);
+    for (my $i=0; $i<=$#fragments;$i++) {
+        $fragments[$i]=~s/\<font([^\>]*)\s+face=[\"\']*symbol[\"\']*([^\>]*)\>(.*)$/&insidetrans($1,$2,$3)/gsie;
+    }
+    return join('</font>',@fragments);
+}
+ 
+sub htmlclean {
+    my ($raw,$full,$blocklinefeed,$blockemptytags,$blocklowercasing,$blockdesymboling)=@_;
+# Take care of CRLF etc
+    unless ($blocklinefeed) {
+        $raw=~s/\\r/\r/g;
+        $raw=~s/\\n/\n/g;
+        $raw=~s/\r\f/\n/gs; $raw=~s/\f\r/\n/gs;
+        $raw=~s/\r\n/\n/gs; $raw=~s/\n\r/\n/gs;
+        $raw=~s/\f/\n/gs; $raw=~s/\r/\n/gs;
+        $raw=~s/\&\#10\;/\n/gs; $raw=~s/\&\#13\;/\n/gs;
+    }
+# Generate empty tags, remove wrong end tags
+    unless ($blockemptytags) {
+        $raw=~s/\<(br|hr|img|meta|embed|allow|basefont)([^\>]*?)\>/\<$1$2 \/\>/gis;
+        $raw=~s/\<\/(br|hr|img|meta|embed|allow|basefont)\>//gis;
+        $raw=~s/\/ \/\>/\/\>/gs;
+        unless ($full) {
+            $raw=~s/\<[\/]*(body|head|html)\>//gis;
+        }
+    }
+# Make standard tags lowercase
+    unless ($blocklowercasing) {
+        foreach ('html','body','head','meta','h1','h2','h3','h4','b','i','m',
+                 'table','tr','td','th','p','br','hr','img','embed','font',
+                 'a','strong','center','title','basefont','li','ol','ul',
+                 'input','select','form','option','script','pre') {
+            $raw=~s/\<$_\s*\>/\<$_\>/gis;
+            $raw=~s/\<\/$_\s*\>/<\/$_\>/gis;
+            $raw=~s/\<$_\s([^\>]*)\>/<$_ $1\>/gis;
+        }
+    }
+# Replace <font face="symbol">
+    unless ($blockdesymboling) {
+        $raw=&symbolfontreplace($raw);
+    }
+    return $raw;
+}
+ 
+
+

--www1125591440--