1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
|
# comes from alltt
if ($alltt_rx) {
$alltt_rx = 'vcode'."|$alltt_rx";
$alltt_rx =~ s/\|{2,}/\|/g; $alltt_rx =~ s/\|$//g;
} else {
$alltt_rx = 'vcode';
}
# everything here is inspired from other .perl files
# in the styles subdirectory of latex2html.
# There is no official documentation on how to implement
# new commands, except the ones that need to be ignored
# or passed to LaTeX to generate images.
&do_require_package ('alltt');
sub do_math_cmd_R {
('', '\\Re');
}
sub do_cmd_class {
local($_) = @_;
my $arg;
$arg = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
join ('', "{\@link $arg}", $_);
}
sub do_cmd_externalclass {
local($_) = @_;
my ($package, $class);
$package = &missing_braces unless (
(s/$next_pair_pr_rx/$package = $2;''/eo)
||(s/$next_pair_rx/$package = $2;''/eo));
$class = &missing_braces unless (
(s/$next_pair_pr_rx/$class = $2;''/eo)
||(s/$next_pair_rx/$class = $2;''/eo));
join ('', "{\@link $package.$class $class}", $_);
}
sub do_cmd_method {
local($_) = @_;
my ($method,$signature);
$method = &missing_braces unless (
(s/$next_pair_pr_rx/$method = $2;''/eo)
||(s/$next_pair_rx/$method = $2;''/eo));
$signature = &missing_braces unless (
(s/$next_pair_pr_rx/$signature = $2;''/eo)
||(s/$next_pair_rx/$signature = $2;''/eo));
$signature = "($signature)" if (length ($signature) > 0);
join ('', "{\@link #$method$signature $method}", $_);
}
sub do_cmd_externalmethod {
local($_) = @_;
my ($package, $class, $method, $signature);
$package = &missing_braces unless (
(s/$next_pair_pr_rx/$package = $2;''/eo)
||(s/$next_pair_rx/$package = $2;''/eo));
$class = &missing_braces unless (
(s/$next_pair_pr_rx/$class = $2;''/eo)
||(s/$next_pair_rx/$class = $2;''/eo));
$method = &missing_braces unless (
(s/$next_pair_pr_rx/$method = $2;''/eo)
||(s/$next_pair_rx/$method = $2;''/eo));
$signature = &missing_braces unless (
(s/$next_pair_pr_rx/$signature = $2;''/eo)
||(s/$next_pair_rx/$signature = $2;''/eo));
$package .= '.' if (length($package) > 0);
$signature = "($signature)" if (length ($signature) > 0);
join ('', "{\@link $package$class#$method$signature $method}", $_);
}
sub do_cmd_clsexternalmethod {
local($_) = @_;
my ($package, $class, $method, $signature);
$package = &missing_braces unless (
(s/$next_pair_pr_rx/$package = $2;''/eo)
||(s/$next_pair_rx/$package = $2;''/eo));
$class = &missing_braces unless (
(s/$next_pair_pr_rx/$class = $2;''/eo)
||(s/$next_pair_rx/$class = $2;''/eo));
$method = &missing_braces unless (
(s/$next_pair_pr_rx/$method = $2;''/eo)
||(s/$next_pair_rx/$method = $2;''/eo));
$signature = &missing_braces unless (
(s/$next_pair_pr_rx/$signature = $2;''/eo)
||(s/$next_pair_rx/$signature = $2;''/eo));
$package .= '.' if (length($package) > 0);
$signature = "($signature)" if (length ($signature) > 0);
join ('', "{\@link $package$class#$method$signature $class.$method}", $_);
}
sub do_cmd_param {
local($_) = @_;
my ($arg, $desc);
$arg = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
$desc = &missing_braces unless (
(s/$next_pair_pr_rx/$desc = $2;''/eo)
||(s/$next_pair_rx/$desc = $2;''/eo));
join ('', "\@param $arg $desc\n", $_);
}
sub do_cmd_blocktag {
local($_) = @_;
my ($arg, $desc);
$tagname = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
$desc = &missing_braces unless (
(s/$next_pair_pr_rx/$desc = $2;''/eo)
||(s/$next_pair_rx/$desc = $2;''/eo));
join ('', "$tagname $desc\n", $_);
}
sub do_cmd_return {
local($_) = @_;
my $text;
$text = &missing_braces unless (
(s/$next_pair_pr_rx/$text = $2;''/eo)
||(s/$next_pair_rx/$text = $2;''/eo));
join ('', "\@return $text", $_);
}
sub do_cmd_exception {
local($_) = @_;
my ($arg, $desc);
$arg = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
$desc = &missing_braces unless (
(s/$next_pair_pr_rx/$desc = $2;''/eo)
||(s/$next_pair_rx/$desc = $2;''/eo));
join ('', "\@exception $arg $desc\n", $_);
}
# Some problems arise with math commands
# Some symbols must not be
# displayed as a Unicode char
# because they cause display problems
# with some browsers.
%custom_math_tr = (
'lfloor', 'floor(',
'rfloor', ')',
'lceil', 'ceil(',
'rceil', ')',
'approx', ' =~ ',
'var', 'var',
'Var', 'Var',
'le', ' <= ',
'leq', ' <= ',
'ge', ' >= ',
'geq', ' >= ',
'to', ' -> ',
'htmax', 'max',
'htmin', 'min',
'htinf', 'inf',
'htsup', 'sup',
'htint', '∫',
'htsum', '∑',
'htprod', '∏',
'htlim', 'lim'
);
foreach my $mathcmd (keys %custom_math_tr) {
eval ("sub do_math_cmd_$mathcmd {\n ('$custom_math_tr{$mathcmd}', \@_);\n}");
}
sub do_math_cmd_bar {
$arg = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
("bar($arg)", @_);
}
sub do_math_cmd_overline {
$arg = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
("bar($arg)", @_);
}
sub do_math_cmd_hat {
$arg = &missing_braces unless (
(s/$next_pair_pr_rx/$arg = $2;''/eo)
||(s/$next_pair_rx/$arg = $2;''/eo));
("hat($arg)", @_);
}
# Inspired from math.pl
sub do_math_cmd_sqrt {
local($_) = @_;
local($n) = &get_next_optional_argument;
local($surd) = &get_next_token();
$n ? ("($surd)<SUP>1/$n</SUP>", $_) : ("($surd)<SUP>1/2</SUP>", $_);
}
sub do_env_hide {
"";
}
sub do_env_detailed {
"";
}
sub do_env_vcode {
# Comes from alltt.perl
local ($_) = @_;
local($closures,$reopens,$alltt_start,$alltt_end,@open_block_tags);
if ($HTML_VERSION > 3.0) {
if ($USING_STYLES) {
$env_id .= ' CLASS="vcode"' unless ($env_id =~/CLASS=/);
$env_style{'vcode'} = " " unless ($env_style{'vcode'});
}
$alltt_start = "\n<DIV$env_id ALIGN=\"LEFT\">\n";
$alltt_end = "\n</DIV>\n";
$env_id = '';
} else {
$alltt_start = "<P ALIGN=\"LEFT\">";
$alltt_end = "</P>";
}
# get the tag-strings for all open tags
local(@keep_open_tags) = @$open_tags_R;
($closures,$reopens) = &preserve_open_tags() if (@$open_tags_R);
# get the tags for text-level tags only
$open_tags_R = [ @keep_open_tags ];
local($local_closures, $local_reopens);
($local_closures, $local_reopens,@open_block_tags) = &preserve_open_block_tags
if (@$open_tags_R);
$open_tags_R = [ @open_block_tags ];
do {
local($open_tags_R) = [ @open_block_tags ];
local(@save_open_tags) = ();
# preserve the possibility for hiding
s/\\(begin|end)$O(\d+)${C}hide$O\2$C/<$1_hide>/go;
# This will prevent braces from being interpreted as
# arguments, allowing us to display them.
# This thing comes from latex2html main script, sub
# revert_to_raw_tex.
while (s/$O\s*\d+\s*$C/\{/o) { s/$&/\}/;}
while (s/$O\s*\d+\s*$C/\{/o) { s/$&/\}/;} #repeat this.
# The same for processed markers ...
while ( s/$OP\s*\d+\s*$CP/\{/o ) { s/$&/\}/; }
while ( s/$OP\s*\d+\s*$CP/\{/o ) { s/$&/\}/;} #repeat this.
# Environments have to be ignored here.
s/\\(begin|end)//g;
# Some commands have {} has argument, remove that.
s/(\\(?:[a-zA-Z]+|[^a-zA-Z])\s*)\{\}/$1/g;
local($cnt) = ++$global{'max_id'};
# put back the hide environments.
s/<(begin|end)_hide>/\\$1$O$cnt${C}hide$O$cnt$C/g;
$cnt = ++$global{'max_id'};
# This comes from alltt
$_ = join('',"$O$cnt$C\\tt$O", ++$global{'max_id'}, $C
, $_ , $O, $global{'max_id'}, "$C$O$cnt$C");
$_ = &translate_environments($_);
$_ = &translate_commands($_) if (/\\/);
# preserve space-runs, using
while (s/(\S) ( +)/$1$2;SPMnbsp;/g){};
s/(<BR>) /$1;SPMnbsp;/g;
#RRM: using <PRE> tags doesn't allow images, etc.
# $_ = &revert_to_raw_tex($_);
# &mark_string; # ???
# s/\\([{}])/$1/g; # ???
# s/<\/?\w+>//g; # no nested tags allowed
# join('', $closures,"<PRE$env_id>$_</PRE>", $reopens);
# s/<P>//g;
# join('', $closures,"<PRE$env_id>", $_, &balance_tags(), '</PRE>', $reopens);
$_ = join('', $closures, $alltt_start , $local_reopens
, $_
, &balance_tags() #, $local_closures
, $alltt_end, $reopens);
undef $open_tags_R; undef @save_open_tags;
};
$open_tags_R = [ @keep_open_tags ];
$_;
}
&ignore_commands ("tab\ntabb\ntabbb\nendtab\nendtabb\nendtabbb\nhrule\n"
. "cite # [] # {}\n"
. "eqlabel # {}\n"
. "ref # {}\n"
. "defclass # {}\n"
. "defmodule # {}");
1;
|