[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=(
+ '±' => '\pm',
+ '´' => '\times',
+ '¸' => '\div',
+ 'Ò' => '(R)',
+ 'Ó' => '\copy',
+ 'Ø' => '\neg',
+ 'â' => '(R)',
+ 'ã' => '\copy',
+ '¦' => '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',
+ '¡' => '\Upsilon',
+ '¢' => "'",
+ '¤' => '/',
+ '²' => '"',
+ '¼' => '\ldots',
+ 'À' => '\aleph',
+ 'Á' => '\Im',
+ 'Â' => '\Re',
+ 'Ã' => '\wp',
+ 'Ô' => '^{TM}',
+ 'ä' => '^{TM}',
+ 'ð' => 'EUR',
+ '«' => '\leftrightarrow',
+ '¬' => '\leftarrow',
+ '­' => '\uparrow',
+ '®' => '\rightarrow',
+ '¯' => '\downarraw',
+ '¿' => '\hookleftarrow',
+ 'Û' => '\Leftrightarrow',
+ 'Ü' => '\Leftarrow',
+ 'Ý' => '\Uparrow',
+ 'Þ' => '\Rightarrow',
+ 'ß' => '\Downarrow',
+ '"' => '\forall',
+ '$' => '\exists',
+ ''' => '\ni',
+ '*' => '\ast',
+ '-' => '-',
+ '@' => '\cong',
+ '\' => '\therefore',
+ '^' => '\perp',
+ '~' => '\sim',
+ '£' => '\leq',
+ '¥' => '\infty',
+ '³' => '\geq',
+ 'µ' => '\propto',
+ '¶' => '\partial',
+ '·' => '\cdot',
+ '¹' => '\not=',
+ 'º' => '\equiv',
+ '»' => '\approx',
+ 'Ä' => '\otimes',
+ 'Å' => '\oplus',
+ 'Æ' => '\emptyset',
+ 'Ç' => '\cap',
+ 'È' => '\cup',
+ 'É' => '\supset',
+ 'Ê' => '\supseteq',
+ 'Ë' => '\not\subset',
+ 'Ì' => '\subset',
+ 'Í' => '\subseteq',
+ 'Î' => '\in',
+ 'Ï' => '\not\in',
+ 'Ð' => '\angle',
+ 'Ñ' => '\nabla',
+ 'Õ' => '\prod',
+ 'Ö' => '\surd',
+ '×' => '\cdot',
+ 'Ù' => '\wedge',
+ 'Ú' => '\wee',
+ 'å' => '\sum',
+ 'ò' => '\int',
+ 'á' => '\langle',
+ 'ñ' => '\rangle',
+ 'à' => '\diamondsuit',
+ '§' => '\clubsuit',
+ '¨' => '\diamondsuit',
+ '©' => '\heartsuit',
+ 'ª' => '\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--