SSL chap5_mj.html
Sprache: HTML
|
|
| products/Sources/formale Sprachen/GAP/pkg/gapdoc/doc/chap5_mj.html |
 |
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<title>GAP (GAPDoc) - Chapter 5: The Converters and an XML Parser</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap5" onload="jscontent()">
<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0_mj.html">Top</a> <a href="chap1_mj.html">1</a> <a href="chap2_mj.html">2</a> <a href="chap3_mj.html">3</a> <a href="chap4_mj.html">4</a> <a href="chap5_mj.html">5</a> <a href="chap6_mj.html">6</a> <a href="chap7_mj.html">7</a> <a href="chapA_mj.html">A</a> <a href="chapB_mj.html">B</a> <a href="chapC_mj.html">C</a> <a href="chapBib_mj.html">Bib</a> <a href="chapInd_mj.html">Ind</a> </div>
<div class="chlinkprevnexttop"> <a href="chap0_mj.html">[Top of Book]</a> <a href="chap0_mj.html#contents">[Contents]</a> <a href="chap4_mj.html">[Previous Chapter]</a> <a href="chap6_mj.html">[Next Chapter]</a> </div>
<p id="mathjaxlink" class="pcenter"><a href="chap5.html">[MathJax off]</a></p>
<p><a id="X845E7FDC7C082CC4" name="X845E7FDC7C082CC4"></a></p>
<div class="ChapSects"><a href="chap5_mj.html#X845E7FDC7C082CC4">5 <span class="Heading">The Converters and an XML Parser</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap5_mj.html#X7D1BB5867C13FA14">5.1 <span class="Heading">Producing Documentation from Source Files</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X826F530686F4D052">5.1-1 MakeGAPDocDoc</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap5_mj.html#X7FE2AF49838D9034">5.2 <span class="Heading">Parsing XML Documents</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X847EB8498151D443">5.2-1 ParseTreeXMLString</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X835887057D0B4DA8">5.2-2 StringXMLElement</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X786827BF793191B3">5.2-3 EntitySubstitution</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X86589C5C859ACE38">5.2-4 DisplayXMLStructure</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X7A7B223A83E38B40">5.2-5 ApplyToNodesParseTree</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X7F76D4A27C7FB946">5.2-6 GetTextXMLTree</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X8466F74C80442F7D">5.2-7 XMLElements</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X84CFF72484B19C0D">5.2-8 CheckAndCleanGapDocTree</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X84062CD67B286FF0">5.2-9 AddParagraphNumbersGapDocTree</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X78A22C58841E5D0B">5.2-10 InfoXMLParser</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X8403741C8386E7F0">5.2-11 XMLValidate</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X797F96F8876D7452">5.2-12 ValidateGAPDoc</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap5_mj.html#X8560E1A2845EC2C1">5.3 <span class="Heading">The Converters</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X85BE6DF178423EF5">5.3-1 GAPDoc2LaTeX</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X86CD0B197CD58D2A">5.3-2 GAPDoc2Text</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X7DFCE7357D6032A2">5.3-3 GAPDoc2TextPrintTextFiles</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X7EB5E86F87A09F94">5.3-4 AddPageNumbersToSix</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X7D42CFED7885BC00">5.3-5 PrintSixFile</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X7DEB37417BBD8941">5.3-6 SetGAPDocTextTheme</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X84F22EEB78845CFD">5.3-7 GAPDoc2HTML</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X84A7007778073E7A">5.3-8 GAPDoc2HTMLPrintHTMLFiles</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X788AB14383272FDB">5.3-9 <span class="Heading">Stylesheet files</span></a>
</span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X813599E982DE9B98">5.3-10 CopyHTMLStyleFiles</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X85AFD98383174BB5">5.3-11 SetGAPDocHTMLStyle</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X864A528B81C661A2">5.3-12 InfoGAPDoc</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X82AB468887ED0DBB">5.3-13 SetGapDocLanguage</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap5_mj.html#X800299827B88ABBE">5.4 <span class="Heading">Testing Manual Examples</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X8337B2BC79253B3F">5.4-1 ExtractExamples</a></span>
<span class="ContSS"><br /><span class="nocss"> </span><a href="chap5_mj.html#X781D56FC7B938DCB">5.4-2 RunExamples</a></span>
</div></div>
</div>
<h3>5 <span class="Heading">The Converters and an XML Parser</span></h3>
<p>The <strong class="pkg">GAPDoc</strong> package contains a set of programs which allow us to convert a <strong class="pkg">GAPDoc</strong> book into several output versions and to make them available to <strong class="pkg">GAP</strong>'s online help.
<p>Currently the following output formats are provided: text for browsing inside a terminal running <strong class="pkg">GAP</strong>, LaTeX with <code class="code">hyperref</code>-package for cross references via hyperlinks and HTML for reading with a Web-browser.</p>
<p><a id="X7D1BB5867C13FA14" name="X7D1BB5867C13FA14"></a></p>
<h4>5.1 <span class="Heading">Producing Documentation from Source Files</span></h4>
<p>Here we explain how to use the functions which are described in more detail in the following sections. We assume that we have the main file <code class="file">MyBook.xml</code> of a book <code class="code">"MyBook"</code> in the directory <code class="file">/my/book/path</code>. This contains <code class="code"><#Include ...></code>-statements as explained in Chapter <a href="chap4_mj.html#X7A3355C07F57C280"><span class="RefLink">4</span></a>. These refer to some other files as well as pieces of text which are found in the comments of some <strong class="pkg">GAP</strong> source files <code class="file">../lib/a.gd</code> and <code class="file">../lib/b.gi</code> (relative to the path above). A BibTeX database <code class="file">MyBook.bib</code> for the citations is also in the directory given above. We want to produce a text-, <code class="code">pdf-</code> and HTML-version of the document. (A LaTeX version of the manual is produced, so it is also easy to compile <code class="code">dvi</code>-, and postscript-versions.)</p>
<p>All the commands shown in this Section are collected in the single function <code class="func">MakeGAPDocDoc</code> (<a href="chap5_mj.html#X826F530686F4D052"><span class="RefLink">5.1-1</span></a>).</p>
<p>First we construct the complete XML-document as a string with <code class="func">ComposedDocument</code> (<a href="chap4_mj.html#X857D77557D12559D"><span class="RefLink">4.2-1</span></a>). This interprets recursively the <code class="code"><#Include ...></code>-statements.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">path := Directory("/my/book/path");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">main := "MyBook.xml";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">files := ["../lib/a.gd", "../lib/b.gi"];;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">bookname := "MyBook";;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">doc := ComposedDocument("GAPDoc", path, main, files, true);;</span>
</pre></div>
<p>Now <code class="code">doc</code> is a list with two entries, the first is a string containing the XML-document, the second gives information from which files and locations which part of the document was collected. This is useful in the next step, if there are any errors in the document.</p>
<p>Next we parse the document and store its structure in a tree-like data structure. The commands for this are <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) and <code class="func">CheckAndCleanGapDocTree</code> (<a href="chap5_mj.html#X84CFF72484B19C0D"><span class="RefLink">5.2-8</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">r := ParseTreeXMLString(doc[1], doc[2]);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">CheckAndCleanGapDocTree(r);</span>
true
</pre></div>
<p>We start to produce a text version of the manual, which can be read in a terminal (window). The command is <code class="func">GAPDoc2Text</code> (<a href="chap5_mj.html#X86CD0B197CD58D2A"><span class="RefLink">5.3-2</span></a>). This produces a record with the actual text and some additional information. The text can be written chapter-wise into files with <code class="func">GAPDoc2TextPrintTextFiles</code> (<a href="chap5_mj.html#X7DFCE7357D6032A2"><span class="RefLink">5.3-3</span></a>). The names of these files are <code class="file">chap0.txt</code>, <code class="file">chap1.txt</code> and so on. The text contains some markup using ANSI escape sequences. This markup is substituted by the <strong class="pkg">GAP</strong> help system (user configurable) to show the text with colors and other attributes. For the bibliography we have to tell <code class="func">GAPDoc2Text</code> (<a href="chap5_mj.html#X86CD0B197CD58D2A"><span class="RefLink">5.3-2</span></a>) the location of the BibTeX database by specifying a <code class="code">path</code> as second argument.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">t := GAPDoc2Text(r, path);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GAPDoc2TextPrintTextFiles(t, path);</span>
</pre></div>
<p>This command constructs all parts of the document including table of contents, bibliography and index. The functions <code class="func">FormatParagraph</code> (<a href="chap6_mj.html#X812058CE7C8E9022"><span class="RefLink">6.1-4</span></a>) for formatting text paragraphs and <code class="func">ParseBibFiles</code> (<a href="chap7_mj.html#X82555C307FDC1817"><span class="RefLink">7.1-1</span></a>) for reading BibTeX files with <strong class="pkg">GAP</strong> may be of independent interest.</p>
<p>With the text version we have also produced the information which is used for searching with <strong class="pkg">GAP</strong>'s online help. Also, labels are produced which can be used by links in the HTML- and pdf-versions of the manual.
<p>Next we produce a LaTeX version of the document. <code class="func">GAPDoc2LaTeX</code> (<a href="chap5_mj.html#X85BE6DF178423EF5"><span class="RefLink">5.3-1</span></a>) returns a string containing the LaTeX source. The utility function <code class="func">FileString</code> (<a href="chap6_mj.html#X7E14D32181FBC3C3"><span class="RefLink">6.3-5</span></a>) writes the content of a string to a file, we choose <code class="file">MyBook.tex</code>.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">l := GAPDoc2LaTeX(r);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">FileString(Filename(path, Concatenation(bookname, ".tex")), l);</span>
</pre></div>
<p>Assuming that you have a sufficiently good installation of TeX available (see <code class="func">GAPDoc2LaTeX</code> (<a href="chap5_mj.html#X85BE6DF178423EF5"><span class="RefLink">5.3-1</span></a>) for details) this can be processed with a series of commands like in the following example.</p>
<div class="example"><pre>
cd /my/book/path
pdflatex MyBook
bibtex MyBook
pdflatex MyBook
makeindex MyBook
pdflatex MyBook
mv MyBook.pdf manual.pdf
</pre></div>
<p>After this we have a <code class="code">pdf</code>-version of the document in the file <code class="file">manual.pdf</code>. It contains hyperlink information which can be used with appropriate browsers for convenient reading of the document on screen (e.g., <code class="code">xpdf</code> is nice because it allows remote calls to display named locations of the document). Of course, we could also use other commands like <code class="code">latex</code> or <code class="code">dvips</code> to process the LaTeX source file. Furthermore we have produced a file <code class="file">MyBook.pnr</code> which is <strong class="pkg">GAP</strong>-readable and contains the page number information for each (sub-)section of the document.</p>
<p>We can add this page number information to the indexing information collected by the text converter and then print a <code class="file">manual.six</code> file which is read by <strong class="pkg">GAP</strong> when the manual is loaded. This is done with <code class="func">AddPageNumbersToSix</code> (<a href="chap5_mj.html#X7EB5E86F87A09F94"><span class="RefLink">5.3-4</span></a>) and <code class="func">PrintSixFile</code> (<a href="chap5_mj.html#X7D42CFED7885BC00"><span class="RefLink">5.3-5</span></a>).</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">AddPageNumbersToSix(r, Filename(path, "MyBook.pnr"));</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">PrintSixFile(Filename(path, "manual.six"), r, bookname);</span>
</pre></div>
<p>Finally we produce an HTML-version of the document and write it (chapter-wise) into files <code class="file">chap0.html</code>, <code class="file">chap1.html</code> and so on. They can be read with any Web-browser. The commands are <code class="func">GAPDoc2HTML</code> (<a href="chap5_mj.html#X84F22EEB78845CFD"><span class="RefLink">5.3-7</span></a>) and <code class="func">GAPDoc2HTMLPrintHTMLFiles</code> (<a href="chap5_mj.html#X84A7007778073E7A"><span class="RefLink">5.3-8</span></a>). We also add a link from <code class="file">manual.html</code> to <code class="file">chap0.html</code>. You probably want to copy stylesheet files into the same directory, see <a href="chap5_mj.html#X788AB14383272FDB"><span class="RefLink">5.3-9</span></a> for more details. The argument <code class="code">path</code> of <code class="func">GAPDoc2HTML</code> (<a href="chap5_mj.html#X84F22EEB78845CFD"><span class="RefLink">5.3-7</span></a>) specifies the directory containing the BibTeX database files.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">h := GAPDoc2HTML(r, path);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">GAPDoc2HTMLPrintHTMLFiles(h, path);</span>
</pre></div>
<p><a id="X826F530686F4D052" name="X826F530686F4D052"></a></p>
<h5>5.1-1 MakeGAPDocDoc</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ MakeGAPDocDoc</code>( <var class="Arg">path</var>, <var class="Arg">main</var>, <var class="Arg">files</var>, <var class="Arg">bookname</var>[, <var class="Arg">gaproot</var>][, <var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function collects all the commands for producing a text-, <code class="code">pdf</code>- and HTML-version of a <strong class="pkg">GAPDoc</strong> document as described in Section <a href="chap5_mj.html#X7D1BB5867C13FA14"><span class="RefLink">5.1</span></a>. It checks the <code class="code">.log</code> file from the call of <code class="code">pdflatex</code> and reports if there are errors, warnings or overfull boxes.</p>
<p><em>Note:</em> If this function works for you depends on your operating system and installed software. It will probably work on most <code class="code">UNIX</code> systems with a standard LaTeX installation. If the function doesn't work for you look at the source code and adjust it to your system.
<p>Here <var class="Arg">path</var> must be the directory (as string or directory object) containing the main file <var class="Arg">main</var> of the document (given with or without the <code class="code">.xml</code> extension. The argument <var class="Arg">files</var> is a list of (probably source code) files relative to <var class="Arg">path</var> which contain pieces of documentation which must be included in the document, see Chapter <a href="chap4_mj.html#X7A3355C07F57C280"><span class="RefLink">4</span></a>. And <var class="Arg">bookname</var> is the name of the book used by <strong class="pkg">GAP</strong>'s online help. The optional argument gaproot must be a string which gives the relative path from path to the main GAP root directory. If this is given, the HTML files are produced with relative paths to external books.
<p>If the string <code class="code">"nopdf"</code> is given as optional argument then <code class="func">MakeGAPDocDoc</code> will not produce a <code class="code">pdf</code>-version of the help book (the source <code class="code">.tex</code>-file is generated). Consequently, the index for the help system will not contain page numbers for the <code class="code">pdf</code>-version. This variant of <code class="func">MakeGAPDocDoc</code> should work independently of the operating system because no external programs are called. It is recommended that distributed manuals contain the <code class="code">pdf</code>-version.</p>
<p><code class="func">MakeGAPDocDoc</code> can be called with additional arguments <code class="code">"MathJax"</code>, <code class="code">"Tth"</code> and/or <code class="code">"MathML"</code>. If these are given additional variants of the HTML conversion are called, see <code class="func">GAPDoc2HTML</code> (<a href="chap5_mj.html#X84F22EEB78845CFD"><span class="RefLink">5.3-7</span></a>) for details.</p>
<p>It is possible to use <strong class="pkg">GAPDoc</strong> with other languages than English, see <code class="func">SetGapDocLanguage</code> (<a href="chap5_mj.html#X82AB468887ED0DBB"><span class="RefLink">5.3-13</span></a>) for more details.</p>
<p><a id="X7FE2AF49838D9034" name="X7FE2AF49838D9034"></a></p>
<h4>5.2 <span class="Heading">Parsing XML Documents</span></h4>
<p>Arbitrary well-formed XML documents can be parsed and browsed by the following functions. A proper validation can be done with an external program, see <code class="func">XMLValidate</code> (<a href="chap5_mj.html#X8403741C8386E7F0"><span class="RefLink">5.2-11</span></a>) below.</p>
<p><a id="X847EB8498151D443" name="X847EB8498151D443"></a></p>
<h5>5.2-1 ParseTreeXMLString</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ParseTreeXMLString</code>( <var class="Arg">str</var>[, <var class="Arg">srcinfo</var>][, <var class="Arg">entitydict</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ParseTreeXMLFile</code>( <var class="Arg">fname</var>[, <var class="Arg">entitydict</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a record which is root of a tree structure</p>
<p>The first function parses an XML-document stored in string <var class="Arg">str</var> and returns the document in form of a tree.</p>
<p>The optional argument <var class="Arg">srcinfo</var> must have the same format as in <code class="func">OriginalPositionDocument</code> (<a href="chap4_mj.html#X86D1141E7EDCAAC8"><span class="RefLink">4.2-2</span></a>). If it is given then error messages refer to the original source of the text with the problem.</p>
<p>With the optional argument <var class="Arg">entitydict</var> named entities can be given to the parser, for example entities which are defined in the <code class="code">.dtd</code>-file (which is not read by this parser). The standard XML-entities do not need to be provided, and for <strong class="pkg">GAPDoc</strong> documents the entity definitions from <code class="code">gapdoc.dtd</code> are automatically provided. Entities in the document's <!DOCTYPE declaration are parsed and also need not to be provided here. The argument entitydict must be a record where each component name is an entity name (without the surrounding & and ;) to which is assigned its substitution string.
<p>The second function is just a shortcut for <code class="code">ParseTreeXMLString( StringFile(</code><var class="Arg">fname</var><code class="code">), ... )</code>, see <code class="func">StringFile</code> (<a href="chap6_mj.html#X7E14D32181FBC3C3"><span class="RefLink">6.3-5</span></a>).</p>
<p>After these functions return the list of named entities which were known during the parsing can be found in the record <code class="code">ENTITYDICT</code>.</p>
<p>A node in the result tree corresponds to an XML element, or to some parsed character data. In the first case it looks as follows:</p>
<div class="example"><pre>
rec( name := "Book",
attributes := rec( Name := "EDIM" ),
content := [ ... list of nodes for content ...],
start := 312,
stop := 15610,
next := 15611 )
</pre></div>
<p>This means that <code class="code"><var class="Arg">str</var>{[312..15610]}</code> looks like <code class="code"><Book Name="EDIM"> ... content ... </Book></code>.</p>
<p>The leaves of the tree encode parsed character data as in the following example:</p>
<div class="example"><pre>
rec( name := "PCDATA",
content := "text without markup " )
</pre></div>
<p>This function checks whether the XML document is <em>well formed</em>, see <a href="chap2_mj.html#X8561F07A81CABDD6"><span class="RefLink">2.1-14</span></a> for an explanation. If an error in the XML structure is found, a break loop is entered and the text around the position where the problem starts is shown. With <code class="code">Show();</code> one can browse the original input in the <code class="func">Pager</code> (<a href="../../../doc/ref/chap2_mj.html#X7ED03E41792C3840"><span class="RefLink">Reference: Pager</span></a>), starting with the line where the error occurred. All entities are resolved when they are either entities defined in the <strong class="pkg">GAPDoc</strong> package (in particular the standard XML entities) or if their definition is included in the <code class="code"><!DOCTYPE ..></code> tag of the document.</p>
<p>Note that <code class="func">ParseTreeXMLString</code> does not parse and interpret the corresponding document type definition (the <code class="code">.dtd</code>-file given in the <code class="code"><!DOCTYPE ..></code> tag). Hence it also does not check the <em>validity</em> of the document (i.e., it is no <em>validating XML parser</em>).</p>
<p>If you are using this function to parse a <strong class="pkg">GAPDoc</strong> document you can use <code class="func">CheckAndCleanGapDocTree</code> (<a href="chap5_mj.html#X84CFF72484B19C0D"><span class="RefLink">5.2-8</span></a>) for some validation and additional checking of the document structure.</p>
<p><a id="X835887057D0B4DA8" name="X835887057D0B4DA8"></a></p>
<h5>5.2-2 StringXMLElement</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ StringXMLElement</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a list <code class="code">[string, positions]</code></p>
<p>The argument <var class="Arg">tree</var> must have a format of a node in the parse tree of an XML document as returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) (including the root node representing the full document). This function computes a pair <code class="code">[string, positions]</code> where <code class="code">string</code> contains XML code which is equivalent to the code which was parsed to get <var class="Arg">tree</var>. And <code class="code">positions</code> is a list of lists of four numbers <code class="code">[eltb, elte, contb, conte]</code>. There is one such list for each XML element occuring in <code class="code">string</code>, where <code class="code">eltb</code> and <code class="code">elte</code> are the begin and end position of this element in <code class="code">string</code> and where <code class="code">contb</code> and <code class="code">conte</code> are begin and end position of the content of this element, or both are <code class="code">0</code> if there is no content.</p>
<p>Note that parsing XML code is an irreversible task, we can only expect to get equivalent XML code from this function. But parsing the resulting <code class="code">string</code> again and applying <code class="func">StringXMLElement</code> again gives the same result. See the function <code class="func">EntitySubstitution</code> (<a href="chap5_mj.html#X786827BF793191B3"><span class="RefLink">5.2-3</span></a>) for back-substitutions of entities in the result.</p>
<p><a id="X786827BF793191B3" name="X786827BF793191B3"></a></p>
<h5>5.2-3 EntitySubstitution</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ EntitySubstitution</code>( <var class="Arg">xmlstring</var>, <var class="Arg">entities</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a string</p>
<p>The argument <var class="Arg">xmlstring</var> must be a string containing XML code or a pair <code class="code">[string, positions]</code> as returned by <code class="func">StringXMLElement</code> (<a href="chap5_mj.html#X835887057D0B4DA8"><span class="RefLink">5.2-2</span></a>). The argument <var class="Arg">entities</var> specifies entity names (without the surrounding <var class="Arg">&</var> and <code class="code">;</code>) and their substitution strings, either a list of pairs of strings or as a record with the names as components and the substitutions as values.</p>
<p>This function tries to substitute non-intersecting parts of <code class="code">string</code> by the given entities. If the <code class="code">positions</code> information is given then only parts of the document which allow a valid substitution by an entity are considered. Otherwise a simple text substitution without further check is done.</p>
<p>Note that in general the entity resolution in XML documents is a complicated and non-reversible task. But nevertheless this utility may be useful in not too complicated situations.</p>
<p><a id="X86589C5C859ACE38" name="X86589C5C859ACE38"></a></p>
<h5>5.2-4 DisplayXMLStructure</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ DisplayXMLStructure</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This utility displays the tree structure of an XML document as it is returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) (without the <code class="code">PCDATA</code> leaves).</p>
<p>Since this is usually quite long the result is shown using the <code class="func">Pager</code> (<a href="../../../doc/ref/chap2_mj.html#X7ED03E41792C3840"><span class="RefLink">Reference: Pager</span></a>).</p>
<p><a id="X7A7B223A83E38B40" name="X7A7B223A83E38B40"></a></p>
<h5>5.2-5 ApplyToNodesParseTree</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ApplyToNodesParseTree</code>( <var class="Arg">tree</var>, <var class="Arg">fun</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AddRootParseTree</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ RemoveRootParseTree</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>The function <code class="func">ApplyToNodesParseTree</code> applies a function <var class="Arg">fun</var> to all nodes of the parse tree <var class="Arg">tree</var> of an XML document returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>).</p>
<p>The function <code class="func">AddRootParseTree</code> is an application of this. It adds to all nodes a component <code class="code">.root</code> to which the top node tree <var class="Arg">tree</var> is assigned. These components can be removed afterwards with <code class="func">RemoveRootParseTree</code>.</p>
<p>Here are two more utilities which use <code class="func">ApplyToNodesParseTree</code>.</p>
<p><a id="X7F76D4A27C7FB946" name="X7F76D4A27C7FB946"></a></p>
<h5>5.2-6 GetTextXMLTree</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GetTextXMLTree</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a string</p>
<p>The argument <var class="Arg">tree</var> must be a node of a parse tree of some XML document, see <code class="func">ParseTreeXMLFile</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>). This function collects the content of this and all included elements recursively into a string.</p>
<p><a id="X8466F74C80442F7D" name="X8466F74C80442F7D"></a></p>
<h5>5.2-7 XMLElements</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ XMLElements</code>( <var class="Arg">tree</var>, <var class="Arg">eltnames</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: a list of nodes</p>
<p>The argument <var class="Arg">tree</var> must be a node of a parse tree of some XML document, see <code class="func">ParseTreeXMLFile</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>). This function returns a list of all subnodes of <var class="Arg">tree</var> (possibly including <var class="Arg">tree</var>) of elements with name given in the list of strings <var class="Arg">eltnames</var>. Use <code class="code">"PCDATA"</code> as name for leave nodes which contain the actual text of the document. As an abbreviation <var class="Arg">eltnames</var> can also be a string which is then put in a one element list.</p>
<p>And here are utilities for processing <strong class="pkg">GAPDoc</strong> XML documents.</p>
<p><a id="X84CFF72484B19C0D" name="X84CFF72484B19C0D"></a></p>
<h5>5.2-8 CheckAndCleanGapDocTree</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ CheckAndCleanGapDocTree</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: nothing</p>
<p>The argument <var class="Arg">tree</var> of this function is a parse tree from <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) of some <strong class="pkg">GAPDoc</strong> document. This function does an (incomplete) validity check of the document according to the document type declaration in <code class="file">gapdoc.dtd</code>. It also does some additional checks which cannot be described in the DTD (like checking whether chapters and sections have a heading). For elements with element content the whitespace between these elements is removed.</p>
<p>In case of an error the break loop is entered and the position of the error in the original XML document is printed. With <code class="code">Show();</code> one can browse the original input in the <code class="func">Pager</code> (<a href="../../../doc/ref/chap2_mj.html#X7ED03E41792C3840"><span class="RefLink">Reference: Pager</span></a>).</p>
<p><a id="X84062CD67B286FF0" name="X84062CD67B286FF0"></a></p>
<h5>5.2-9 AddParagraphNumbersGapDocTree</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AddParagraphNumbersGapDocTree</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: nothing</p>
<p>The argument <var class="Arg">tree</var> must be an XML tree returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) applied to a <strong class="pkg">GAPDoc</strong> document. This function adds to each node of the tree a component <code class="code">.count</code> which is of form <code class="code">[Chapter[, Section[, Subsection, Paragraph] ] ]</code>. Here the first three numbers should be the same as produced by the LaTeX version of the document. Text before the first chapter is counted as chapter <code class="code">0</code> and similarly for sections and subsections. Some elements are always considered to start a new paragraph.</p>
<p><a id="X78A22C58841E5D0B" name="X78A22C58841E5D0B"></a></p>
<h5>5.2-10 InfoXMLParser</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ InfoXMLParser</code></td><td class="tdright">( info class )</td></tr></table></div>
<p>The default level of this info class is 1. Functions like <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) are then printing some information, in particular in case of errors. You can suppress it by setting the level of <code class="func">InfoXMLParser</code> to 0. With level 2 there may be some more information for debugging purposes.</p>
<p><a id="X8403741C8386E7F0" name="X8403741C8386E7F0"></a></p>
<h5>5.2-11 XMLValidate</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ XMLValidate</code>( <var class="Arg">doc</var>, <var class="Arg">dtdpath</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: <code class="keyw">fail</code> or a record</p>
<p>The argument <var class="Arg">doc</var> must be a string which is an XML document, and <var class="Arg">dtdpath</var> is a path containing the corresponding DTD file.</p>
<p>The function returns <code class="keyw">fail</code> if the program <code class="code">xmllint</code> cannot be called.</p>
<p>Otherwise the document is validated via the external program <code class="code">xmllint</code> via the function <code class="func">IO_PipeThroughWithError</code> (<a href="../../../pkg/io/doc/chap4_mj.html#X7A9ACA3979635506"><span class="RefLink">IO: IO_PipeThroughWithError</span></a>), and its resulting record is returned.</p>
<p><a id="X797F96F8876D7452" name="X797F96F8876D7452"></a></p>
<h5>5.2-12 ValidateGAPDoc</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ValidateGAPDoc</code>( <var class="Arg">doc</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: <code class="keyw">fail</code>, <code class="keyw">true</code> or a record</p>
<p>The argument <var class="Arg">doc</var> must be a string which is a GAPDoc XML document or a pair of a string and list as returned by <code class="func">ComposedDocument</code> (<a href="chap4_mj.html#X857D77557D12559D"><span class="RefLink">4.2-1</span></a>) with argument <var class="Arg">info</var> set to <code class="keyw">true</code>.</p>
<p>The function returns <code class="keyw">fail</code> in case of a problem.</p>
<p>Otherwise the document is validated using <code class="func">XMLValidate</code> (<a href="chap5_mj.html#X8403741C8386E7F0"><span class="RefLink">5.2-11</span></a>). If the validation was successful this function returns <code class="keyw">true</code>. In the case of validation errors some information is printed and the result of <code class="func">XMLValidate</code> (<a href="chap5_mj.html#X8403741C8386E7F0"><span class="RefLink">5.2-11</span></a>) is returned.</p>
<div class="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">fn := Filename(DirectoriesPackageLibrary("gapdoc", ""), </span>
<span class="GAPprompt">></span> <span class="GAPinput"> "3k+1/3k+1.xml");;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">doc := ComposedDocument("GAPDoc", "", fn, [], true);;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">doc[1][220] := 't';;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">check := ValidateGAPDoc(doc);;</span>
ValidateGAPDoc found problems:
Line 11: parser error : Opening and ending tag mismatch
source position: /opt/gap/pkg/GAPDoc-1.6.4/3k+1/3k+1.xml, line 11
</pre></div>
<p><a id="X8560E1A2845EC2C1" name="X8560E1A2845EC2C1"></a></p>
<h4>5.3 <span class="Heading">The Converters</span></h4>
<p>Here are more details about the conversion programs for <strong class="pkg">GAPDoc</strong> XML documents.</p>
<p><a id="X85BE6DF178423EF5" name="X85BE6DF178423EF5"></a></p>
<h5>5.3-1 GAPDoc2LaTeX</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GAPDoc2LaTeX</code>( <var class="Arg">tree</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: LaTeX document as string</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SetGapDocLaTeXOptions</code>( [<var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: Nothing</p>
<p>The argument <var class="Arg">tree</var> for this function is a tree describing a <strong class="pkg">GAPDoc</strong> XML document as returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) (probably also checked with <code class="func">CheckAndCleanGapDocTree</code> (<a href="chap5_mj.html#X84CFF72484B19C0D"><span class="RefLink">5.2-8</span></a>)). The output is a string containing a version of the document which can be written to a file and processed with LaTeX or pdfLaTeX (and probably BibTeX and <code class="code">makeindex</code>).</p>
<p>The output uses the <code class="code">report</code> document class and needs the following LaTeX packages: <code class="code">amssymb</code>, <code class="code">inputenc</code>, <code class="code">makeidx</code>, <code class="code">color</code>, <code class="code">fancyvrb</code>, <code class="code">psnfss</code>, <code class="code">pslatex</code>, <code class="code">enumitem</code> and <code class="code">hyperref</code>. These are for example provided by the <strong class="pkg">texlive</strong> distribution of TeX (which in turn is used for most TeX packages of current Linux distributions); see <span class="URL"><a href="https://www.tug.org/texlive/">https://www.tug.org/texlive/</a></span>.</p>
<p>In particular, the resulting <code class="code">pdf</code>-output (and <code class="code">dvi</code>-output) contains (internal and external) hyperlinks which can be very useful for onscreen browsing of the document.</p>
<p>The LaTeX processing also produces a file with extension <code class="code">.pnr</code> which is <strong class="pkg">GAP</strong> readable and contains the page numbers for all (sub)sections of the document. This can be used by <strong class="pkg">GAP</strong>'s online help; see AddPageNumbersToSix (5.3-4). Non-ASCII characters in the GAPDoc document are translated to LaTeX input in ASCII-encoding with the help of Encode (6.2-2) and the option "LaTeX". See the documentation of Encode (6.2-2) for how to proceed if you have a character which is not handled (yet).
<p>This function works by running recursively through the document tree and calling a handler function for each <strong class="pkg">GAPDoc</strong> XML element. Many of these handler functions (usually in <code class="code">GAPDoc2LaTeXProcs.<ElementName></code>) are not difficult to understand (the greatest complications are some commands for index entries, labels or the output of page number information). So it should be easy to adjust layout details to your own taste by slight modifications of the program.</p>
<p>Former versions of <strong class="pkg">GAPDoc</strong> supported some XML processing instructions to add some extra lines to the preamble of the LaTeX document. Its use is now deprecated, use the much more flexible <code class="func">SetGapDocLaTeXOptions</code> instead: The default layout of the resulting documents can be changed with <code class="func">SetGapDocLaTeXOptions</code>. This changes parts of the header of the LaTeX file produced by <strong class="pkg">GAPDoc</strong>. You can see the header with some placeholders by <code class="code">Page(GAPDoc2LaTeXProcs.Head);</code>. The placeholders are filled with components from the record <code class="code">GAPDoc2LaTeXProcs.DefaultOptions</code>. The arguments of <code class="func">SetGapDocLaTeXOptions</code> can be records with the same structure (or parts of it) with different values. As abbreviations there are also three strings supported as arguments. These are <code class="code">"nocolor"</code> for switching all colors to black; then <code class="code">"nopslatex"</code> to use standard LaTeX fonts instead of postscript fonts; and finally <code class="code">"utf8"</code> to choose UTF-8 as input encoding for the LaTeX document.</p>
<p><a id="X86CD0B197CD58D2A" name="X86CD0B197CD58D2A"></a></p>
<h5>5.3-2 GAPDoc2Text</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GAPDoc2Text</code>( <var class="Arg">tree</var>[, <var class="Arg">bibpath</var>][, <var class="Arg">width</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: record containing text files as strings and other information</p>
<p>The argument <var class="Arg">tree</var> for this function is a tree describing a <strong class="pkg">GAPDoc</strong> XML document as returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>) (probably also checked with <code class="func">CheckAndCleanGapDocTree</code> (<a href="chap5_mj.html#X84CFF72484B19C0D"><span class="RefLink">5.2-8</span></a>)). This function produces a text version of the document which can be used with <strong class="pkg">GAP</strong>'s online help (with the "screen" viewer, see SetHelpViewer (Reference: SetHelpViewer)). It includes title page, bibliography and index. The bibliography is made from BibXMLext or BibTeX databases, see 7. Their location must be given with the argument bibpath (as string or directory object).
<p>The output is a record with one component for each chapter (with names <code class="code">"0"</code>, <code class="code">"1"</code>, ..., <code class="code">"Bib"</code> and <code class="code">"Ind"</code>). Each such component is again a record with the following components:</p>
<dl>
<dt><strong class="Mark"><code class="code">text</code></strong></dt>
<dd><p>the text of the whole chapter as a string</p>
</dd>
<dt><strong class="Mark"><code class="code">ssnr</code></strong></dt>
<dd><p>list of subsection numbers in this chapter (like <code class="code">[3, 2, 1]</code> for chapter 3, section 2, subsection 1)</p>
</dd>
<dt><strong class="Mark"><code class="code">linenr</code></strong></dt>
<dd><p>corresponding list of line numbers where the subsections start</p>
</dd>
<dt><strong class="Mark"><code class="code">len</code></strong></dt>
<dd><p>number of lines of this chapter</p>
</dd>
</dl>
<p>The result can be written into files with the command <code class="func">GAPDoc2TextPrintTextFiles</code> (<a href="chap5_mj.html#X7DFCE7357D6032A2"><span class="RefLink">5.3-3</span></a>).</p>
<p>As a side effect this function also produces the <code class="file">manual.six</code> information which is used for searching in <strong class="pkg">GAP</strong>'s online help. This is stored in tree.six and can be printed into a manual.six file with PrintSixFile (5.3-5) (preferably after producing a LaTeX version of the document as well and adding the page number information to tree.six, see GAPDoc2LaTeX (5.3-1) and AddPageNumbersToSix (5.3-4)).
<p>The text produced by this function contains some markup via ANSI escape sequences. The sequences used here are usually ignored by terminals. But the <strong class="pkg">GAP</strong> help system will substitute them by interpreted color and attribute sequences (see <code class="func">TextAttr</code> (<a href="chap6_mj.html#X785F61E77899580E"><span class="RefLink">6.1-2</span></a>)) before displaying them. There is a default markup used for this but it can also be configured by the user, see <code class="func">SetGAPDocTextTheme</code> (<a href="chap5_mj.html#X7DEB37417BBD8941"><span class="RefLink">5.3-6</span></a>). Furthermore, the text produced is in UTF-8 encoding. The encoding is also translated on the fly, if <code class="code">GAPInfo.TermEncoding</code> is set to some encoding supported by <code class="func">Encode</code> (<a href="chap6_mj.html#X818A31567EB30A39"><span class="RefLink">6.2-2</span></a>), e.g., <code class="code">"ISO-8859-1"</code> or <code class="code">"latin1"</code>.</p>
<p>With the optional argument <var class="Arg">width</var> a different length of the output text lines can be chosen. The default is 76 and all lines in the resulting text start with two spaces. This looks good on a terminal with a standard width of 80 characters and you probably don't want to use this argument.
<p><a id="X7DFCE7357D6032A2" name="X7DFCE7357D6032A2"></a></p>
<h5>5.3-3 GAPDoc2TextPrintTextFiles</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ GAPDoc2TextPrintTextFiles</code>( <var class="Arg">t</var>[, <var class="Arg">path</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: nothing</p>
<p>The first argument must be a result returned by <code class="func">GAPDoc2Text</code> (<a href="chap5_mj.html#X86CD0B197CD58D2A"><span class="RefLink">5.3-2</span></a>). The second argument is a path for the files to write, it can be given as string or directory object. The text of each chapter is written into a separate file with name <code class="file">chap0.txt</code>, <code class="file">chap1.txt</code>, ..., <code class="file">chapBib.txt</code>, and <code class="file">chapInd.txt</code>.</p>
<p>If you want to make your document accessible via the <strong class="pkg">GAP</strong> online help you must put at least these files for the text version into a directory, together with the file <code class="file">manual.six</code>, see <code class="func">PrintSixFile</code> (<a href="chap5_mj.html#X7D42CFED7885BC00"><span class="RefLink">5.3-5</span></a>). Then specify the path to the <code class="file">manual.six</code> file in the packages <code class="file">PackageInfo.g</code> file, see <a href="../../../doc/ref/chap76_mj.html#X85C8DE357EE424D8"><span class="RefLink">Reference: The PackageInfo.g File</span></a>.</p>
<p>Optionally you can add the <code class="code">dvi</code>- and <code class="code">pdf</code>-versions of the document which are produced with <code class="func">GAPDoc2LaTeX</code> (<a href="chap5_mj.html#X85BE6DF178423EF5"><span class="RefLink">5.3-1</span></a>) to this directory. The files must have the names <code class="file">manual.dvi</code> and <code class="file">manual.pdf</code>, respectively. Also you can add the files of the HTML version produced with <code class="func">GAPDoc2HTML</code> (<a href="chap5_mj.html#X84F22EEB78845CFD"><span class="RefLink">5.3-7</span></a>) to this directory, see <code class="func">GAPDoc2HTMLPrintHTMLFiles</code> (<a href="chap5_mj.html#X84A7007778073E7A"><span class="RefLink">5.3-8</span></a>). The handler functions in <strong class="pkg">GAP</strong> for this help format detect automatically which of the optional formats of a book are actually available.</p>
<p><a id="X7EB5E86F87A09F94" name="X7EB5E86F87A09F94"></a></p>
<h5>5.3-4 AddPageNumbersToSix</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ AddPageNumbersToSix</code>( <var class="Arg">tree</var>, <var class="Arg">pnrfile</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: nothing</p>
<p>Here <var class="Arg">tree</var> must be the XML tree of a <strong class="pkg">GAPDoc</strong> document, returned by <code class="func">ParseTreeXMLString</code> (<a href="chap5_mj.html#X847EB8498151D443"><span class="RefLink">5.2-1</span></a>). Running <code class="code">latex</code> on the result of <code class="code">GAPDoc2LaTeX(<var class="Arg">tree</var>)</code> produces a file <var class="Arg">pnrfile</var> (with extension <code class="code">.pnr</code>). The command <code class="code">GAPDoc2Text(<var class="Arg">tree</var>)</code> creates a component <code class="code"><var class="Arg">tree</var>.six</code> which contains all information about the document for the <strong class="pkg">GAP</strong> online help, except the page numbers in the <code class="code">.dvi, .ps, .pdf</code> versions of the document. This command adds the missing page number information to <code class="code"><var class="Arg">tree</var>.six</code>.</p>
<p><a id="X7D42CFED7885BC00" name="X7D42CFED7885BC00"></a></p>
<h5>5.3-5 PrintSixFile</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ PrintSixFile</code>( <var class="Arg">tree</var>, <var class="Arg">bookname</var>, <var class="Arg">fname</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: nothing</p>
<p>This function prints the <code class="code">.six</code> file <var class="Arg">fname</var> for a <strong class="pkg">GAPDoc</strong> document stored in <var class="Arg">tree</var> with name <var class="Arg">bookname</var>. Such a file contains all information about the book which is needed by the <strong class="pkg">GAP</strong> online help. This information must first be created by calls of <code class="func">GAPDoc2Text</code> (<a href="chap5_mj.html#X86CD0B197CD58D2A"><span class="RefLink">5.3-2</span></a>) and <code class="func">AddPageNumbersToSix</code> (<a href="chap5_mj.html#X7EB5E86F87A09F94"><span class="RefLink">5.3-4</span></a>).</p>
<p><a id="X7DEB37417BBD8941" name="X7DEB37417BBD8941"></a></p>
<h5>5.3-6 SetGAPDocTextTheme</h5>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ SetGAPDocTextTheme</code>( [<var class="Arg">optrec1</var>[, <var class="Arg">optrec2</var>], <var class="Arg">...</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<p>Returns: nothing</p>
<p>This utility function is for readers of the screen version of <strong class="pkg">GAP</strong> manuals which are generated by the < | |