From 8784fb72e8eee3d983d30ac46e0ec3709d4f0ab0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:17:34 +0200 Subject: Adding debian version 7.0.14-dfsg-4. Signed-off-by: Daniel Baumann --- debian/lynx-dump-postprocess | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 debian/lynx-dump-postprocess (limited to 'debian/lynx-dump-postprocess') 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=; +} +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"; + } +} -- cgit v1.2.3