11 ($title,$body,$links) =
14 (\s
+Table\ of\ Contents
.*)
15 (References
\n\n\s
+1\
..*)/sx
);
19 print "$title\n".'-' x
length($title)."\n\n";
21 # Sort out local links.
22 # The regex might not be entirely accurate.
23 foreach (split /\n/, $links) {
24 ($index, $url) = /^\s*(\d+)\. (.+)$/;
25 if ($url !~ /file:\/\
/.*#.*$/) {
26 $links[$index] = $url;
32 foreach (split /\n(?:\s+_+\n)?\n/, $body) {
35 while ( $rest =~ /^(.*?)\[(\d+)\](.*)$/s ) {
37 if (defined $links[$2]) {
40 $footnote.=" $linkno. $links[$2]\n";
46 if ($footnote ne '') {