summaryrefslogtreecommitdiffstats
path: root/debian/lynx-dump-postprocess
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:47:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 00:47:27 +0000
commitd5eb37dd4a5a433c40c3c1e7ead424add62663f8 (patch)
tree6a18289cb463d11227d1fa4c990548e50a09d917 /debian/lynx-dump-postprocess
parentAdding upstream version 4.92. (diff)
downloadexim4-d5eb37dd4a5a433c40c3c1e7ead424add62663f8.tar.xz
exim4-d5eb37dd4a5a433c40c3c1e7ead424add62663f8.zip
Adding debian version 4.92-8+deb10u6.debian/4.92-8+deb10u6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/lynx-dump-postprocess')
-rwxr-xr-xdebian/lynx-dump-postprocess49
1 files changed, 49 insertions, 0 deletions
diff --git a/debian/lynx-dump-postprocess b/debian/lynx-dump-postprocess
new file mode 100755
index 0000000..e1ebbf9
--- /dev/null
+++ b/debian/lynx-dump-postprocess
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+
+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";
+ }
+}