-
Notifications
You must be signed in to change notification settings - Fork 25
/
fixup-html-file.pl
executable file
·61 lines (50 loc) · 2.48 KB
/
fixup-html-file.pl
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
#!/usr/bin/perl
# This is hackish, but I can't figure out how to modify the html output otherwise
my ($arg) = @ARGV;
while($line = <STDIN>)
{
if ($line =~ m/<a class="index-button.*title="Index"/) {
# Add extra buttons
$extra = "<a class=\"index-button button\" href=\"https://www.jirka.org/ra/\" title=\"Home\" alt=\"Book Home\"><span class=\"name\">Home</span></a>\n";
$extra .= "<a class=\"index-button button\" href=\"https://www.jirka.org/ra/realanal.pdf\" title=\"PDF\"><span class=\"name\">PDF(I)</span></a>\n";
$extra .= "<a class=\"index-button button\" href=\"https://www.jirka.org/ra/realanal2.pdf\" title=\"PDF\"><span class=\"name\">PDF(II)</span></a>\n";
##FIXME: add paperback buttons
$extra .= "<a class=\"index-button button\" href=\"https://www.amazon.com/dp/B0C9S99TKF\" title=\"Paperback\" alt=\"Buy Paperback\"><span class=\"name\">Book(I)</span></a>\n";
$extra .= "<a class=\"index-button button\" href=\"https://www.amazon.com/dp/B0C9S7P6M8\" title=\"Paperback\" alt=\"Buy Paperback\"><span class=\"name\">Book(II)</span></a>\n";
if (not ($line =~ s/<div class="searchbox"/$extra<div class="searchbox"/)) {
print STDERR "Can't add extra buttons!";
exit 1;
}
}
if ($line =~ m/<\/head>/) {
# Fast preview doesn't seem worth it and it could be confusing since it's not quite right so disable it
# Note: Doesn't really work in MathJax3, but it's probably not needed anymore
#print "<script type=\"text/x-mathjax-config\">\n";
#print " MathJax.Hub.Config({\n";
#print " \"fast-preview\": {\n";
#print " disabled: true,\n";
#print " },\n";
#print " });\n";
#print "</script>\n";
print "<style>\n";
# Not really critical, avoids flashing some LaTeX code on initial load, as external .css files get loaded slowly
print " .hidden-content { display:none; }\n";
# This is for the print PDF warning below
print " .print-pdf-warning { display:none; }\n";
print " \@media print { .print-pdf-warning { display:inline; } }\n";
print "</style>\n";
}
if ($line =~ m/<\/body>/) {
print "<span class=\"print-pdf-warning\">\n";
print " <em>For a higher quality printout use the PDF versions: <tt>https://www.jirka.org/ra/realanal.pdf</tt>";
print " or <tt>https://www.jirka.org/ra/realanal2.pdf</tt></em>\n";
print "</span>\n";
}
# no longer there
#$line =~ s/>Authored in PreTeXt</>Created with PreTeXt</;
# In case chtml is broken again
$line =~ s/^ chtml: {/ svg: {/;
$line =~ s/tex-chtml[.]js/tex-svg.js/;
#print line
print $line;
}