2c853f8a4807dd72da9d3e7645bd6013e06260e4
[platform/upstream/groff.git] / doc / fixinfo.sh
1 #! /bin/sh
2 #
3 # Fix a problem with HTML output produced by makeinfo
4 #   (tested with versions 4.8 and 4.13).
5 #
6 # groff.texinfo uses (after macro expansion) something like
7 #
8 #   @deffn ...
9 #   @XXindex ...
10 #   @deffnx ...
11 #
12 # which has worked with earlier versions (using an undocumented feature
13 # of the implementation of @deffn and @deffnx).  Version 4.8 has new
14 # code for generating HTML, and the above construction produces wrong
15 # HTML output: It starts a new <blockquote> without closing it properly.
16 # The very problem is that, according to the documentation, the @deffnx
17 # must immediately follow the @deffn line, making it impossible to add
18 # entries into user-defined indices if supplied with macro wrappers around
19 # @deffn and @deffnx.
20 #
21 # Note that this script is a quick hack and tightly bound to the current
22 # groff.texinfo macro code.  Hopefully, a new texinfo version makes it
23 # unnecessary.
24
25 t=${TMPDIR-.}/gro$$.tmp
26
27 cat $1 | sed '
28 1 {
29   N
30   N
31 }
32 :b
33 $b
34 N
35 /^<blockquote>\n *<p>.*\n\n   \&mdash;/ {
36   s/^<blockquote>\n *<p>\(.*\n\)\n   \&mdash;/\1\&mdash;/
37   n
38   N
39   N
40   bb
41 }
42 $b
43 P
44 D
45 ' > $t
46 rm $1
47 mv $t $1