summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts')
-rwxr-xr-xMaster/texmf-dist/scripts/jmlr/makejmlrbook98
1 files changed, 74 insertions, 24 deletions
diff --git a/Master/texmf-dist/scripts/jmlr/makejmlrbook b/Master/texmf-dist/scripts/jmlr/makejmlrbook
index 77669bbff3a..0bef7f02730 100755
--- a/Master/texmf-dist/scripts/jmlr/makejmlrbook
+++ b/Master/texmf-dist/scripts/jmlr/makejmlrbook
@@ -2,8 +2,8 @@
# File : makejmlrbook
# Author : Nicola L C Talbot
# Date : 22nd March 2010
-# Last Modified : 24nd March 2010
-# Version : 0.1
+# Last Modified : 5th Jan 2011
+# Version : 0.2
# Description : Given the name of a document using the
# jmlrbook class file, this script runs
# pdflatex (and possibly bibtex) on the
@@ -31,7 +31,7 @@ use File::Copy;
use Cwd;
use strict;
-my $version = "0.1 (2010-03-24)";
+my $version = "0.2 (2011-01-05)";
my $eol = "\n";
my $dd = '/';
@@ -234,6 +234,7 @@ if ($html)
foreach my $import (@imports)
{
+ my $label = $import->{'label'};
my $importbase = &fname($import->{'path'}, $import->{'name'});
# Check the aux file of this article
@@ -315,18 +316,16 @@ foreach my $import (@imports)
# If html is required, we also need pdf versions of the
# individual articles.
- # Does the pdf file exist?
+ # v0.2 run latex even if pdf file exists to ensure start page
+ # number is correct.
- unless (-e "$importbase.$format")
- {
- chdir $import->{'path'}
- or die "Can't change directory to '$import->{path}': $!\n";
+ chdir $import->{'path'}
+ or die "Can't change directory to '$import->{path}': $!\n";
- &latex($import->{'name'});
+ &latexstartpage($import->{'name'}, $pagerefs{$label}->{'start'});
- chdir "$org_dir/$main_path" or
- die "Can't change directory to '$org_dir/$main_path': $!\n";
- }
+ chdir "$org_dir/$main_path" or
+ die "Can't change directory to '$org_dir/$main_path': $!\n";
# Do we need a rerun?
@@ -335,10 +334,10 @@ foreach my $import (@imports)
chdir $import->{'path'}
or die "Can't change directory to '$import->{path}': $!\n";
- &latex($import->{'name'});
+ &latexstartpage($import->{'name'}, $pagerefs{$label}->{'start'});
- chdir "$org_dir/$main_path" or
- die "Can't change directory to '$org_dir/$main_path': $!\n";
+ chdir &fname($org_dir,$main_path) or
+ die "Can't change directory to '$org_dir$dd$main_path': $!\n";
}
my $importdir = $import->{'path'};
@@ -423,6 +422,7 @@ foreach my $import (@imports)
"\\def\\input\@path{{../../$texpath/}}$eol",
"\\makeatother",$eol,
$text, $eol,
+ "\\HCode{", &htmltimestamp, "}", $eol,
"\\HCode{</div>}", $eol,
"\\end{document}",$eol;
@@ -463,17 +463,19 @@ END_CFG
}
# Go back to main directory
- chdir "$org_dir/$main_path"
- or die "Can't change directory to '$org_dir/$main_path': $!\n";
+
+ chdir "$org_dir$dd$main_path"
+ or die "Can't change directory to '$org_dir$dd$main_path': $!\n";
# Copy the html file to the html directory, but rename
# the css file to jmlr.css
- my $infile = "html-src/$importdir/".$import->{'name'}.".html";
+ my $infile = &fname("html-src",$importdir,
+ $import->{'name'}.".html");
open INFD, $infile or die "Can't open '$infile': $!\n";
- my $outfile = "html/".$import->{'name'}.".html";
+ my $outfile = &fname("html", $import->{'name'}.".html");
open OUTFD, ">$outfile" or die "Can't open '$outfile': $!\n";
@@ -495,12 +497,22 @@ END_CFG
or die "Can't copy 'html-src/$importdir/$import->{name}.css'",
" to 'html/jmlr.css': $!\n";
+ # Check the appropriate subdirectory is in html directory
+
+ my $outname = &fname('html', $importdir);
+
+ unless (-d $outname)
+ {
+ mkdir $outname
+ or die "Can't create directory '$outname': $!\n";
+ }
+
# Copy pdf file
- copy("$importbase.$format",
- "html/$import->{name}.$format")
- or die "Can't copy '$importdir/$import->{name}.$format'",
- " to 'html/$import->{name}.$format': $!\n";
+ $outname = &fname($outname, "$import->{name}.$format");
+
+ copy("$importbase.$format", $outname)
+ or die "Can't copy '$importbase.$format'", " to '$outname': $!\n";
}
}
@@ -687,7 +699,7 @@ if ($html)
my $name = $imports[$idx]->{'name'};
- print OUTFD "\\par [\\href{$name.html}{abs}] [\\href{$name.pdf}{pdf}]$eol$eol";
+ print OUTFD "\\par [\\href{$name.html}{abs}] [\\href{$name/$name.pdf}{pdf}]$eol$eol";
$idx++;
}
@@ -695,6 +707,10 @@ if ($html)
close TOC;
+ # version 0.2 added time stamp
+
+ print OUTFD "\\HCode{", &htmltimestamp, "}$eol";
+
print OUTFD "\\HCode{</div>}\\end{document}$eol";
close OUTFD;
@@ -733,6 +749,16 @@ if ($html)
close OUTFD;
close INFD;
+
+ # v0.2 new:
+ # Copy any images generated by htlatex to html/
+
+ my @imagefiles = glob(&fname('html-src', "index*.png"));
+
+ foreach my $imagefile (@imagefiles)
+ {
+ copy($imagefile, 'html');
+ }
}
# Return to original directory
@@ -756,6 +782,23 @@ sub latex{
}
}
+# v0.2 new
+sub latexstartpage{
+ my $file = shift;
+ my $page = shift;
+
+ my $code;
+
+ $code = system(join(' ', $latexapp, $latexopts,
+ "\"\\def\\startpage{$page}\\input{$file}\""));
+
+ if ($code)
+ {
+ die "**LaTeX run failed with exit code $code.**\n",
+ "Check '$file.log' for details\n";
+ }
+}
+
sub latexonline{
my $file = shift;
@@ -837,4 +880,11 @@ sub needs_rerun{
sub fname{ join($dd, @_) }
+# v0.2 new
+sub htmltimestamp{
+ my $timestamp = localtime;
+
+ return "<hr><center>Page last modified on $timestamp.</center>";
+}
+
1;