🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.sgml
Article #190

sgmls to latex

#190
From: Gary Houston
Date: Sun, 16 Aug 1992 01:57
91 lines
2798 bytes
Hi,

I recently discovered sgml and installed the sgmls program. 

To get a feel for what it can do I have been playing around with a 
simple "memo" document type and trying to convert the output from 
sgmls to various other formats by text substitution with sgmlsasp. 
However I have found problems while using the attribute
facility. I would like to use a basic list type, something like:

<li type=arabic>
<it> first item
<it> second item
</li>

After parsing by sgmls this becomes:

ATYPE TOKEN ALPHA
(LI
(IT
- first item
)IT
(IT
- second item
)IT
)LI

Now, to convert this to latex I obviously need to replace the
(LI with something like \begin{enumerate}, the (IT with \item,
and the )LI with \end{enumerate}. 

This does not seem to be possible with sgmlsasp as it stands:
the treatment of attributes is too primitive. So I hacked up
a program to convert the output from sgmls to an alternative
form:

ATYPE TOKEN ALPHA
(LI
(IT
- first item
)IT
(IT
- second item
)IT
ATYPE TOKEN ALPHA
)LI

Now the attributes are listed whenever they are needed. I made
a few modifications to sgmls and sgmlsasp to handle this new
format, and set up a replacement table to convert to latex:

<li>            "\\begin{[type]}"       +
</li>           "\\end{[type]}" +
<it>            "\\item "
</it>           ""      +

and the output is:

\begin{ALPHA}
\item  first item
\item  second item
\end{ALPHA}
\end{memo}

which is pretty close to what's needed. Sed could be
used to translate \begin{ALPHA} to \begin{enumerate} and
\end{ALPHA} to \end{enumerate}.

However it would seem to be better if the asp table could
be extended to handle something like:

<li>            "\\begin{[type=ALPHA:enumerate]}"       +
</li>           "\\end{[type=ALPHA:enumerate]}" +
<it>            "\\item "
</it>           ""      +

and allow the conversions to be done automatically.

The second problem that I have found in converting to latex
need to escape the special characters, %$&_ etc. It seems to me 
that this should be done at the output stage, once again by
operating on the output from sgmls.

As a complete novice to sgml I am looking for some 
comments on whether what I am doing here is sensible.
Alternatively, if I am reinventing the wheel and 
utilities exist to perform some of the operations above please
let me know. 

Regards,
Gary Houston
Technical Details
Message-ID: <1992Aug16.015739.24861@stats.govt.nz>
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!waikato.ac.nz!comp.vuw.ac.nz!stats.govt.nz!gary

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!wupost!waikato.ac.nz!comp.vuw.ac.nz!stats.govt.nz!gary
Newsgroups: comp.text.sgml
Subject: sgmls to latex
Message-ID: <1992Aug16.015739.24861@stats.govt.nz>
From: ghouston@stats.govt.nz (Gary Houston)
Date: Sun, 16 Aug 92 01:57:39 GMT
Sender: gary@stats.govt.nz (Gary Houston)
Organization: NZ Dept of Statistics, Wellington, NZ
Lines: 94