Skip to content

Commit f98fa8f

Browse files
committed
Improved handling of tables, index terms and figure titles.
1 parent b3a4200 commit f98fa8f

File tree

2 files changed

+57
-44
lines changed

2 files changed

+57
-44
lines changed

bin/genbook.sh

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/bash
22

33
# First, let's convert the figures to EPS format
4-
cd graphics
5-
for i in *.tif;
6-
do tifftopnm $i |pnmtops -noturn > `basename $i .tif`.eps ;
7-
done
8-
cd ..
4+
#cd graphics
5+
#for i in *.tif;
6+
#do tifftopnm $i |pnmtops -noturn > `basename $i .tif`.eps ;
7+
#done
8+
#cd ..
99

1010
# Then, let's convert the SGML files to troff (MS macros)
1111
cat preface.sgm ch*.sgm | sed -E -f ../../../bin/sgml2troff.sed > book.ms
@@ -30,19 +30,16 @@ sed -i -e '/^$/d' book.ms
3030

3131
echo "If there were no error messages, the file book.ms is ready to be edited."
3232
echo "1) Reformat the tables before running tbl."
33-
echo "After .TS, the format of the table must be specified as l l. instead of"
34-
echo "l"
35-
echo "l"
36-
echo "without a dot. You have to place the l's on the same line and add a ."
37-
echo "If there is a .TL <some text> .PP inside the table, delete .TL and .PP"
38-
echo "and move the text (the title of the table) after the l l."
39-
echo "above the ll. place the letters cs (one c, one less s than the number of l's)"
40-
echo "2) Check the lines starting with .IX"
41-
echo "Make sure the text is after .IX and not on the line below"
33+
echo "After .TS, some tables will have their title appearing before the format"
34+
echo "lll. or similar. Move the title after the lll. line."
35+
echo "above the ll. line place the letters cs (one c, one less s than the number of l's)"
36+
echo "Remove all unwanted line breaks before table data."
37+
echo "2) Check the lines starting with .IX used for indexing"
38+
echo "Make sure all the text is after .IX and not on the line below"
4239
echo "3) run the following command"
4340
echo "tbl book.ms | groff -ms -Tps > book.ps 2> index.txt"
4441
echo "4) Check the content of index.txt to remove error messages"
4542
echo "5) examine book.ps using gv, evince or atril."
46-
echo "verify the formatting of tables, and the absence of spurious SGML tags"
47-
48-
echo "When done with the table, you can run tbl and troff."
43+
echo "Check the formatting of tables, and the absence of spurious SGML tags."
44+
echo "Run the command sort index.txt | uniq > sindex.txt"
45+
echo "The file sindex.txt can be included in book.ms to generate an index."

bin/sgml2troff.sed

+43-27
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,30 @@
22
# Edit the file to fix the tables, then use
33
# tbl out.ms | groff -ms -Tps > out.ps to generate the ps manual.
44

5+
# First, all backslashes in the SGML text must be escaped
6+
s/\\/\\\\/g
7+
# Processing the tables
8+
/<table/,/<\/table>/ s|<title[^>]*>|Tab. |g
9+
/<table/,/<\/table>/ s|</title>||g
510
/<tgroup/,/<\/tgroup>/ s|<title|<caption|g
611
/<tgroup/,/<\/tgroup>/ s|</title|</caption|g
712

813
s|<informaltable[^>]*>|.TS\ncenter,box;\n|g
9-
s|</informaltable>|\n.TE|g
14+
s|</informaltable>|\n.TE\n|g
1015
s|<table[^>]*>|.TS\ncenter,box;\n|g
11-
s|</table>|\n.TE|g
12-
s|<colspec[^>]*>|l |g
13-
s/<tgroup[^>]*>/ \n /g
16+
s|</table>|\n.TE\n|g
17+
s|<colspec[^>]*>||g
18+
s/<tgroup cols="1"[^>]*>/l.\n/g
19+
s/<tgroup cols="2"[^>]*>/ll.\n/g
20+
s/<tgroup cols="3"[^>]*>/lll.\n/g
21+
s/<tgroup cols="4"[^>]*>/llll.\n/g
22+
s/<tgroup cols="5"[^>]*>/lllll.\n/g
23+
s/<tgroup cols="6"[^>]*>/lllllll.\n/g
24+
s/<tgroup cols="7"[^>]*>/llllllll.\n/g
25+
s/<tgroup cols="8"[^>]*>/lllllllll.\n/g
1426
s|</tgroup>||g
15-
27+
/<row>/,/<\/row>/ s/<para>//g
28+
/<row>/,/<\/row>/ s|</para>||g
1629

1730

1831
s/<tbody>//g
@@ -22,12 +35,12 @@ s|</thead>||g
2235
s/<row[^>]*>//g
2336
s|</row>|\n|g
2437
s/<entry[^>*]><para>//g
25-
s|</para></entry>$|\t|g
38+
s|</para></entry>|\t|g
2639
s|</entry>|\t|g
2740
s/<entry[^>]*>//g
2841

