) {
$instream =~ s|(\$key = q/)|$1$pretag|s;
$translated_stream .= $instream;
}
close (LABELS);
eval $translated_stream;
undef $translated_stream;
} else {
require($labelfile);
}
} else {
&write_warnings(
"Could not find the external label file: $labelfile\n");
}
$_;
}
# This command is passed via the .ptr files to LaTeX2HTML.
# It helps to build the document title of a segment.
sub do_cmd_htmlhead {
local($_) = @_;
local(@tmp, $section_number, $sec_id, $hash, $align, $dummy);
($align, $dummy) = &get_next_optional_argument;
if ($align =~/(left|right|center)/i) { $align = "ALIGN=\"$1\""; }
local($curr_sec, $title);
$curr_sec = &missing_braces unless (
(s/$next_pair_pr_rx/$curr_sec = $2;''/e)
||(s/$next_pair_rx/$curr_sec = $2;''/e));
$curr_sec =~ s/\*$/star/;
$current_depth = $section_commands{$curr_sec};
$title = &missing_braces unless (
(s/$next_pair_pr_rx/$title = $2;''/e)
||(s/$next_pair_rx/$title = $2;''/e));
#JCL - use &sanitize
$hash = &sanitize($title);
# This is the LaTeX section number read from the $FILE.aux file
@tmp = split(/$;/,$encoded_section_number{$hash});
$section_number = shift(@tmp);
$section_number = "" if ($section_number eq "-1");
$title = "$section_number " . $title if $section_number;
$TITLE = $title unless ($TITLE);
# record it in encoded form, when it starts a segment
if (($SEGMENT)&&($PREAMBLE)) {
$TITLE = $title;
$encoded_section_number{$hash} = join($;, @tmp);
@tmp = @curr_sec_id;
# $tmp[$current_depth] = 0;
$toc_section_info{join(' ', @tmp)} =
"$current_depth$delim$CURRENT_FILE$delim$TITLE";
}
local($this_head) = &make_section_heading($title, "H2", $align);
local($pre,$post) = &minimize_open_tags("$this_head");
join('',$pre,$_);
}
sub do_cmd_htmlnohead {
local($_) = @_;
${AtBeginDocument_hook} .= " eval {\$_ = \"\";};"
if (($SEGMENT)&&($PREAMBLE));
$_;
}
sub do_cmd_htmladdTOClink {
local($_) = @_;
local(@tmp, $hash, $labelfile, $dummy);
($labelfile, $dummy) = &get_next_optional_argument;
local($curr_sec, $title, $hlink);
$curr_sec = &missing_braces unless (
(s/$next_pair_pr_rx/$curr_sec = $2;''/e)
||(s/$next_pair_rx/$curr_sec = $2;''/e));
$curr_sec =~ s/\*$/star/;
local($depth) = $section_commands{$curr_sec};
$title = &missing_braces unless (
(s/$next_pair_pr_rx/$title = $2;''/e)
||(s/$next_pair_rx/$title = $2;''/e));
$hlink = &missing_braces unless (
(s/$next_pair_pr_rx/$hlink = $2;''/e)
||(s/$next_pair_rx/$hlink = $2;''/e));
$hash = &sanitize($title);
# record it in encoded form
$encoded_section_number{$hash} = join($;, @tmp);
@tmp = @curr_sec_id;
$tmp[$depth] += 1;
local($cnt) = $depth;
while ($cnt < 9) { $cnt++; $tmp[$cnt] = 0;}
$toc_section_info{join(' ', @tmp)} = "$depth$delim$hlink$delim$title";
# Cannot just give the $hlink, since we cannot edit this file
# Need something else to have the link in a mini-TOC
$section_info{join(' ', @tmp)} =
"$depth$delim$hlink$delim$title$delim".'external';
return ($_) unless ($labelfile);
$labelfile .= 'labels.pl' unless ($labelfile =~ /\.pl$/);
if (-f "$labelfile") {
local($pretag) = '';
print "\nLoading label data from file: $labelfile\n";
if ($pretag) {
# code due to Alan Williams
open(LABELS, "<$labelfile");
print "\nLoading external labels from $labelfile, with prefix $pretag"
if ($VERBOSITY > 1);
local($translated_stream, $instream);
while ($instream = ) {
$instream =~ s|(\$key = q/)|$1$pretag|s;
$translated_stream .= $instream;
}
close (LABELS);
eval $translated_stream;
undef $translated_stream;
} else {
require($labelfile);
}
} else {
&write_warnings(
"Could not find the external label file: $labelfile\n");
}
$_;
}
sub do_cmd_segment {
local($_) = @_;
local($ctr, $index, $ditch);
&get_next_optional_argument;# heading alignment, ignored
$ditch = &missing_braces unless (# Ditch filename
(s/$next_pair_pr_rx//o)||(s/$next_pair_rx//o));
$ctr = &missing_braces unless (
(s/$next_pair_pr_rx/$ctr = $2;''/eo)
||(s/$next_pair_rx/$ctr = $2;''/eo));
$ditch = &missing_braces unless (# Ditch title
(s/$next_pair_pr_rx//o)||(s/$next_pair_rx//o));
# s/$next_pair_pr_rx//o;
$segment_sec_id[$index] += 1 if ($index = $section_commands{$ctr});
$SEGMENTED = 1;
$_;
}
sub do_cmd_segmentstar {
local($_) = @_;
$_ = &do_cmd_segment($_);
$_;
}
sub do_cmd_htmlbase {
local($_) = @_;
s/$next_pair_pr_rx/$BASE = &revert_to_raw_tex($2);''/e;
$_;
}
sub do_cmd_htmlmeta {
local($_) = @_;
s/$next_pair_pr_rx/$HTML_META .= join('',&revert_to_raw_tex($2),"\n");''/e;
$_;
}
sub do_cmd_bodytext {
local($_) = @_;
my $attrs;
&missing_braces unless (
(s/$next_pair_pr_rx/$attrs=$2;''/eo)
||(s/$next_pair_rx/$attrs=$2;''/eo));
$BODYTEXT = &revert_to_raw_tex($attrs);
$_;
}
sub do_cmd_htmlbody {
local($_) = @_;
local($attribs,$dum)=&get_next_optional_argument;
local($BODYattribs) = ('');
if ($dum) {
if ($attribs) {
if (!($attribs =~ /=/)) {
$BODYattribs = &parse_valuesonly($attribs,"BODY");
} else {
$BODYattribs = &parse_keyvalues($attribs,"BODY");
}
}
} else { } # default if no [...]
$BODYTEXT .= $BODYattribs;
$_;
}
sub do_cmd_internal{
local($_) = @_;
local($type, $prefix, $file, $var, $buf);
$type = "internals";
s/$optional_arg_rx/$type = $1; ''/eo;
$prefix = &missing_braces unless
((s/$next_pair_pr_rx/$prefix = $2; ''/eo)
||(s/$next_pair_rx/$prefix = $2; ''/eo));
## s/$next_pair_pr_rx/$prefix = $2; ''/eo;
$file = "${prefix}$type.pl";
unless (-f $file) {
print "\nCould not find file: $file \n";
return ($_);
}
local($dir,$nosave) = ('',1);
local($tmpdir,$rest) = ('','');
if ($MULTIPLE_FILES && $ROOTED) {
$nosave = '';
} else {
($tmpdir, $rest) = split(/\Q$dd\E/, $file, 2);
while ($rest) {
$dir .= $tmpdir . $dd;
($tmpdir, $rest) = split(/\Q$dd\E/, $rest, 2);
}
}
if (!($type =~ /(figure|table)/)) {
print "Loading segment data from $file \n" if ($DEBUG||$VERBOSITY);
require ($file);
return ($_);
}
# figure/table captions
local($after,$this) = ($_,'');
open (CAPTIONS, $file);
while () {
if (/^'/) { $this = $_ }
else { $this .= $_ }
if ($this =~ /'$/) {
eval "\$buf = ".$this;
$this = "\n";
}
}
# $buf = join('', );
if ($type =~ /figure/ ) {
print "Loading segment data from $file \n" if ($DEBUG||$VERBOSITY);
if (defined $segment_figure_captions) {
$segment_figure_captions .= (($segment_figure_captions)? "\n" : '') . $buf
} else {
$segment_figure_captions = $figure_captions
. (($figure_captions)? "\n" : '') . $buf
}
} else {
print "Loading segment data from $file \n" if ($DEBUG||$VERBOSITY);
if (defined $segment_table_captions) {
$segment_table_captions .= (($segment_table_captions)? "\n" : '') . $buf
} else {
$segment_table_captions = $table_captions
. (($table_captions)? "\n" : '') . $buf
}
}
close (CAPTIONS);
$after;
}
sub do_cmd_externalref {
local($_) = @_;
&process_ref($external_ref_mark,$external_ref_mark);
}
sub do_cmd_externalcite {
local($_) = @_;
&process_cite("external",'');
}
sub do_cmd_hyperref {
local($_) = @_;
local($text,$url,$hypopt);
local($opt, $dummy) = &get_next_optional_argument;
if ($opt =~ /hyper/) {
# emulate the \hyperref command of the hyperref package
($hypopt, $dummy) = &get_next_optional_argument;
if ($hypopt) {
$text = &missing_braces unless
((s/$next_pair_pr_rx/$text = $2; ''/eo)
||(s/$next_pair_rx/$text = $2; ''/eo));
## s/$next_pair_pr_rx/$text = $2; ''/es;
local($br_id) = ++$global{'max_id'};
$_ = join('', $OP.$br_id.$CP
, $hypopt
, $OP.$br_id.$CP , $_ );
return (
&process_ref($cross_ref_mark,$cross_ref_mark,$text));
}
$url = &missing_braces unless
((s/$next_pair_pr_rx/$url = $2; ''/eo)
||(s/$next_pair_rx/$url = $2; ''/eo));
## s/$next_pair_pr_rx/$url=$2;''/eo;
s/$next_pair_pr_rx/$url.="\#$2.";''/eo;
s/$next_pair_pr_rx/$url.= (($url=~ m|\.$|)? '':'#').$2;''/e;
}
$text = &missing_braces unless
((s/$next_pair_pr_rx/$text = $2; ''/eo)
||(s/$next_pair_rx/$text = $2; ''/eo));
## s/$next_pair_pr_rx/$text = $2; ''/es;
if ($opt =~ /hyper/) {
return( &make_href($url,$text) );
}
s/$next_pair_pr_rx//o; # Throw this away ...
s/$next_pair_pr_rx//o unless ($opt =~ /no/);
&process_ref($cross_ref_mark,$cross_ref_mark,$text);
}
sub do_cmd_hypercite {
local($_) = @_;
local($text);
local($opt, $dummy) = &get_next_optional_argument;
$opt = (($opt =~ /ext|no/) ? "external" : '' );
$text = &missing_braces unless
((s/$next_pair_pr_rx/$text = $2; ''/eo)
||(s/$next_pair_rx/$text = $2; ''/eo));
## s/$next_pair_pr_rx/$text = $2; ''/eo;
s/$next_pair_pr_rx//o; # Throw this away ...
s/$next_pair_pr_rx//o unless ($opt); # ... and this too.
&process_cite($opt, $text);
}
sub do_cmd_htmlref {
local($_) = @_;
local($text);
local($opt, $dummy) = &get_next_optional_argument;
$text = &missing_braces unless
((s/$next_pair_pr_rx/$text = $2; ''/eo)
||(s/$next_pair_rx/$text = $2; ''/eo));
## s/$next_pair_pr_rx/$text = $2; ''/eo;
&process_ref($cross_ref_mark,$cross_ref_mark,$text);
}
sub do_cmd_htmlcite {
local($_) = @_;
local($text);
local($opt, $dummy) = &get_next_optional_argument;
$opt = (($opt =~ /ext/) ? "external" : '' );
$text = &missing_braces unless
((s/$next_pair_pr_rx/$text = $2; ''/eo)
||(s/$next_pair_rx/$text = $2; ''/eo));
## s/$next_pair_pr_rx/$text = $2; ''/eo;
&process_cite($opt,$text);
}
# IGNORE the contents of this environment
sub do_env_latexonly {
"";
}
# use the contents of this environment only in images.tex
sub do_env_imagesonly {
local($_) = @_;
if ($PREAMBLE) { $preamble .= &revert_to_raw_tex($_)}
else { $latex_body .= "\n".&revert_to_raw_tex($_)}
$contents = '';
'';
}
# IGNORE the argument of this command (declaration below)
#sub do_cmd_latex {
# local($this) = &do_cmd_latexonly($_);
#}
# IGNORE the argument of this command
sub do_cmd_htmlimage {
local($_) = @_;
local($attribs);
$attribs = &missing_braces unless
((s/$next_pair_pr_rx/$attribs = $2; ''/eo)
||(s/$next_pair_rx/$attribs = $2; ''/eo));
## s/$next_pair_pr_rx/$attribs=$2;''/eo;
&write_warnings(
"\nThe command \"\\htmlimage\" is only effective inside an environment\n"
. "which may generate an image (eg \"{figure}\", \"{equation}\")\n"
. " $env$id: \\htmlimage{$attribs}");
print STDERR
"\nThe command \"\\htmlimage\" is only effective inside an environment\n"
. "which may generate an image (eg \"{figure}\", \"{equation}\")\n"
. " $env$id: \\htmlimage{$attribs}" if ($VERBOSITY > 1);
$_;
}
# IGNORE the argument of this command
sub do_cmd_htmlborder {
local($_) = @_;
&get_next_optional_argument;
s/$next_pair_pr_rx//o;
&write_warnings(
"\nThe command \"htmlborder\" is only effective inside an " .
"environment which uses a (eg \"{figure}\")\n");
print STDERR
"\nThe command \"htmlborder\" is only effective inside an " .
"environment which uses a (eg \"{figure}\")\n"
if ($VERBOSITY > 1);
$_;
}
sub do_cmd_htmladdtonavigation {
local($_) = @_;
s/$next_pair_pr_rx//o;
$CUSTOM_BUTTONS .= $2;
$_;
}
sub do_cmd_HTMLset {
local($_) = @_;
local($which,$value,$hash,$dummy);
local($hash, $dummy) = &get_next_optional_argument;
$which = &missing_braces unless (
(s/$next_pair_pr_rx/$which = $2;''/eo)
||(s/$next_pair_rx/$which = $2;''/eo));
$value = &missing_braces unless (
(s/$next_pair_pr_rx/$value = $2;''/eo)
||(s/$next_pair_rx/$value = $2;''/eo));
if ($hash) {
local($tmp) = "\%$hash";
if (eval "defined \%{$hash}") { $! = '';
# eval "\$$hash{'$which'} = \"$value\";";
${$hash}{'$which'} = $value;
print "\nHTMLset failed: $! " if ($!);
} else { print "\nhash: \%$hash not defined" }
} elsif ($which) { $! = '';
eval "\${$which} = \"$value\";";
print "\nHTMLset failed: $! " if ($!);
}
$_;
}
# this has been wrapped, so doesn't need to return anything.
sub do_cmd_HTMLsetenv { &do_cmd_HTMLset;}
&process_commands_wrap_deferred (<<_RAW_ARG_DEFERRED_CMDS_);
bodytext # {}
comment # <<\\endcomment>>
htmlonly # <<\\endhtmlonly>>
latexonly # <<\\endlatexonly>>
imagesonly # <<\\endimagesonly>>
rawhtml # <<\\endrawhtml>>
htmlhead # [] # {} # {}
htmlrule # []
htmlrulestar # []
_RAW_ARG_DEFERRED_CMDS_
&ignore_commands( <<_IGNORED_CMDS_);
comment # <<\\endcomment>>
latex # {}
latexhtml # {}
htmlonly
endhtmlonly
latexonly # <<\\endlatexonly>>
imagesonly # <<\\endimagesonly>> &do_env_imagesonly(\$args)
rawhtml # <<\\endrawhtml>> local(\$env)='rawhtml';\$_ = join('',&revert_to_raw_tex(\$args),\$_)
_IGNORED_CMDS_
1; # This must be the last line