git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Generate ePub files of documentation.
[exim.git]
/
doc
/
doc-docbook
/
Pre-xml
diff --git
a/doc/doc-docbook/Pre-xml
b/doc/doc-docbook/Pre-xml
index 4e606dd27ec1c35ee2b9c844eab8024f0c3390a4..22b343d8db8b234b95ed28bf35b952f478ff6916 100755
(executable)
--- a/
doc/doc-docbook/Pre-xml
+++ b/
doc/doc-docbook/Pre-xml
@@
-1,7
+1,5
@@
#! /usr/bin/perl
#! /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.
# 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.
#
# newline, the space and newline are removed, because otherwise you
# get a blank line in the HTML output.
#
-# -noindex Remove the XML t
o generate a Concept and an Options index
.
+# -noindex Remove the XML t
hat generates indexes
.
# -oneindex Ditto, but add XML to generate a single index.
#
# -optbreak Insert an optional line break (zero-width space, ​) after
# -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 <entry> (i.e. not in tables). The same is
# also done within a word of four or more upper-case letters (for
# compile-time options).
# except when preceded by <entry> (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
# The function that processes non-literal, non-monospaced text
@@
-73,11
+73,18
@@
if ($ascii)
$s;
}
$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;
# The main program
$ascii = 0;
$bookinfo = 0;
+$epub = 0;
$html = 0;
$inliteral = 0;
$inliterallayout = 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; }
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; }
elsif ($arg eq "-html") { $html = 1; }
elsif ($arg eq "-noindex") { $noindex = 1; }
elsif ($arg eq "-oneindex") { $oneindex = 1; }
@@
-143,6
+151,25
@@
while (<STDIN>)
next;
}
next;
}
+ # Adjust dates to YYYY-MM-DD
+
+ if ($epub && /^\s*<date[\s>]/)
+ {
+ print;
+ while (<STDIN>)
+ {
+ 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 <literal> and which not. The latter get processed by the
# function above. Items in <literal> get quoted unless they are also in
# A line that is not in a monospaced literal block; keep track of which
# parts are in <literal> and which not. The latter get processed by the
# function above. Items in <literal> get quoted unless they are also in