X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/3634fc257bd0667daef14d72005cd87c735bbb24..c027f5ce4024679cf010976e6da8a01c8a08160e:/doc/doc-docbook/Pre-xml?ds=inline diff --git a/doc/doc-docbook/Pre-xml b/doc/doc-docbook/Pre-xml index 6c017e7c8..22b343d8d 100755 --- a/doc/doc-docbook/Pre-xml +++ b/doc/doc-docbook/Pre-xml @@ -36,7 +36,9 @@ # except when preceded by (i.e. not in tables). The same is # also done within a word of four or more upper-case letters (for # compile-time options). - +# +# -epub Convert date formats to comply with epub specification +# # The function that processes non-literal, non-monospaced text @@ -71,11 +73,18 @@ if ($ascii) $s; } +# Mapping needed for epub + +my %months = ( + jan => '01', feb => '02', mar => '03', apr => '04', may => '05', jun => '06', + jul => '07', aug => '08', sep => '09', oct => '10', nov => '11', dec => '12', +); # The main program $ascii = 0; $bookinfo = 0; +$epub = 0; $html = 0; $inliteral = 0; $inliterallayout = 0; @@ -91,6 +100,7 @@ foreach $arg (@ARGV) if ($arg eq "-fi") { $ligatures = 1; } elsif ($arg eq "-ascii") { $ascii = 1; } elsif ($arg eq "-bookinfo") { $bookinfo = 1; } + elsif ($arg eq "-epub") { $epub = 1; } elsif ($arg eq "-html") { $html = 1; } elsif ($arg eq "-noindex") { $noindex = 1; } elsif ($arg eq "-oneindex") { $oneindex = 1; } @@ -141,6 +151,25 @@ while () next; } + # Adjust dates to YYYY-MM-DD + + if ($epub && /^\s*]/) + { + print; + while () + { + last if /^\s*<\/date>/; + + if (/^ \s* (\d{1,2}) \s+ ([a-zA-Z]{3}) \s+ (\d{4})/x) + { + die "Unknown month '$2'\n" unless exists $months{lc $2}; + my $month = $months{lc $2}; + s//$3-$month-$1/; + } + print; + } + } + # A line that is not in a monospaced literal block; keep track of which # parts are in and which not. The latter get processed by the # function above. Items in get quoted unless they are also in