[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 2369 Revision 2370
1065sub M3 { 1065sub M3 {
1066 my($tex,$l2h,$html) = @_; 1066 my($tex,$l2h,$html) = @_;
1067 MODES(TeX => $tex, Latex2HTML => $l2h, HTML => $html, HTML_tth => $html, HTML_dpng => $html); 1067 MODES(TeX => $tex, Latex2HTML => $l2h, HTML => $html, HTML_tth => $html, HTML_dpng => $html);
1068} 1068}
1069 1069
1070# MODES() is now table driven
1071our %DISPLAY_MODE_FAILOVER = (
1072 TeX => [],
1073 HTML => [],
1074 HTML_tth => [ "HTML", ],
1075 HTML_dpng => [ "HTML_tth", "HTML", ],
1076 HTML_jsMath => [ "HTML_dpng", "HTML_tth", "HTML", ],
1077 HTML_asciimath => [ "HTML_dpng", "HTML_tth", "HTML", ],
1078 # legacy modes -- these are not supported, but some problems might try to
1079 # set the display mode to one of these values manually and some macros may
1080 # provide rendered versions for these modes but not the one we want.
1081 Latex2HTML => [ "TeX", "HTML", ],
1082 HTML_img => [ "HTML_dpng", "HTML_tth", "HTML", ],
1083);
1084
1070# This replaces M3. You can add new modes at will to this one. 1085# This replaces M3. You can add new modes at will to this one.
1071
1072sub MODES { 1086sub MODES {
1073 my %options = @_; 1087 my %options = @_;
1074 1088
1089 # is a string supplied for the current display mode? if so, return it
1075 return $options{$displayMode} if defined $options{$displayMode}; 1090 return $options{$displayMode} if defined $options{$displayMode};
1076 1091
1077 if (exists $envir{displayModeFailover}->{$displayMode}) { 1092 # otherwise, fail over to backup modes
1078 my @backup_modes = @{$envir{displayModeFailover}->{$displayMode}}; 1093 my @backup_modes;
1094 if (exists $DISPLAY_MODE_FAILOVER{$displayMode}) {
1095 @backup_modes = @{$DISPLAY_MODE_FAILOVER{$displayMode}};
1079 foreach my $mode (@backup_modes) { 1096 foreach my $mode (@backup_modes) {
1080 return $options{$mode} if defined $options{$mode}; 1097 return $options{$mode} if defined $options{$mode};
1081 } 1098 }
1099 }
1082 die "ERROR in defining MODES: neither display mode $displayMode nor", 1100 die "ERROR in defining MODES: neither display mode $displayMode nor",
1083 " any fallback modes (", join(", ", @backup_modes), ") defined.\n"; 1101 " any fallback modes (", join(", ", @backup_modes), ") supplied.\n";
1084 }
1085
1086 die "ERROR in defining MODES: current display mode '$displayMode' not found. available modes: ",
1087 join (", ", keys %{$envir{displayModeFailover}}), "\n";
1088
1089 return $options{$displayMode}
1090 if defined( $options{$displayMode} );
1091
1092=for comment
1093
1094 # default searches.
1095 if ($displayMode eq "Latex2HTML") {
1096 return $options{TeX}
1097 if defined( $options{TeX} );
1098 return $options{HTML}
1099 if defined( $options{HTML} );
1100 die " ERROR in using MODES: 'HTML' and 'TeX' options not defined for 'Latex2HTML'";
1101 }
1102
1103 if ($displayMode eq "HTML_tth") {
1104 return $options{HTML}
1105 if defined( $options{HTML} );
1106 die " ERROR in using MODES: 'HTML' option not defined for HTML_tth";
1107
1108 }
1109
1110 if ($displayMode eq "HTML_img") {
1111 return $options{HTML_dpng} if defined $options{HTML_dpng};
1112 return $options{HTML_tth} if defined $options{HTML_tth};
1113 return $options{HTML} if defined $options{HTML};
1114 die " ERROR in using MODES: 'HTML' option not defined for HTML_img";
1115 }
1116
1117 if ($displayMode eq "HTML_dpng") {
1118 return $options{HTML_tth}
1119 if defined( $options{HTML_tth} );
1120 return $options{HTML}
1121 if defined( $options{HTML} );
1122 die " ERROR in using MODES: 'HTML' option not defined for HTML_dpng";
1123
1124 }
1125
1126 if ($displayMode eq "HTML_jsMath") {
1127 return $options{HTML_img} if defined $options{HTML_img};
1128 return $options{HTML_dpng} if defined $options{HTML_dpng};
1129 return $options{HTML_tth} if defined $options{HTML_tth};
1130 return $options{HTML} if defined $options{HTML};
1131 die " ERROR in using MODES: 'HTML' option not defined for HTML_jsMath";
1132 }
1133
1134 if ($displayMode eq "HTML_asciimath") {
1135# return $options{HTML_img} if defined $options{HTML_img};
1136# return $options{HTML_dpng} if defined $options{HTML_dpng};
1137 return $options{HTML_tth} if defined $options{HTML_tth};
1138 return $options{HTML} if defined $options{HTML};
1139 die " ERROR in using MODES: 'HTML' option not defined for HTML_asciimath";
1140 }
1141
1142 # trap undefined errors
1143 die "ERROR in defining MODES: Can't find |$displayMode| among
1144 available options:" . join(" ", keys(%options) )
1145 . " file " . __FILE__ ." line " . __LINE__."\n\n";
1146
1147=cut
1148
1149} 1102}
1150
1151 1103
1152# end display macros 1104# end display macros
1153 1105
1154 1106
1155=head2 Display constants 1107=head2 Display constants

Legend:
Removed from v.2369  
changed lines
  Added in v.2370

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9