diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:19:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:19:25 +0000 |
commit | 744970696db3fad9c8735bcbe54c840e1e084d76 (patch) | |
tree | 479f3208f97fc415b7dc42c25ba734bb06dc8766 /debian/lynx-dump-postprocess | |
parent | Adding upstream version 6.1.22-dfsg. (diff) | |
download | virtualbox-744970696db3fad9c8735bcbe54c840e1e084d76.tar.xz virtualbox-744970696db3fad9c8735bcbe54c840e1e084d76.zip |
Adding debian version 6.1.22-dfsg-4.debian/6.1.22-dfsg-4debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/lynx-dump-postprocess')
-rwxr-xr-x | debian/lynx-dump-postprocess | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/debian/lynx-dump-postprocess b/debian/lynx-dump-postprocess new file mode 100755 index 00000000..644e49c0 --- /dev/null +++ b/debian/lynx-dump-postprocess @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +# taken from the exim4 package + +open IN, '<&STDIN'; +#open IN, 'dump'; +{ + local $/; + $content=<IN>; +} +close IN; + +($title,$body,$links) = + ($content =~ + /^(.*)\n\s+_+\n\n + (\s+Table\ of\ Contents.*) + (References\n\n\s+1\..*)/sx); + +die unless ($title); + +print "$title\n".'-' x length($title)."\n\n"; + +# Sort out local links. +# The regex might not be entirely accurate. +foreach (split /\n/, $links) { + ($index, $url) = /^\s*(\d+)\. (.+)$/; + if ($url !~ /file:\/\/.*#.*$/) { + $links[$index] = $url; + } +} + +$linkno=0; +# Split paragraphs +foreach (split /\n(?:\s+_+\n)?\n/, $body) { + my $footnote = ''; + my $rest = $_; + while ( $rest =~ /^(.*?)\[(\d+)\](.*)$/s ) { + print $1; + if (defined $links[$2]) { + $linkno++; + print "[$linkno]"; + $footnote.=" $linkno. $links[$2]\n"; + } + $rest = $3; + } + print $rest; + print "\n\n"; + if ($footnote ne '') { + print "$footnote\n"; + } +} |