[system] / trunk / pg / macros / PGbasicmacros.pl Repository:
ViewVC logotype

Diff of /trunk/pg/macros/PGbasicmacros.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 4098 Revision 4386
746 $name = RECORD_ANS_NAME($name); # record answer name 746 $name = RECORD_ANS_NAME($name); # record answer name
747 my $answer_value = ''; 747 my $answer_value = '';
748 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name}); 748 $answer_value = ${$inputs_ref}{$name} if defined(${$inputs_ref}{$name});
749 my $out = ""; 749 my $out = "";
750 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or 750 if ($displayMode eq 'HTML' or $displayMode eq 'HTML_tth' or
751 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img' or $displayMode eq 'HTML_jsMath' or $displayMode eq 'HTML_asciimath') { 751 $displayMode eq 'HTML_dpng' or $displayMode eq 'HTML_img' or $displayMode eq 'HTML_jsMath' or
752 $displayMode eq 'HTML_asciimath' or $displayMode eq 'HTML_LaTeXMathML') {
752 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!; 753 $out = qq!<SELECT NAME = "$name" SIZE=1> \n!;
753 my $i; 754 my $i;
754 foreach ($i=0; $i< @list; $i=$i+2) { 755 foreach ($i=0; $i< @list; $i=$i+2) {
755 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : ""; 756 my $select_flag = ($list[$i] eq $answer_value) ? "SELECTED" : "";
756 $out .= qq!<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\n!; 757 $out .= qq!<OPTION $select_flag VALUE ="$list[$i]" > $list[$i+1] </OPTION>\n!;
1099 MODES(TeX => $tex, Latex2HTML => $l2h, HTML => $html, HTML_tth => $html, HTML_dpng => $html); 1100 MODES(TeX => $tex, Latex2HTML => $l2h, HTML => $html, HTML_tth => $html, HTML_dpng => $html);
1100} 1101}
1101 1102
1102# MODES() is now table driven 1103# MODES() is now table driven
1103our %DISPLAY_MODE_FAILOVER = ( 1104our %DISPLAY_MODE_FAILOVER = (
1104 TeX => [], 1105 TeX => [],
1105 HTML => [], 1106 HTML => [],
1106 HTML_tth => [ "HTML", ], 1107 HTML_tth => [ "HTML", ],
1107 HTML_dpng => [ "HTML_tth", "HTML", ], 1108 HTML_dpng => [ "HTML_tth", "HTML", ],
1108 HTML_jsMath => [ "HTML_dpng", "HTML_tth", "HTML", ], 1109 HTML_jsMath => [ "HTML_dpng", "HTML_tth", "HTML", ],
1109 HTML_asciimath => [ "HTML_dpng", "HTML_tth", "HTML", ], 1110 HTML_asciimath => [ "HTML_dpng", "HTML_tth", "HTML", ],
1111 HTML_LaTeXMathML => [ "HTML_dpng", "HTML_tth", "HTML", ],
1110 # legacy modes -- these are not supported, but some problems might try to 1112 # legacy modes -- these are not supported, but some problems might try to
1111 # set the display mode to one of these values manually and some macros may 1113 # set the display mode to one of these values manually and some macros may
1112 # provide rendered versions for these modes but not the one we want. 1114 # provide rendered versions for these modes but not the one we want.
1113 Latex2HTML => [ "TeX", "HTML", ], 1115 Latex2HTML => [ "TeX", "HTML", ],
1114 HTML_img => [ "HTML_dpng", "HTML_tth", "HTML", ], 1116 HTML_img => [ "HTML_dpng", "HTML_tth", "HTML", ],
1513 $out = '<SPAN CLASS="math">'.$in.'</SPAN>' if $mode eq "inline"; 1515 $out = '<SPAN CLASS="math">'.$in.'</SPAN>' if $mode eq "inline";
1514 $out = '<DIV CLASS="math">'.$in.'</DIV>' if $mode eq "display"; 1516 $out = '<DIV CLASS="math">'.$in.'</DIV>' if $mode eq "display";
1515 } elsif ($displayMode eq "HTML_asciimath") { 1517 } elsif ($displayMode eq "HTML_asciimath") {
1516 $out = "`$in`" if $mode eq "inline"; 1518 $out = "`$in`" if $mode eq "inline";
1517 $out = '<DIV ALIGN="CENTER">`'.$in.'`</DIV>' if $mode eq "display"; 1519 $out = '<DIV ALIGN="CENTER">`'.$in.'`</DIV>' if $mode eq "display";
1520 } elsif ($displayMode eq "HTML_LaTeXMathML") {
1521 $in = '{'.$in.'}';
1522 $in =~ s/</\\lt/g; $in =~ s/>/\\gt/g;
1523 $in =~ s/\{\s*(\\(display|text|script|scriptscript)style)/$1\{/g;
1524 $out = '$$'.$in.'$$' if $mode eq "inline";
1525 $out = '<DIV ALIGN="CENTER">$$\displaystyle{'.$in.'}$$</DIV>' if $mode eq "display";
1518 } else { 1526 } else {
1519 $out = "\\($in\\)" if $mode eq "inline"; 1527 $out = "\\($in\\)" if $mode eq "inline";
1520 $out = "\\[$in\\]" if $mode eq "display"; 1528 $out = "\\[$in\\]" if $mode eq "display";
1521 } 1529 }
1522 return $out; 1530 return $out;
1894 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n"; 1902 $out .= "\n\\par\\smallskip\\begin{center}\\begin{tabular}{" . "|c" x $number . "|} \\hline\n";
1895 } 1903 }
1896 elsif ($displayMode eq 'Latex2HTML') { 1904 elsif ($displayMode eq 'Latex2HTML') {
1897 $out .= "\n\\begin{rawhtml} <TABLE , BORDER=1>\n\\end{rawhtml}"; 1905 $out .= "\n\\begin{rawhtml} <TABLE , BORDER=1>\n\\end{rawhtml}";
1898 } 1906 }
1899 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') { 1907 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||
1908 $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' ||
1909 $displayMode eq 'HTML_asciimath' || $displayMode eq 'HTML_LaTeXMathML') {
1900 $out .= "<TABLE BORDER=1>\n" 1910 $out .= "<TABLE BORDER=1>\n"
1901 } 1911 }
1902 else { 1912 else {
1903 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n"; 1913 $out = "Error: PGbasicmacros: begintable: Unknown displayMode: $displayMode.\n";
1904 } 1914 }
1911 $out .= "\n\\end {tabular}\\end{center}\\par\\smallskip\n"; 1921 $out .= "\n\\end {tabular}\\end{center}\\par\\smallskip\n";
1912 } 1922 }
1913 elsif ($displayMode eq 'Latex2HTML') { 1923 elsif ($displayMode eq 'Latex2HTML') {
1914 $out .= "\n\\begin{rawhtml} </TABLE >\n\\end{rawhtml}"; 1924 $out .= "\n\\begin{rawhtml} </TABLE >\n\\end{rawhtml}";
1915 } 1925 }
1916 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') { 1926 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||
1927 $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' ||
1928 $displayMode eq 'HTML_asciimath' || $displayMode eq 'HTML_LaTeXMathML') {
1917 $out .= "</TABLE>\n"; 1929 $out .= "</TABLE>\n";
1918 } 1930 }
1919 else { 1931 else {
1920 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n"; 1932 $out = "Error: PGbasicmacros: endtable: Unknown displayMode: $displayMode.\n";
1921 } 1933 }
1939 while (@elements) { 1951 while (@elements) {
1940 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n"; 1952 $out .= " \n\\begin{rawhtml}\n<TD> \n\\end{rawhtml}\n" . shift(@elements) . " \n\\begin{rawhtml}\n</TD> \n\\end{rawhtml}\n";
1941 } 1953 }
1942 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n"; 1954 $out .= " \n\\begin{rawhtml}\n</TR> \n\\end{rawhtml}\n";
1943 } 1955 }
1944 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||$displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') { 1956 elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'||
1957 $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' ||
1958 $displayMode eq 'HTML_asciimath' || $displayMode eq 'HTML_LaTeXMathML') {
1945 $out .= "<TR>\n"; 1959 $out .= "<TR>\n";
1946 while (@elements) { 1960 while (@elements) {
1947 $out .= "<TD>" . shift(@elements) . "</TD>"; 1961 $out .= "<TD>" . shift(@elements) . "</TD>";
1948 } 1962 }
1949 $out .= "\n</TR>\n"; 1963 $out .= "\n</TR>\n";
2031 } 2045 }
2032 } elsif ($displayMode eq 'Latex2HTML') { 2046 } elsif ($displayMode eq 'Latex2HTML') {
2033 my $wid = ($envir->{onTheFlyImageSize} || 0)+ 30; 2047 my $wid = ($envir->{onTheFlyImageSize} || 0)+ 30;
2034 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="_blank" onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n 2048 $out = qq!\\begin{rawhtml}\n<A HREF= "$imageURL" TARGET="_blank" onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height"></A>\n
2035 \\end{rawhtml}\n ! 2049 \\end{rawhtml}\n !
2036 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' || $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath') { 2050 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||
2051 $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' ||
2052 $displayMode eq 'HTML_asciimath' || $displayMode eq 'HTML_LaTeXMathML') {
2037 my $wid = ($envir->{onTheFlyImageSize} || 0) +30; 2053 my $wid = ($envir->{onTheFlyImageSize} || 0) +30;
2038 $out = qq!<A HREF= "$imageURL" TARGET="_blank" onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height" $out_options{extra_html_tags} ></A> 2054 $out = qq!<A HREF= "$imageURL" TARGET="_blank" onclick="window.open(this.href,this.target, 'width=$wid,height=$wid,scrollbars=yes,resizable=on'); return false;"><IMG SRC="$imageURL" WIDTH="$width" HEIGHT="$height" $out_options{extra_html_tags} ></A>
2039 ! 2055 !
2040 } else { 2056 } else {
2041 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n"; 2057 $out = "Error: PGbasicmacros: image: Unknown displayMode: $displayMode.\n";
2063 $out = " $out " if $displayMode eq 'HTML_tth'; 2079 $out = " $out " if $displayMode eq 'HTML_tth';
2064 $out = " $out " if $displayMode eq 'HTML_dpng'; 2080 $out = " $out " if $displayMode eq 'HTML_dpng';
2065 $out = " $out " if $displayMode eq 'HTML_img'; 2081 $out = " $out " if $displayMode eq 'HTML_img';
2066 $out = " $out " if $displayMode eq 'HTML_jsMath'; 2082 $out = " $out " if $displayMode eq 'HTML_jsMath';
2067 $out = " $out " if $displayMode eq 'HTML_asciimath'; 2083 $out = " $out " if $displayMode eq 'HTML_asciimath';
2084 $out = " $out " if $displayMode eq 'HTML_LaTeXMathML';
2068 $out = " $out " if $displayMode eq 'Latex2HTML'; 2085 $out = " $out " if $displayMode eq 'Latex2HTML';
2069 $out; 2086 $out;
2070} 2087}
2071 2088
2072sub captions { 2089sub captions {
2118 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) ) 2135 $out .= "\n\\begin{rawhtml} <TH>\n\\end{rawhtml}\n".&caption( shift(@captions) )
2119 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ; 2136 . "\n\\begin{rawhtml} </TH>\n\\end{rawhtml}\n" ;
2120 } 2137 }
2121 2138
2122 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}"; 2139 $out .= "\n\\begin{rawhtml} </TR> </TABLE >\n\\end{rawhtml}";
2123 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng'|| $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' || $displayMode eq 'HTML_asciimath'){ 2140 } elsif ($displayMode eq 'HTML' || $displayMode eq 'HTML_tth' || $displayMode eq 'HTML_dpng' ||
2141 $displayMode eq 'HTML_img' || $displayMode eq 'HTML_jsMath' ||
2142 $displayMode eq 'HTML_asciimath' || $displayMode eq 'HTML_LaTeXMathML') {
2124 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n"; 2143 $out .= "<P>\n <TABLE BORDER=2 CELLPADDING=3 CELLSPACING=2 ><TR ALIGN=CENTER VALIGN=MIDDLE>\n";
2125 while (@images) { 2144 while (@images) {
2126 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>"; 2145 $out .= " \n<TD>". &image( shift(@images),%options ) ."</TD>";
2127 } 2146 }
2128 $out .= "</TR>\n<TR>"; 2147 $out .= "</TR>\n<TR>";

Legend:
Removed from v.4098  
changed lines
  Added in v.4386

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9