22 |
# remove comments between <html> and <head> texi2html inserts them |
# remove comments between <html> and <head> texi2html inserts them |
23 |
# there and swish can't find document title then (libxml or swish bug?) |
# there and swish can't find document title then (libxml or swish bug?) |
24 |
while ($contents =~ s/(<html>.*)<!--.*?-->(.*<head>)/$1$2/msi) { }; |
while ($contents =~ s/(<html>.*)<!--.*?-->(.*<head>)/$1$2/msi) { }; |
25 |
|
|
26 |
|
# remove empty lines before/after <html> |
27 |
|
$contents =~ s/^\s+(<html>)/$1/is; |
28 |
|
$contents =~ s/(<\/html>)\s+$/$1/is; |
29 |
|
# remove cr |
30 |
|
$contents =~ s/\r//gs; |
31 |
|
|
32 |
|
# remove SQL Magazine header and footer |
33 |
|
$contents =~ s/<!-- begin topnav area -->.+?<!-- end topnav area -->/<\/table>/is; |
34 |
|
$contents =~ s/<!--Begin Footer-->.+?<\/table>/<\/table>/is; |
35 |
|
|
36 |
# remote TPJ left column |
# remote TPJ left column |
37 |
if ($contents =~ s,<!-- BEGIN LEFT SIDE BAR CELL -->.+?<!-- END LEFT SIDE BAR CELL -->,,isg) { |
if ($contents =~ s,<!-- BEGIN LEFT SIDE BAR CELL -->.+?<!-- END LEFT SIDE BAR CELL -->,,isg) { |
99 |
|
|
100 |
if ($contents =~ s,<title>(.*)</title>,<title>$new_title</title>,is) { |
if ($contents =~ s,<title>(.*)</title>,<title>$new_title</title>,is) { |
101 |
print STDERR "replace title '$1' with '$new_title'\n" if ($verbose); |
print STDERR "replace title '$1' with '$new_title'\n" if ($verbose); |
102 |
} elsif ( |
} elsif ($contents =~ s,(<head>),$1<title>$new_title</title>,is) { |
103 |
# try to insert after <head>, <html> or at top |
print STDERR "adding title '$new_title' after <head>\n" if ($verbose); |
104 |
$contents =~ s,(<head>),$1<title>$new_title</title>,is || |
|
105 |
$contents =~ s,(<html>),$1<title>$new_title</title>,is || |
} elsif ($contents =~ s,(<html>),$1<head><title>$new_title</title></head>,is) { |
106 |
$contents =~ s,^,<title>$new_title</title>, ) { |
print STDERR "adding title '$new_title' after <html>\n" if ($verbose); |
107 |
|
|
108 |
|
} elsif ($contents =~ s,^,<title>$new_title</title>,) { |
109 |
print STDERR "adding new title '$new_title'\n" if ($verbose); |
print STDERR "adding new title '$new_title'\n" if ($verbose); |
110 |
|
} else { |
111 |
|
print STDERR "WARNING: filter couldn't add new title '$new_title' anywhere!"; |
112 |
} |
} |
113 |
|
|
114 |
return $contents; |
return $contents; |