X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/9b3719888275859f10e5a8c6e87a92899abc0d95..c027f5ce4024679cf010976e6da8a01c8a08160e:/doc/doc-docbook/Pre-xml?ds=inline diff --git a/doc/doc-docbook/Pre-xml b/doc/doc-docbook/Pre-xml index 4e606dd27..22b343d8d 100755 --- a/doc/doc-docbook/Pre-xml +++ b/doc/doc-docbook/Pre-xml @@ -1,7 +1,5 @@ #! /usr/bin/perl -# $Cambridge: exim/doc/doc-docbook/Pre-xml,v 1.3 2006/02/01 11:01:01 ph10 Exp $ - # Script to pre-process XML input before processing it for various purposes. # Options specify which transformations are to be done. Monospaced literal # layout blocks are never touched. @@ -30,7 +28,7 @@ # newline, the space and newline are removed, because otherwise you # get a blank line in the HTML output. # -# -noindex Remove the XML to generate a Concept and an Options index. +# -noindex Remove the XML that generates indexes. # -oneindex Ditto, but add XML to generate a single index. # # -optbreak Insert an optional line break (zero-width space, ​) after @@ -38,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 @@ -73,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; @@ -93,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; } @@ -143,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