help-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transforming XML or other intermediate representation of Texinfo; ca


From: Patrice Dumas
Subject: Re: Transforming XML or other intermediate representation of Texinfo; category system
Date: Mon, 13 Dec 2021 17:22:56 +0100

On Sun, Dec 12, 2021 at 11:00:12PM -0800, Robert Dodier wrote:
> Hi, I hope all is well with you-all.
> 
> First of all, am I reinventing a wheel here? Is there already an
> implementation of a category system for Texinfo? There wasn't when I
> got started but that was a long time (more than 10 years) ago. I
> searched again today but didn't find anything.

There are categories in Texinfo in the @def* commands but I guess that
it does not correspond to your need as it exists since a long time.

> Assuming there isn't such a system already, I am thinking a cleaner
> way to implement it would be to generate an intermediate
> representation of Texinfo documents, do some transformations on it,
> and then generate the output (info, html, pdf).

texi2any is structured around an intermediate representation.  It reads
texinfo, though the C parser (a pure perl parser exists too) and this
generates a structured intermediate representation of Texinfo documents,
which is a perl structure.  Then the Converters convert this structure
to HTML, Info, simple text, docbook, TexinfoXML, back to Texinfo.  (And,
it is in progress, but there is also a LaTeX converter half done).  But
it cannot directly produce pdf, so it is only for formats output by
texi2any.

> Is it possible to use
> XML as an intermediate representation? I know that one can generate
> XML via --xml -- the crucial step would be to be able to input XML as
> well. Is it possible for makeinfo to read XML as input?

One way to do it would be to use util/txixml2texi.pl to output Texinfo
corresponding to the TexinfoXML generated by texi2any which would
generate Texinfo.  But it needs to be TexinfoXML and not any other
type of XML.

I think that it could be theoretically possible to parse TexinfoXML
directly into a texinfo document structure used internally by texi2any,
using code similar to code in util/txixml2texi.pl, but going through
a texinfo file produced from TexinfoXML instead looks easier to me.

> Failing that, is there any other structured intermediate
> representation (i.e., can be either output or input) of Texinfo
> documents?

The perl structure used internally by texi2any is a structured
intermediate representation.  But I do not know if it would be so
practical for you to manipulate as you need to do it in perl.

The tree is documented in the pod section of tp/Texinfo/ParserNonXS.pm
in the texinfo source, after TEXINFO TREE.
pod2man tp/Texinfo/ParserNonXS.pm | man -l -

There are tree transformations that exist in texi2any documented in
the "Other Customization Variables" node of the Texinfo manual, at
TREE_TRANSFORMATIONS.  But it would only help you the extent that
you want to manipulate the internal texinfo tree before outputting
some output that texi2any can output, such as Texinfo, HTML, or Info,
but not pdf.

It should also be possible to change the HTML output by redefining the
formatting function for @def* and maybe other formatting functions, but
then it would only be for HTML.

-- 
Pat



reply via email to

[Prev in Thread] Current Thread [Next in Thread]