texi2txt: add support for making cross-references in the document
commitb3ec1ac8f4ae24979df0be69e8d4d3f53476a0c5
authorChristophe CURIS <christophe.curis@free.fr>
Mon, 6 Apr 2015 15:58:03 +0000 (6 17:58 +0200)
committerCarlos R. Mafra <crmafra@gmail.com>
Sat, 18 Apr 2015 18:31:11 +0000 (18 19:31 +0100)
tree35c710c846fbe62ddf7be81d2a886043318875a1
parent22e62c0637ebbdcfd6bab9fb623c36bd6f31a3c8
texi2txt: add support for making cross-references in the document

The texinfo format provides 3 commands @ref, @xref and @pxref to make cross
references to existing @nodes in the document; it also provides a command
@anchor to place arbitrary targets for cross-reference.

Because these will be handy for the Installation Manual that already does
some references, this patch implements the 4 commands:

 - change the '@node' command, that did nothing, to now track potential
reference points;

 - add the '@anchor' command to register a new target for x-ref;

 - implement the 3 '@*ref' commands with similar behaviour as the texinfo
format states, with support for all arguments, generating a temporary
"@x##@" pattern for the line target;

 - generate a new file (*.xrf, a sed script) at the end with the
replacement for x-ref patterns with the correct line number, and perform
a few consistency checks;

 - during the final search-and-replace used to insert the Table of Content,
include the x-ref replacement.

The current script has some limitations:
 - because we cannot know in advance the target line number for the x-ref,
we insert it with a constant size of 5 characters to avoid breaking the
justification alignment when doing the replace;

 - there is a strict order to respect between @node and @chapter/@section,
which is needed because we have to include a line offset to get it right
when using the order given in the texinfo manual.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
script/generate-txt-from-texi.sh