2942
# Figure caption
30-
/<figure>/,/<\/figure>/ s|<title[^>]*>||g
43+
/<figure>/,/<\/figure>/ s|<title[^>]*>|Fig. |g
3144
/<figure>/,/<\/figure>/ s|</title>||g
3245

3346
# Sectioning
@@ -42,7 +55,7 @@ s/<entry[^>]*>//g
4255

4356
# Definition lists
4457
s/<variablelist[^>]*>//g
45-
s|</variablelist>||g
58+
s|</variablelist>|\n.LP\n|g
4659
/<varlistentry>/,/<\/varlistentry>/ s/<listitem>//g
4760
/<varlistentry>/,/<\/varlistentry>/ s|</listitem>||g
4861
/<varlistentry>/ s|</term>|"\n|g
@@ -63,20 +76,20 @@ s|</listitem>|\n|g
6376
s/<[Pp]ara[^>]*>/\n /g
6477
s|</[Pp]ara>|\n|g
6578
s/<itemizedlist[^>]*>/\n/g
66-
s|</itemizedlist>|\n|g
67-
s|<orderedlist[^>]*>|\n|g
68-
s|</orderedlist>|\n|g
79+
s|</itemizedlist>|\n.LP\n|g
80+
s|<orderedlist[^>]*>||g
81+
s|</orderedlist>|\n.LP\n|g
6982
# Sections
7083
s/<sect1[^>]*>/.NH 1 /g
7184
s/<sect2[^>]*>/.NH 2 /g
7285
s/<sect3[^>]*>/.NH 3 /g
7386
s/<sect4[^>]*>/.NH 4 /g
7487
s|</sect[1-4]>||g
7588
#Footnotes
76-
s|<note>|*\n.FS\n* |g
77-
s|</note>|.FE\n |g
78-
s|<footnote[^>]*>|*\n.FS\n* |g
79-
s|</footnote>|.FE\n |g
89+
s|<note>|\\**\n.FS\n|g
90+
s|</note>|\n.FE\n|g
91+
s|<footnote[^>]*>|\\**\n.FS\n|g
92+
s|</footnote>|\n.FE\n|g
8093

8194
s|<title[^>]*>|.TL\n |g
8295
s|</title>|\n.LP|g
@@ -143,9 +156,9 @@ s|</tip>|\n.B2|g
143156
s|></graphic>||g
144157
s|<graphic id="[^"]*"|.PSPIC "|g
145158
s|[ ]*entityref="||g
146-
147-
s/<figure>//g
148-
s|</figure>||g
159+
# Figures are placed in a Keep environment
160+
s/<figure>/\n.KS/g
161+
s|</figure>|\n.KE|g
149162
s/<sidebar>//g
150163
s|</sidebar>||g
151164
s/<![-]*Original XRef content: '//g ; s/'-->//g
@@ -161,7 +174,7 @@ s/&eacute;/\\*'e/g
161174
s/&egrave;/\\*`e/g
162175
s/&euml;/\\:e/g
163176
s/&ecirc;/\\*^e/g
164-
s/&iacute;/\\*'a/g
177+
s/&iacute;/\\*'i/g
165178
s/&igrave;/\\*`i/g
166179
s/&icirc;/\\*^i/g
167180
s/&iuml;/\\*:i/g
@@ -205,7 +218,7 @@ s/&hyphen;/\\(hy/g
205218
s/&mdash;/\\[em]/g
206219
s/&ndash;/\\[en]/g
207220
s/&bull;/\\(bu/g
208-
s/&numsp;/ n\\(de /g
221+
s/&numsp;/ n\\[Om] /g
209222
s/&lt;/</g
210223
s/&gt;/>/g
211224
s/&ge;/\\(>=/g
@@ -219,7 +232,7 @@ s/&divide;/\\(di/g
219232
# symbole &ogon; =>
220233
s/&ogon;/\\(->/g
221234
s/&iexcl;/\\[r!]/g
222-
S/&iquest;/\\[r?]/g
235+
s/&iquest;/\\[r?]/g
223236
# hyphenation character
224237
s/&shy;;/\\%/g
225238
s/&amp;/\&/g
@@ -241,11 +254,11 @@ s/<\?//g
241254
s|<indexterm>||g
242255
s|</indexterm>|\n|g
243256
s|<primary>|\n.IX |g
244-
s|</primary>| |g
245-
s|<secondary>||g
246-
s|</secondary>| |g
247-
s|<tertiary>||g
248-
s|</tertiary>| |g
257+
s|</primary>||g
258+
s|<secondary>|, |g
259+
s|</secondary>||g
260+
s|<tertiary>|, |g
261+
s|</tertiary>||g
249262
#s|<secondary>[^<]*</secondary>||g
250263
#s|<tertiary>[^<]*</tertiary>||g
251264
#Commentaires
@@ -278,6 +291,9 @@ s/\$startrange>//g
278291
# SGML tags cut at end of line...
279292
s/<$//g
280293
# Comments inside xref
281-
s/role="[A-Za-z]*"//g
294+
s/role="[A-Za-z-]*"//g
295+
296+
# Wrong opening quotation sign was used
297+
s/^'/ '/g
282298
# Don't leave empty lines
283299
/^$/ d

0 commit comments

Comments
 (0)