Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X5 [33X[0;0YThe Converters and an XML Parser[133X[101X23[33X[0;0YThe [5XGAPDoc[105X package contains a set of programs which allow us to convert a4[5XGAPDoc[105X book into several output versions and to make them available to [5XGAP[105X's5online help.[133X67[33X[0;0YCurrently the following output formats are provided: text for browsing8inside a terminal running [5XGAP[105X, LaTeX with [10Xhyperref[110X-package for cross9references via hyperlinks and HTML for reading with a Web-browser.[133X101112[1X5.1 [33X[0;0YProducing Documentation from Source Files[133X[101X1314[33X[0;0YHere we explain how to use the functions which are described in more detail15in the following sections. We assume that we have the main file [11XMyBook.xml[111X16of a book [10X"MyBook"[110X in the directory [11X/my/book/path[111X. This contains [10X<#Include17...>[110X-statements as explained in Chapter [14X4[114X. These refer to some other files18as well as pieces of text which are found in the comments of some [5XGAP[105X source19files [11X../lib/a.gd[111X and [11X../lib/b.gi[111X (relative to the path above). A BibTeX20database [11XMyBook.bib[111X for the citations is also in the directory given above.21We want to produce a text-, [10Xpdf-[110X and HTML-version of the document. (A LaTeX22version of the manual is produced, so it is also easy to compile [10Xdvi[110X-, and23postscript-versions.)[133X2425[33X[0;0YAll the commands shown in this Section are collected in the single function26[2XMakeGAPDocDoc[102X ([14X5.1-1[114X).[133X2728[33X[0;0YFirst we construct the complete XML-document as a string with29[2XComposedDocument[102X ([14X4.2-1[114X). This interprets recursively the [10X<#Include30...>[110X-statements.[133X3132[4X[32X Example [32X[104X33[4X[25Xgap>[125X [27Xpath := Directory("/my/book/path");;[127X[104X34[4X[25Xgap>[125X [27Xmain := "MyBook.xml";;[127X[104X35[4X[25Xgap>[125X [27Xfiles := ["../lib/a.gd", "../lib/b.gi"];;[127X[104X36[4X[25Xgap>[125X [27Xbookname := "MyBook";;[127X[104X37[4X[25Xgap>[125X [27Xdoc := ComposedDocument("GAPDoc", path, main, files, true);;[127X[104X38[4X[32X[104X3940[33X[0;0YNow [10Xdoc[110X is a list with two entries, the first is a string containing the41XML-document, the second gives information from which files and locations42which part of the document was collected. This is useful in the next step,43if there are any errors in the document.[133X4445[33X[0;0YNext we parse the document and store its structure in a tree-like data46structure. The commands for this are [2XParseTreeXMLString[102X ([14X5.2-1[114X) and47[2XCheckAndCleanGapDocTree[102X ([14X5.2-8[114X).[133X4849[4X[32X Example [32X[104X50[4X[25Xgap>[125X [27Xr := ParseTreeXMLString(doc[1], doc[2]);;[127X[104X51[4X[25Xgap>[125X [27XCheckAndCleanGapDocTree(r);[127X[104X52[4X[28Xtrue[128X[104X53[4X[32X[104X5455[33X[0;0YWe start to produce a text version of the manual, which can be read in a56terminal (window). The command is [2XGAPDoc2Text[102X ([14X5.3-2[114X). This produces a57record with the actual text and some additional information. The text can be58written chapter-wise into files with [2XGAPDoc2TextPrintTextFiles[102X ([14X5.3-3[114X). The59names of these files are [11Xchap0.txt[111X, [11Xchap1.txt[111X and so on. The text contains60some markup using ANSI escape sequences. This markup is substituted by the61[5XGAP[105X help system (user configurable) to show the text with colors and other62attributes. For the bibliography we have to tell [2XGAPDoc2Text[102X ([14X5.3-2[114X) the63location of the BibTeX database by specifying a [10Xpath[110X as second argument.[133X6465[4X[32X Example [32X[104X66[4X[25Xgap>[125X [27Xt := GAPDoc2Text(r, path);;[127X[104X67[4X[25Xgap>[125X [27XGAPDoc2TextPrintTextFiles(t, path);[127X[104X68[4X[32X[104X6970[33X[0;0YThis command constructs all parts of the document including table of71contents, bibliography and index. The functions [2XFormatParagraph[102X ([14X6.1-4[114X) for72formatting text paragraphs and [2XParseBibFiles[102X ([14X7.1-1[114X) for reading BibTeX73files with [5XGAP[105X may be of independent interest.[133X7475[33X[0;0YWith the text version we have also produced the information which is used76for searching with [5XGAP[105X's online help. Also, labels are produced which can be77used by links in the HTML- and [10Xpdf[110X-versions of the manual.[133X7879[33X[0;0YNext we produce a LaTeX version of the document. [2XGAPDoc2LaTeX[102X ([14X5.3-1[114X)80returns a string containing the LaTeX source. The utility function81[2XFileString[102X ([14X6.3-5[114X) writes the content of a string to a file, we choose82[11XMyBook.tex[111X.[133X8384[4X[32X Example [32X[104X85[4X[25Xgap>[125X [27Xl := GAPDoc2LaTeX(r);;[127X[104X86[4X[25Xgap>[125X [27XFileString(Filename(path, Concatenation(bookname, ".tex")), l);[127X[104X87[4X[32X[104X8889[33X[0;0YAssuming that you have a sufficiently good installation of TeX available90(see [2XGAPDoc2LaTeX[102X ([14X5.3-1[114X) for details) this can be processed with a series91of commands like in the following example.[133X9293[4X[32X Example [32X[104X94[4X[28Xcd /my/book/path[128X[104X95[4X[28Xpdflatex MyBook[128X[104X96[4X[28Xbibtex MyBook[128X[104X97[4X[28Xpdflatex MyBook[128X[104X98[4X[28Xmakeindex MyBook[128X[104X99[4X[28Xpdflatex MyBook[128X[104X100[4X[28Xmv MyBook.pdf manual.pdf[128X[104X101[4X[32X[104X102103[33X[0;0YAfter this we have a [10Xpdf[110X-version of the document in the file [11Xmanual.pdf[111X. It104contains hyperlink information which can be used with appropriate browsers105for convenient reading of the document on screen (e.g., [10Xxpdf[110X is nice because106it allows remote calls to display named locations of the document). Of107course, we could also use other commands like [10Xlatex[110X or [10Xdvips[110X to process the108LaTeX source file. Furthermore we have produced a file [11XMyBook.pnr[111X which is109[5XGAP[105X-readable and contains the page number information for each (sub-)section110of the document.[133X111112[33X[0;0YWe can add this page number information to the indexing information113collected by the text converter and then print a [11Xmanual.six[111X file which is114read by [5XGAP[105X when the manual is loaded. This is done with [2XAddPageNumbersToSix[102X115([14X5.3-4[114X) and [2XPrintSixFile[102X ([14X5.3-5[114X).[133X116117[4X[32X Example [32X[104X118[4X[25Xgap>[125X [27XAddPageNumbersToSix(r, Filename(path, "MyBook.pnr"));[127X[104X119[4X[25Xgap>[125X [27XPrintSixFile(Filename(path, "manual.six"), r, bookname);[127X[104X120[4X[32X[104X121122[33X[0;0YFinally we produce an HTML-version of the document and write it123(chapter-wise) into files [11Xchap0.html[111X, [11Xchap1.html[111X and so on. They can be read124with any Web-browser. The commands are [2XGAPDoc2HTML[102X ([14X5.3-7[114X) and125[2XGAPDoc2HTMLPrintHTMLFiles[102X ([14X5.3-8[114X). We also add a link from [11Xmanual.html[111X to126[11Xchap0.html[111X. You probably want to copy stylesheet files into the same127directory, see [14X5.3-9[114X for more details. The argument [10Xpath[110X of [2XGAPDoc2HTML[102X128([14X5.3-7[114X) specifies the directory containing the BibTeX database files.[133X129130[4X[32X Example [32X[104X131[4X[25Xgap>[125X [27Xh := GAPDoc2HTML(r, path);;[127X[104X132[4X[25Xgap>[125X [27XGAPDoc2HTMLPrintHTMLFiles(h, path);[127X[104X133[4X[32X[104X134135[1X5.1-1 MakeGAPDocDoc[101X136137[33X[1;0Y[29X[2XMakeGAPDocDoc[102X( [3Xpath[103X, [3Xmain[103X, [3Xfiles[103X, [3Xbookname[103X[, [3Xgaproot[103X] ) [32X function[133X138139[33X[0;0YThis function collects all the commands for producing a text-, [10Xpdf[110X- and140HTML-version of a [5XGAPDoc[105X document as described in Section [14X5.1[114X. It checks the141[10X.log[110X file from the call of [10Xpdflatex[110X and reports if there are errors,142warnings or overfull boxes.[133X143144[33X[0;0Y[13XNote:[113X If this function works for you depends on your operating system and145installed software. It will probably work on most [10XUNIX[110X systems with a146standard LaTeX installation. If the function doesn't work for you look at147the source code and adjust it to your system.[133X148149[33X[0;0YHere [3Xpath[103X must be the directory (as string or directory object) containing150the main file [3Xmain[103X of the document (given with or without the [10X.xml[110X151extension. The argument [3Xfiles[103X is a list of (probably source code) files152relative to [3Xpath[103X which contain pieces of documentation which must be153included in the document, see Chapter [14X4[114X. And [3Xbookname[103X is the name of the154book used by [5XGAP[105X's online help. The optional argument [3Xgaproot[103X must be a155string which gives the relative path from [3Xpath[103X to the main [5XGAP[105X root156directory. If this is given, the HTML files are produced with relative paths157to external books.[133X158159[33X[0;0Y[2XMakeGAPDocDoc[102X can be called with additional arguments [10X"MathJax"[110X, [10X"Tth"[110X160and/or [10X"MathML"[110X. If these are given additional variants of the HTML161conversion are called, see [2XGAPDoc2HTML[102X ([14X5.3-7[114X) for details.[133X162163[33X[0;0YIt is possible to use [5XGAPDoc[105X with other languages than English, see164[2XSetGapDocLanguage[102X ([14X5.3-13[114X) for more details.[133X165166167[1X5.2 [33X[0;0YParsing XML Documents[133X[101X168169[33X[0;0YArbitrary well-formed XML documents can be parsed and browsed by the170following functions.[133X171172[1X5.2-1 ParseTreeXMLString[101X173174[33X[1;0Y[29X[2XParseTreeXMLString[102X( [3Xstr[103X[, [3Xsrcinfo[103X][, [3Xentitydict[103X] ) [32X function[133X175[33X[1;0Y[29X[2XParseTreeXMLFile[102X( [3Xfname[103X[, [3Xentitydict[103X] ) [32X function[133X176[6XReturns:[106X [33X[0;10Ya record which is root of a tree structure[133X177178[33X[0;0YThe first function parses an XML-document stored in string [3Xstr[103X and returns179the document in form of a tree.[133X180181[33X[0;0YThe optional argument [3Xsrcinfo[103X must have the same format as in182[2XOriginalPositionDocument[102X ([14X4.2-2[114X). If it is given then error messages refer183to the original source of the text with the problem.[133X184185[33X[0;0YWith the optional argument [3Xentitydict[103X named entities can be given to the186parser, for example entities which are defined in the [10X.dtd[110X-file (which is187not read by this parser). The standard XML-entities do not need to be188provided, and for [5XGAPDoc[105X documents the entity definitions from [10Xgapdoc.dtd[110X189are automatically provided. Entities in the document's [10X<!DOCTYPE[110X declaration190are parsed and also need not to be provided here. The argument [3Xentitydict[103X191must be a record where each component name is an entity name (without the192surrounding & and ;) to which is assigned its substitution string.[133X193194[33X[0;0YThe second function is just a shortcut for [10XParseTreeXMLString(195StringFile([110X[3Xfname[103X[10X), ... )[110X, see [2XStringFile[102X ([14X6.3-5[114X).[133X196197[33X[0;0YAfter these functions return the list of named entities which were known198during the parsing can be found in the record [10XENTITYDICT[110X.[133X199200[33X[0;0YA node in the result tree corresponds to an XML element, or to some parsed201character data. In the first case it looks as follows:[133X202203[4X[32X Example Node [32X[104X204[4Xrec( name := "Book",[104X205[4X attributes := rec( Name := "EDIM" ),[104X206[4X content := [ ... list of nodes for content ...],[104X207[4X start := 312,[104X208[4X stop := 15610,[104X209[4X next := 15611 )[104X210[4X[32X[104X211212[33X[0;0YThis means that [10X[3Xstr[103X[10X{[312..15610]}[110X looks like [10X<Book Name="EDIM"> ... content213... </Book>[110X.[133X214215[33X[0;0YThe leaves of the tree encode parsed character data as in the following216example:[133X217218[4X[32X Example Node [32X[104X219[4Xrec( name := "PCDATA", [104X220[4X content := "text without markup " )[104X221[4X[32X[104X222223[33X[0;0YThis function checks whether the XML document is [13Xwell formed[113X, see [14X2.1-14[114X for224an explanation. If an error in the XML structure is found, a break loop is225entered and the text around the position where the problem starts is shown.226With [10XShow();[110X one can browse the original input in the [2XPager[102X ([14XReference:227Pager[114X), starting with the line where the error occurred. All entities are228resolved when they are either entities defined in the [5XGAPDoc[105X package (in229particular the standard XML entities) or if their definition is included in230the [10X<!DOCTYPE ..>[110X tag of the document.[133X231232[33X[0;0YNote that [2XParseTreeXMLString[102X does not parse and interpret the corresponding233document type definition (the [10X.dtd[110X-file given in the [10X<!DOCTYPE ..>[110X tag).234Hence it also does not check the [13Xvalidity[113X of the document (i.e., it is no235[13Xvalidating XML parser[113X).[133X236237[33X[0;0YIf you are using this function to parse a [5XGAPDoc[105X document you can use238[2XCheckAndCleanGapDocTree[102X ([14X5.2-8[114X) for some validation and additional checking239of the document structure.[133X240241[1X5.2-2 StringXMLElement[101X242243[33X[1;0Y[29X[2XStringXMLElement[102X( [3Xtree[103X ) [32X function[133X244[6XReturns:[106X [33X[0;10Ya list [10X[string, positions][110X[133X245246[33X[0;0YThe argument [3Xtree[103X must have a format of a node in the parse tree of an XML247document as returned by [2XParseTreeXMLString[102X ([14X5.2-1[114X) (including the root node248representing the full document). This function computes a pair [10X[string,249positions][110X where [10Xstring[110X contains XML code which is equivalent to the code250which was parsed to get [3Xtree[103X. And [10Xpositions[110X is a list of lists of four251numbers [10X[eltb, elte, contb, conte][110X. There is one such list for each XML252element occuring in [10Xstring[110X, where [10Xeltb[110X and [10Xelte[110X are the begin and end253position of this element in [10Xstring[110X and where [10Xcontb[110X and [10Xconte[110X are begin and254end position of the content of this element, or both are [10X0[110X if there is no255content.[133X256257[33X[0;0YNote that parsing XML code is an irreversible task, we can only expect to258get equivalent XML code from this function. But parsing the resulting [10Xstring[110X259again and applying [2XStringXMLElement[102X again gives the same result. See the260function [2XEntitySubstitution[102X ([14X5.2-3[114X) for back-substitutions of entities in261the result.[133X262263[1X5.2-3 EntitySubstitution[101X264265[33X[1;0Y[29X[2XEntitySubstitution[102X( [3Xxmlstring[103X, [3Xentities[103X ) [32X function[133X266[6XReturns:[106X [33X[0;10Ya string[133X267268[33X[0;0YThe argument [3Xxmlstring[103X must be a string containing XML code or a pair269[10X[string, positions][110X as returned by [2XStringXMLElement[102X ([14X5.2-2[114X). The argument270[3Xentities[103X specifies entity names (without the surrounding [3X&[103X and [10X;[110X) and their271substitution strings, either a list of pairs of strings or as a record with272the names as components and the substitutions as values.[133X273274[33X[0;0YThis function tries to substitute non-intersecting parts of [10Xstring[110X by the275given entities. If the [10Xpositions[110X information is given then only parts of the276document which allow a valid substitution by an entity are considered.277Otherwise a simple text substitution without further check is done.[133X278279[33X[0;0YNote that in general the entity resolution in XML documents is a complicated280and non-reversible task. But nevertheless this utility may be useful in not281too complicated situations.[133X282283[1X5.2-4 DisplayXMLStructure[101X284285[33X[1;0Y[29X[2XDisplayXMLStructure[102X( [3Xtree[103X ) [32X function[133X286287[33X[0;0YThis utility displays the tree structure of an XML document as it is288returned by [2XParseTreeXMLString[102X ([14X5.2-1[114X) (without the [10XPCDATA[110X leaves).[133X289290[33X[0;0YSince this is usually quite long the result is shown using the [2XPager[102X291([14XReference: Pager[114X).[133X292293[1X5.2-5 ApplyToNodesParseTree[101X294295[33X[1;0Y[29X[2XApplyToNodesParseTree[102X( [3Xtree[103X, [3Xfun[103X ) [32X function[133X296[33X[1;0Y[29X[2XAddRootParseTree[102X( [3Xtree[103X ) [32X function[133X297[33X[1;0Y[29X[2XRemoveRootParseTree[102X( [3Xtree[103X ) [32X function[133X298299[33X[0;0YThe function [2XApplyToNodesParseTree[102X applies a function [3Xfun[103X to all nodes of300the parse tree [3Xtree[103X of an XML document returned by [2XParseTreeXMLString[102X301([14X5.2-1[114X).[133X302303[33X[0;0YThe function [2XAddRootParseTree[102X is an application of this. It adds to all304nodes a component [10X.root[110X to which the top node tree [3Xtree[103X is assigned. These305components can be removed afterwards with [2XRemoveRootParseTree[102X.[133X306307[33X[0;0YHere are two more utilities which use [2XApplyToNodesParseTree[102X.[133X308309[1X5.2-6 GetTextXMLTree[101X310311[33X[1;0Y[29X[2XGetTextXMLTree[102X( [3Xtree[103X ) [32X function[133X312[6XReturns:[106X [33X[0;10Ya string[133X313314[33X[0;0YThe argument [3Xtree[103X must be a node of a parse tree of some XML document, see315[2XParseTreeXMLFile[102X ([14X5.2-1[114X). This function collects the content of this and all316included elements recursively into a string.[133X317318[1X5.2-7 XMLElements[101X319320[33X[1;0Y[29X[2XXMLElements[102X( [3Xtree[103X, [3Xeltnames[103X ) [32X function[133X321[6XReturns:[106X [33X[0;10Ya list of nodes[133X322323[33X[0;0YThe argument [3Xtree[103X must be a node of a parse tree of some XML document, see324[2XParseTreeXMLFile[102X ([14X5.2-1[114X). This function returns a list of all subnodes of325[3Xtree[103X (possibly including [3Xtree[103X) of elements with name given in the list of326strings [3Xeltnames[103X. Use [10X"PCDATA"[110X as name for leave nodes which contain the327actual text of the document. As an abbreviation [3Xeltnames[103X can also be a328string which is then put in a one element list.[133X329330[33X[0;0YAnd here are utilities for processing [5XGAPDoc[105X XML documents.[133X331332[1X5.2-8 CheckAndCleanGapDocTree[101X333334[33X[1;0Y[29X[2XCheckAndCleanGapDocTree[102X( [3Xtree[103X ) [32X function[133X335[6XReturns:[106X [33X[0;10Ynothing[133X336337[33X[0;0YThe argument [3Xtree[103X of this function is a parse tree from [2XParseTreeXMLString[102X338([14X5.2-1[114X) of some [5XGAPDoc[105X document. This function does an (incomplete) validity339check of the document according to the document type declaration in340[11Xgapdoc.dtd[111X. It also does some additional checks which cannot be described in341the DTD (like checking whether chapters and sections have a heading). For342elements with element content the whitespace between these elements is343removed.[133X344345[33X[0;0YIn case of an error the break loop is entered and the position of the error346in the original XML document is printed. With [10XShow();[110X one can browse the347original input in the [2XPager[102X ([14XReference: Pager[114X).[133X348349[1X5.2-9 AddParagraphNumbersGapDocTree[101X350351[33X[1;0Y[29X[2XAddParagraphNumbersGapDocTree[102X( [3Xtree[103X ) [32X function[133X352[6XReturns:[106X [33X[0;10Ynothing[133X353354[33X[0;0YThe argument [3Xtree[103X must be an XML tree returned by [2XParseTreeXMLString[102X ([14X5.2-1[114X)355applied to a [5XGAPDoc[105X document. This function adds to each node of the tree a356component [10X.count[110X which is of form [10X[Chapter[, Section[, Subsection,357Paragraph] ] ][110X. Here the first three numbers should be the same as produced358by the LaTeX version of the document. Text before the first chapter is359counted as chapter [10X0[110X and similarly for sections and subsections. Some360elements are always considered to start a new paragraph.[133X361362[1X5.2-10 InfoXMLParser[101X363364[33X[1;0Y[29X[2XInfoXMLParser[102X[32X info class[133X365366[33X[0;0YThe default level of this info class is 1. Functions like [2XParseTreeXMLString[102X367([14X5.2-1[114X) are then printing some information, in particular in case of errors.368You can suppress it by setting the level of [2XInfoXMLParser[102X to 0. With level 2369there may be some more information for debugging purposes.[133X370371372[1X5.3 [33X[0;0YThe Converters[133X[101X373374[33X[0;0YHere are more details about the conversion programs for [5XGAPDoc[105X XML375documents.[133X376377[1X5.3-1 GAPDoc2LaTeX[101X378379[33X[1;0Y[29X[2XGAPDoc2LaTeX[102X( [3Xtree[103X ) [32X function[133X380[6XReturns:[106X [33X[0;10YLaTeX document as string[133X381382[33X[1;0Y[29X[2XSetGapDocLaTeXOptions[102X( [[3X...[103X] ) [32X function[133X383[6XReturns:[106X [33X[0;10YNothing[133X384385[33X[0;0YThe argument [3Xtree[103X for this function is a tree describing a [5XGAPDoc[105X XML386document as returned by [2XParseTreeXMLString[102X ([14X5.2-1[114X) (probably also checked387with [2XCheckAndCleanGapDocTree[102X ([14X5.2-8[114X)). The output is a string containing a388version of the document which can be written to a file and processed with389LaTeX or pdfLaTeX (and probably BibTeX and [10Xmakeindex[110X).[133X390391[33X[0;0YThe output uses the [10Xreport[110X document class and needs the following LaTeX392packages: [10Xa4wide[110X, [10Xamssymb[110X, [10Xinputenc[110X, [10Xmakeidx[110X, [10Xcolor[110X, [10Xfancyvrb[110X, [10Xpsnfss[110X,393[10Xpslatex[110X, [10Xenumitem[110X and [10Xhyperref[110X. These are for example provided by the394[5XteTeX-1.0[105X or [5Xtexlive[105X distributions of TeX (which in turn are used for most395TeX packages of current Linux distributions); see [7Xhttp://www.tug.org/tetex/[107X.[133X396397[33X[0;0YIn particular, the resulting [10Xpdf[110X-output (and [10Xdvi[110X-output) contains (internal398and external) hyperlinks which can be very useful for onscreen browsing of399the document.[133X400401[33X[0;0YThe LaTeX processing also produces a file with extension [10X.pnr[110X which is [5XGAP[105X402readable and contains the page numbers for all (sub)sections of the403document. This can be used by [5XGAP[105X's online help; see [2XAddPageNumbersToSix[102X404([14X5.3-4[114X). Non-ASCII characters in the [5XGAPDoc[105X document are translated to LaTeX405input in ASCII-encoding with the help of [2XEncode[102X ([14X6.2-2[114X) and the option406[10X"LaTeX"[110X. See the documentation of [2XEncode[102X ([14X6.2-2[114X) for how to proceed if you407have a character which is not handled (yet).[133X408409[33X[0;0YThis function works by running recursively through the document tree and410calling a handler function for each [5XGAPDoc[105X XML element. Many of these411handler functions (usually in [10XGAPDoc2LaTeXProcs.<ElementName>[110X) are not412difficult to understand (the greatest complications are some commands for413index entries, labels or the output of page number information). So it414should be easy to adjust layout details to your own taste by slight415modifications of the program.[133X416417[33X[0;0YFormer versions of [5XGAPDoc[105X supported some XML processing instructions to add418some extra lines to the preamble of the LaTeX document. Its use is now419deprecated, use the much more flexible [2XSetGapDocLaTeXOptions[102X instead: The420default layout of the resulting documents can be changed with421[2XSetGapDocLaTeXOptions[102X. This changes parts of the header of the LaTeX file422produced by [5XGAPDoc[105X. You can see the header with some placeholders by423[10XPage(GAPDoc2LaTeXProcs.Head);[110X. The placeholders are filled with components424from the record [10XGAPDoc2LaTeXProcs.DefaultOptions[110X. The arguments of425[2XSetGapDocLaTeXOptions[102X can be records with the same structure (or parts of426it) with different values. As abbreviations there are also three strings427supported as arguments. These are [10X"nocolor"[110X for switching all colors to428black; then [10X"nopslatex"[110X to use standard LaTeX fonts instead of postscript429fonts; and finally [10X"utf8"[110X to choose UTF-8 as input encoding for the LaTeX430document.[133X431432[1X5.3-2 GAPDoc2Text[101X433434[33X[1;0Y[29X[2XGAPDoc2Text[102X( [3Xtree[103X[, [3Xbibpath[103X][, [3Xwidth[103X] ) [32X function[133X435[6XReturns:[106X [33X[0;10Yrecord containing text files as strings and other information[133X436437[33X[0;0YThe argument [3Xtree[103X for this function is a tree describing a [5XGAPDoc[105X XML438document as returned by [2XParseTreeXMLString[102X ([14X5.2-1[114X) (probably also checked439with [2XCheckAndCleanGapDocTree[102X ([14X5.2-8[114X)). This function produces a text version440of the document which can be used with [5XGAP[105X's online help (with the [10X"screen"[110X441viewer, see [2XSetHelpViewer[102X ([14XReference: SetHelpViewer[114X)). It includes title442page, bibliography and index. The bibliography is made from BibXMLext or443BibTeX databases, see [14X7[114X. Their location must be given with the argument444[3Xbibpath[103X (as string or directory object).[133X445446[33X[0;0YThe output is a record with one component for each chapter (with names [10X"0"[110X,447[10X"1"[110X, ..., [10X"Bib"[110X and [10X"Ind"[110X). Each such component is again a record with the448following components:[133X449450[8X[10Xtext[110X[8X[108X451[33X[0;6Ythe text of the whole chapter as a string[133X452453[8X[10Xssnr[110X[8X[108X454[33X[0;6Ylist of subsection numbers in this chapter (like [10X[3, 2, 1][110X for455chapter 3, section 2, subsection 1)[133X456457[8X[10Xlinenr[110X[8X[108X458[33X[0;6Ycorresponding list of line numbers where the subsections start[133X459460[8X[10Xlen[110X[8X[108X461[33X[0;6Ynumber of lines of this chapter[133X462463[33X[0;0YThe result can be written into files with the command464[2XGAPDoc2TextPrintTextFiles[102X ([14X5.3-3[114X).[133X465466[33X[0;0YAs a side effect this function also produces the [11Xmanual.six[111X information467which is used for searching in [5XGAP[105X's online help. This is stored in [10X[3Xtree[103X[10X.six[110X468and can be printed into a [11Xmanual.six[111X file with [2XPrintSixFile[102X ([14X5.3-5[114X)469(preferably after producing a LaTeX version of the document as well and470adding the page number information to [10X[3Xtree[103X[10X.six[110X, see [2XGAPDoc2LaTeX[102X ([14X5.3-1[114X) and471[2XAddPageNumbersToSix[102X ([14X5.3-4[114X)).[133X472473[33X[0;0YThe text produced by this function contains some markup via ANSI escape474sequences. The sequences used here are usually ignored by terminals. But the475[5XGAP[105X help system will substitute them by interpreted color and attribute476sequences (see [2XTextAttr[102X ([14X6.1-2[114X)) before displaying them. There is a default477markup used for this but it can also be configured by the user, see478[2XSetGAPDocTextTheme[102X ([14X5.3-6[114X). Furthermore, the text produced is in UTF-8479encoding. The encoding is also translated on the fly, if480[10XGAPInfo.TermEncoding[110X is set to some encoding supported by [2XEncode[102X ([14X6.2-2[114X),481e.g., [10X"ISO-8859-1"[110X or [10X"latin1"[110X.[133X482483[33X[0;0YWith the optional argument [3Xwidth[103X a different length of the output text lines484can be chosen. The default is 76 and all lines in the resulting text start485with two spaces. This looks good on a terminal with a standard width of 80486characters and you probably don't want to use this argument.[133X487488[1X5.3-3 GAPDoc2TextPrintTextFiles[101X489490[33X[1;0Y[29X[2XGAPDoc2TextPrintTextFiles[102X( [3Xt[103X[, [3Xpath[103X] ) [32X function[133X491[6XReturns:[106X [33X[0;10Ynothing[133X492493[33X[0;0YThe first argument must be a result returned by [2XGAPDoc2Text[102X ([14X5.3-2[114X). The494second argument is a path for the files to write, it can be given as string495or directory object. The text of each chapter is written into a separate496file with name [11Xchap0.txt[111X, [11Xchap1.txt[111X, ..., [11XchapBib.txt[111X, and [11XchapInd.txt[111X.[133X497498[33X[0;0YIf you want to make your document accessible via the [5XGAP[105X online help you499must put at least these files for the text version into a directory,500together with the file [11Xmanual.six[111X, see [2XPrintSixFile[102X ([14X5.3-5[114X). Then specify501the path to the [11Xmanual.six[111X file in the packages [11XPackageInfo.g[111X file, see502[14X'Reference: The PackageInfo.g File'[114X.[133X503504[33X[0;0YOptionally you can add the [10Xdvi[110X- and [10Xpdf[110X-versions of the document which are505produced with [2XGAPDoc2LaTeX[102X ([14X5.3-1[114X) to this directory. The files must have506the names [11Xmanual.dvi[111X and [11Xmanual.pdf[111X, respectively. Also you can add the507files of the HTML version produced with [2XGAPDoc2HTML[102X ([14X5.3-7[114X) to this508directory, see [2XGAPDoc2HTMLPrintHTMLFiles[102X ([14X5.3-8[114X). The handler functions in509[5XGAP[105X for this help format detect automatically which of the optional formats510of a book are actually available.[133X511512[1X5.3-4 AddPageNumbersToSix[101X513514[33X[1;0Y[29X[2XAddPageNumbersToSix[102X( [3Xtree[103X, [3Xpnrfile[103X ) [32X function[133X515[6XReturns:[106X [33X[0;10Ynothing[133X516517[33X[0;0YHere [3Xtree[103X must be the XML tree of a [5XGAPDoc[105X document, returned by518[2XParseTreeXMLString[102X ([14X5.2-1[114X). Running [10Xlatex[110X on the result of519[10XGAPDoc2LaTeX([3Xtree[103X[10X)[110X produces a file [3Xpnrfile[103X (with extension [10X.pnr[110X). The520command [10XGAPDoc2Text([3Xtree[103X[10X)[110X creates a component [10X[3Xtree[103X[10X.six[110X which contains all521information about the document for the [5XGAP[105X online help, except the page522numbers in the [10X.dvi, .ps, .pdf[110X versions of the document. This command adds523the missing page number information to [10X[3Xtree[103X[10X.six[110X.[133X524525[1X5.3-5 PrintSixFile[101X526527[33X[1;0Y[29X[2XPrintSixFile[102X( [3Xtree[103X, [3Xbookname[103X, [3Xfname[103X ) [32X function[133X528[6XReturns:[106X [33X[0;10Ynothing[133X529530[33X[0;0YThis function prints the [10X.six[110X file [3Xfname[103X for a [5XGAPDoc[105X document stored in531[3Xtree[103X with name [3Xbookname[103X. Such a file contains all information about the book532which is needed by the [5XGAP[105X online help. This information must first be533created by calls of [2XGAPDoc2Text[102X ([14X5.3-2[114X) and [2XAddPageNumbersToSix[102X ([14X5.3-4[114X).[133X534535[1X5.3-6 SetGAPDocTextTheme[101X536537[33X[1;0Y[29X[2XSetGAPDocTextTheme[102X( [[3Xoptrec1[103X[, [3Xoptrec2[103X], [3X...[103X] ) [32X function[133X538[6XReturns:[106X [33X[0;10Ynothing[133X539540[33X[0;0YThis utility function is for readers of the screen version of [5XGAP[105X manuals541which are generated by the [5XGAPDoc[105X package. It allows to configure the color542and attribute layout of the displayed text. There is a default which can be543reset by calling this function without argument.[133X544545[33X[0;0YAs an abbreviation the arguments [3Xoptrec1[103X and so on can be strings for the546known name of a theme. Information about valid names is shown with547[10XSetGAPDocTextTheme("");[110X.[133X548549[33X[0;0YOtherwise, [3Xoptrec1[103X and so on must be a record. Its entries overwrite the550corresponding entries in the default and in previous arguments. To construct551valid markup you can use [2XTextAttr[102X ([14X6.1-2[114X). Entries must be either pairs of552strings, which are put before and after the corresponding text, or as an553abbreviation it can be a single string. In the latter case, the second554string is implied; if the string contains an escape sequence the second555string is [10XTextAttr.reset[110X, otherwise the given string is used. The following556components are recognized:[133X557558[8X[10Xflush[110X[8X[108X559[33X[0;6Y[10X"both"[110X for left-right justified paragraphs, and [10X"left"[110X for ragged560right ones[133X561562[8X[10XHeading[110X[8X[108X563[33X[0;6Ychapter and (sub-)section headings[133X564565[8X[10XFunc[110X[8X[108X566[33X[0;6Yfunction, operation, ... names[133X567568[8X[10XArg[110X[8X[108X569[33X[0;6Yargument names in descriptions[133X570571[8X[10XExample[110X[8X[108X572[33X[0;6Yexample code[133X573574[8X[10XPackage[110X[8X[108X575[33X[0;6Ypackage names[133X576577[8X[10XReturns[110X[8X[108X578[33X[0;6YReturns-line in descriptions[133X579580[8X[10XURL[110X[8X[108X581[33X[0;6YURLs[133X582583[8X[10XMark[110X[8X[108X584[33X[0;6YMarks in description lists[133X585586[8X[10XK[110X[8X[108X587[33X[0;6Y[5XGAP[105X keywords[133X588589[8X[10XC[110X[8X[108X590[33X[0;6Ycode or text to type[133X591592[8X[10XF[110X[8X[108X593[33X[0;6Yfile names[133X594595[8X[10XB[110X[8X[108X596[33X[0;6Ybuttons[133X597598[8X[10XM[110X[8X[108X599[33X[0;6Ysimplified math elements[133X600601[8X[10XMath[110X[8X[108X602[33X[0;6Ynormal math elements[133X603604[8X[10XDisplay[110X[8X[108X605[33X[0;6Ydisplayed math elements[133X606607[8X[10XEmph[110X[8X[108X608[33X[0;6Yemphasized text[133X609610[8X[10XQ[110X[8X[108X611[33X[0;6Yquoted text[133X612613[8X[10XRef[110X[8X[108X614[33X[0;6Yreference text[133X615616[8X[10XPrompt[110X[8X[108X617[33X[0;6Y[5XGAP[105X prompt in examples[133X618619[8X[10XBrkPrompt[110X[8X[108X620[33X[0;6Y[5XGAP[105X break prompt in examples[133X621622[8X[10XGAPInput[110X[8X[108X623[33X[0;6Y[5XGAP[105X input in examples[133X624625[8X[10Xreset[110X[8X[108X626[33X[0;6Yreset to default, don't change this[133X627628[8X[10XBibAuthor[110X[8X[108X629[33X[0;6Yauthor names in bibliography[133X630631[8X[10XBibTitle[110X[8X[108X632[33X[0;6Ytitles in bibliography[133X633634[8X[10XBibJournal[110X[8X[108X635[33X[0;6Yjournal names in bibliography[133X636637[8X[10XBibVolume[110X[8X[108X638[33X[0;6Yvolume number in bibliography[133X639640[8X[10XBibLabel[110X[8X[108X641[33X[0;6Ylabels for bibliography entries[133X642643[8X[10XBibReset[110X[8X[108X644[33X[0;6Yreset for bibliography, don't change[133X645646[8X[10XListBullet[110X[8X[108X647[33X[0;6Ybullet for simple lists (2 visible characters long)[133X648649[8X[10XEnumMarks[110X[8X[108X650[33X[0;6Yone visible character before and after the number in enumerated lists[133X651652[8X[10XDefLineMarker[110X[8X[108X653[33X[0;6Ymarker before function and variable definitions (2 visible characters654long)[133X655656[8X[10XFillString[110X[8X[108X657[33X[0;6Yfor filling in definitions and example separator lines[133X658659[4X[32X Example [32X[104X660[4X[25Xgap>[125X [27X# use no colors for GAP examples and [127X[104X661[4X[25Xgap>[125X [27X# change display of headings to bold green[127X[104X662[4X[25Xgap>[125X [27XSetGAPDocTextTheme("noColorPrompt", [127X[104X663[4X[25X>[125X [27X rec(Heading:=Concatenation(TextAttr.bold, TextAttr.2)));[127X[104X664[4X[32X[104X665666[1X5.3-7 GAPDoc2HTML[101X667668[33X[1;0Y[29X[2XGAPDoc2HTML[102X( [3Xtree[103X[, [3Xbibpath[103X[, [3Xgaproot[103X]][, [3Xmtrans[103X] ) [32X function[133X669[6XReturns:[106X [33X[0;10Yrecord containing HTML files as strings and other information[133X670671[33X[0;0YThe argument [3Xtree[103X for this function is a tree describing a [5XGAPDoc[105X XML672document as returned by [2XParseTreeXMLString[102X ([14X5.2-1[114X) (probably also checked673with [2XCheckAndCleanGapDocTree[102X ([14X5.2-8[114X)). Without an [3Xmtrans[103X argument this674function produces an HTML version of the document which can be read with any675Web-browser and also be used with [5XGAP[105X's online help (see [2XSetHelpViewer[102X676([14XReference: SetHelpViewer[114X)). It includes title page, bibliography, and677index. The bibliography is made from BibTeX databases. Their location must678be given with the argument [3Xbibpath[103X (as string or directory object, if not679given the current directory is used). If the third argument [3Xgaproot[103X is given680and is a string then this string is interpreted as relative path to [5XGAP[105X's681main root directory. Reference-URLs to external HTML-books which begin with682the [5XGAP[105X root path are then rewritten to start with the given relative path.683This makes the HTML-documentation portable provided a package is installed684in some standard location below the [5XGAP[105X root.[133X685686[33X[0;0YThe output is a record with one component for each chapter (with names [10X"0"[110X,687[10X"1"[110X, ..., [10X"Bib"[110X, and [10X"Ind"[110X). Each such component is again a record with the688following components:[133X689690[8X[10Xtext[110X[8X[108X691[33X[0;6Ythe text of an HTML file containing the whole chapter (as a string)[133X692693[8X[10Xssnr[110X[8X[108X694[33X[0;6Ylist of subsection numbers in this chapter (like [10X[3, 2, 1][110X for695chapter 3, section 2, subsection 1)[133X696697[33X[0;0Y[13XStandard output format without[113X [3Xmtrans[103X [13Xargument[113X[133X698699[33X[0;0YThe HTML code produced with this converter conforms to the W3C specification700[21XXHTML 1.0 strict[121X, see [7Xhttp://www.w3.org/TR/xhtml1[107X. First, this means that701the HTML files are valid XML files. Secondly, the extension [21Xstrict[121X says in702particular that the code doesn't contain any explicit font or color703information.[133X704705[33X[0;0YMathematical formulae are handled as in the text converter [2XGAPDoc2Text[102X706([14X5.3-2[114X). We don't want to assume that the browser can use symbol fonts. Some707[5XGAP[105X users like to browse the online help with [10Xlynx[110X, see [2XSetHelpViewer[102X708([14XReference: SetHelpViewer[114X), which runs inside the same terminal windows as709[5XGAP[105X.[133X710711[33X[0;0YTo view the generated files in graphical browsers, stylesheet files with712layout configuration should be copied into the directory with the generated713HTML files, see [14X5.3-9[114X.[133X714715[33X[0;0Y[13XOutput format with[113X [3Xmtrans[103X argument[133X716717[33X[0;0YCurrently, there are three variants of this converter available which handle718mathematical formulae differently. They are accessed via the optional last719[3Xmtrans[103X argument.[133X720721[33X[0;0YIf [3Xmtrans[103X is set to [10X"MathJax"[110X the formulae are essentially translated as for722LaTeX documents (there is no processing of [10X<M>[110X elements as decribed in723[14X3.8-2[114X). Inline formulae are delimited by [10X\([110X and [10X\)[110X and displayed formulae by724[10X\[[110X and [10X\][110X. With [5XMathJax[105X webpages can contain nicely formatted scalable and725searchable formulae. The resulting files link by default to726[7Xhttp://cdn.mathjax.org[107X to get the [5XMathJax[105X script and fonts. This means that727they can only be used on computers with internet access. An alternative URL728can be set by overwriting [10XGAPDoc2HTMLProcs.MathJaxURL[110X before building the729HTML version of a manual. This way a local installation of [5XMathJax[105X could be730used. See [7Xhttp://www.mathjax.org/[107X for more details.[133X731732[33X[0;0YThe following possibilities for [3Xmtrans[103X are still supported, but since the733[5XMathJax[105X approach seems much better, their use is deprecated.[133X734735[33X[0;0YIf the argument [3Xmtrans[103X is set to [10X"Tth"[110X it is assumed that you have installed736the LaTeX to HTML translation program [10Xtth[110X. This is used to translate the737contents of the [10XM[110X, [10XMath[110X and [10XDisplay[110X elements into HTML code. Note that the738resulting code is not compliant with any standard. Formally it is [21XXHTML 1.0739Transitional[121X, it contains explicit font specifications and the characters of740mathematical symbols are included via their position in a [21XSymbol[121X font. Some741graphical browsers can be configured to display this in a useful manner,742check the Tth homepage ([7Xhttp://hutchinson.belmont.ma.us/tth/[107X) for more743details.[133X744745[33X[0;0YThis function works by running recursively through the document tree and746calling a handler function for each [5XGAPDoc[105X XML element. Many of these747handler functions (usually in [10XGAPDoc2TextProcs.<ElementName>[110X) are not748difficult to understand (the greatest complications are some commands for749index entries, labels or the output of page number information). So it750should be easy to adjust certain details to your own taste by slight751modifications of the program.[133X752753[33X[0;0YThe result of this converter can be written to files with the command754[2XGAPDoc2HTMLPrintHTMLFiles[102X ([14X5.3-8[114X).[133X755756[33X[0;0YThere are two user preferences for reading the HTML manuals produced by757[5XGAPDoc[105X. A user can choose among several style files which determine the758appearance of the manual pages with [10XSetUserPreference("GAPDoc", "HTMLStyle",759[...]);[110X where the list in the third argument are arguments for760[2XSetGAPDocHTMLStyle[102X ([14X5.3-11[114X). The second preference is set by761[10XSetUserPreference("GAPDoc", "UseMathJax", ...);[110X where the third argument is762[9Xtrue[109X or [9Xfalse[109X (default). If this is set to [9Xtrue[109X, the [5XGAP[105X help system763displays the [5XMathJax[105X version of the HTML manuals.[133X764765[1X5.3-8 GAPDoc2HTMLPrintHTMLFiles[101X766767[33X[1;0Y[29X[2XGAPDoc2HTMLPrintHTMLFiles[102X( [3Xt[103X[, [3Xpath[103X] ) [32X function[133X768[6XReturns:[106X [33X[0;10Ynothing[133X769770[33X[0;0YThe first argument must be a result returned by [2XGAPDoc2HTML[102X ([14X5.3-7[114X). The771second argument is a path for the files to write, it can be given as string772or directory object. The text of each chapter is written into a separate773file with name [11Xchap0.html[111X, [11Xchap1.html[111X, ..., [11XchapBib.html[111X, and [11XchapInd.html[111X.[133X774775[33X[0;0YThe [5XMathJax[105X versions are written to files [11Xchap0_mj.html[111X, ...,776[11XchapInd_mj.html[111X.[133X777778[33X[0;0YThe experimental version which is produced with [10Xtth[110X uses different names for779the files, namely [11Xchap0_sym.html[111X, and so on for files which need symbol780fonts.[133X781782[33X[0;0YYou should also add stylesheet files to the directory with the HTML files,783see [14X5.3-9[114X.[133X784785786[1X5.3-9 [33X[0;0YStylesheet files[133X[101X787788[33X[0;0YFor graphical browsers the layout of the generated HTML manuals can be789highly configured by cascading stylesheet (CSS) and javascript files. Such790files are provided in the [11Xstyles[111X directory of the [5XGAPDoc[105X package.[133X791792[33X[0;0YWe recommend that these files are copied into each manual directory (such793that each of them is selfcontained). There is a utility function794[2XCopyHTMLStyleFiles[102X ([14X5.3-10[114X) which does this. Of course, these files may be795changed or new styles may be added. New styles may also be sent to the796[5XGAPDoc[105X authors for possible inclusion in future versions.[133X797798[33X[0;0YThe generated HTML files refer to the file [11Xmanual.css[111X which conforms to the799W3C specification CSS 2.0, see [7Xhttp://www.w3.org/TR/REC-CSS2[107X, and the800javascript file [11Xmanual.js[111X (only in browsers which support CSS or javascript,801respectively; but the HTML files are also readable without any of them). To802add a style [10Xmystyle[110X one or both of [11Xmystyle.css[111X and [11Xmystyle.js[111X must be803provided; these can overwrite default settings and add new javascript804functions. For more details see the comments in [11Xmanual.js[111X.[133X805806[1X5.3-10 CopyHTMLStyleFiles[101X807808[33X[1;0Y[29X[2XCopyHTMLStyleFiles[102X( [3Xdir[103X ) [32X function[133X809[6XReturns:[106X [33X[0;10Ynothing[133X810811[33X[0;0YThis utility function copies the [11X*.css[111X and [11X*.js[111X files from the [11Xstyles[111X812directory of the [5XGAPDoc[105X package into the directory [3Xdir[103X.[133X813814[1X5.3-11 SetGAPDocHTMLStyle[101X815816[33X[1;0Y[29X[2XSetGAPDocHTMLStyle[102X( [[3Xstyle1[103X[, [3Xstyle2[103X], [3X...[103X] ) [32X function[133X817[6XReturns:[106X [33X[0;10Ynothing[133X818819[33X[0;0YThis utility function is for readers of the HTML version of [5XGAP[105X manuals820which are generated by the [5XGAPDoc[105X package. It allows to configure the821display style of the manuals. This will only have an effect if you are using822a browser that supports [5Xjavascript[105X. There is a default which can be reset by823calling this function without argument.[133X824825[33X[0;0YThe arguments [3Xstyle1[103X and so on must be strings. You can find out about the826valid strings by following the [12X[Style][112X link on top of any manual page.827(Going back to the original page, its address has a setting for [10XGAPDocStyle[110X828which is the list of strings, separated by commas, you want to use here.)[133X829830[4X[32X Example [32X[104X831[4X[25Xgap>[125X [27X# show/hide subsections in tables on contents only after click,[127X[104X832[4X[25Xgap>[125X [27X# and don't use colors in GAP examples[127X[104X833[4X[25Xgap>[125X [27XSetGAPDocHTMLStyle("toggless", "nocolorprompt");[127X[104X834[4X[32X[104X835836[1X5.3-12 InfoGAPDoc[101X837838[33X[1;0Y[29X[2XInfoGAPDoc[102X[32X info class[133X839840[33X[0;0YThe default level of this info class is 1. The converter functions for841[5XGAPDoc[105X documents are then printing some information. You can suppress this842by setting the level of [2XInfoGAPDoc[102X to 0. With level 2 there may be some more843information for debugging purposes.[133X844845[1X5.3-13 SetGapDocLanguage[101X846847[33X[1;0Y[29X[2XSetGapDocLanguage[102X( [[3Xlang[103X] ) [32X function[133X848[6XReturns:[106X [33X[0;10Ynothing[133X849850[33X[0;0YThe [5XGAPDoc[105X converter programs sometimes produce text which is not explicit851in the document, e.g., headers like [21XAbstract[121X, [21XAppendix[121X, links to [21XNext852Chapter[121X, variable types [21Xfunction[121X and so on.[133X853854[33X[0;0YWith [2XSetGapDocLanguage[102X the language for these texts can be changed. The855argument [3Xlang[103X must be a string. Calling without argument or with a language856name for which no translations are available is the same as using the857default [10X"english"[110X.[133X858859[33X[0;0YIf your language [3Xlang[103X is not yet available, look at the record860[10XGAPDocTexts.english[110X and translate all the strings to [3Xlang[103X. Then assign this861record to [10XGAPDocTexts.([3Xlang[103X[10X)[110X and send it to the [5XGAPDoc[105X authors for inclusion862in future versions of [5XGAPDoc[105X. (Currently, there are translations for863[10Xenglish[110X, [10Xgerman[110X, [10Xrussian[110X and [10Xukrainian[110X.)[133X864865[33X[0;0Y[13XFurther hints:[113X To get strings produced by LaTeX right you will probably use866the [10Xbabel[110X package with option [3Xlang[103X, see [2XSetGapDocLaTeXOptions[102X ([14X5.3-1[114X). If867[3Xlang[103X cannot be encoded in [10Xlatin1[110X encoding you can consider the use of [10X"utf8"[110X868with [2XSetGapDocLaTeXOptions[102X ([14X5.3-1[114X).[133X869870871[1X5.4 [33X[0;0YTesting Manual Examples[133X[101X872873[33X[0;0YWe also provide some tools to check and adjust the examples given in874[10X<Example>[110X-elements.[133X875876[33X[0;0YFormer versions of [5XGAPDoc[105X provided functions [10XManualExamples[110X and877[10XTestManualExamples[110X. These functions are still available, but no longer878documented. Their use is deprecated.[133X879880[1X5.4-1 ExtractExamples[101X881882[33X[1;0Y[29X[2XExtractExamples[102X( [3Xpath[103X, [3Xmain[103X, [3Xfiles[103X, [3Xunits[103X ) [32X function[133X883[6XReturns:[106X [33X[0;10Ya list of lists[133X884885[33X[1;0Y[29X[2XExtractExamplesXMLTree[102X( [3Xtree[103X, [3Xunits[103X ) [32X function[133X886[6XReturns:[106X [33X[0;10Ya list of lists[133X887888[33X[0;0YThe argument [3Xtree[103X must be a parse tree of a [5XGAPDoc[105X document, see889[2XParseTreeXMLFile[102X ([14X5.2-1[114X). The function [2XExtractExamplesXMLTree[102X returns a data890structure representing the [10X<Example>[110X elements of the document. The return891value can be used with [2XRunExamples[102X ([14X5.4-2[114X) to check and optionally update892the examples of the document.[133X893894[33X[0;0YDepending on the argument [3Xunits[103X several examples are collected in one list.895Recognized values for [3Xunits[103X are [10X"Chapter"[110X, [10X"Section"[110X, [10X"Subsection"[110X or896[10X"Single"[110X. The latter means that each example is in a separate list. For all897other value of [3Xunits[103X just one list with all examples is returned.[133X898899[33X[0;0YThe arguments [3Xpath[103X, [3Xmain[103X and [3Xfiles[103X of [2XExtractExamples[102X are the same as for900[2XComposedDocument[102X ([14X4.2-1[114X). This function first contructs and parses the901[5XGAPDoc[105X document and then applies [2XExtractExamplesXMLTree[102X.[133X902903[1X5.4-2 RunExamples[101X904905[33X[1;0Y[29X[2XRunExamples[102X( [3Xexmpls[103X[, [3Xoptrec[103X] ) [32X function[133X906[6XReturns:[106X [33X[0;10Y[9Xtrue[109X or [9Xfalse[109X[133X907908[33X[0;0YThe argument [3Xexmpls[103X must be the output of a call to [2XExtractExamples[102X ([14X5.4-1[114X)909or [2XExtractExamplesXMLTree[102X ([14X5.4-1[114X). The optional argument [3Xoptrec[103X must be a910record, its components can change the default behaviour of this function.[133X911912[33X[0;0YBy default this function runs the [5XGAP[105X input of all examples and compares the913actual output with the output given in the examples. If differences occur914these are displayed together with information on the location of the source915code of that example. Before running the examples in each unit (entry of916[3Xexmpls[103X) the function [2XSTART_TEST[102X ([14XReference: START_TEST[114X) is called and the917screen width is set to 72 characters.[133X918919[33X[0;0YThis function returns [9Xtrue[109X if no differences are found and [9Xfalse[109X otherwise.[133X920921[33X[0;0YIf the argument [3Xoptrec[103X is given, the following components are recognized:[133X922923[8X[10XshowDiffs[110X[8X[108X924[33X[0;6YThe default value is [9Xtrue[109X, if set to something else found differences925in the examples are not displayed.[133X926927[8X[10Xwidth[110X[8X[108X928[33X[0;6YThe value must be a positive integer which is used as screen width929when running the examples. As mentioned above, the default is 72 which930is a sensible value for the text version of the [5XGAPDoc[105X document used931in a 80 character wide terminal.[133X932933[8X[10XignoreComments[110X[8X[108X934[33X[0;6YThe default is [9Xfalse[109X.[133X935[33X[0;6YIf set to [9Xtrue[109X comments in the input will be ignored (as in the936default behaviour of the [2XTest[102X ([14XReference: Test[114X) function).[133X937938[8X[10XchangeSources[110X[8X[108X939[33X[0;6YIf this is set to [9Xtrue[109X then the source code of all manual examples940which show differences is adjusted to the current outputs. The default941is [9Xfalse[109X.[133X942[33X[0;6YUse this feature with care. Note that sometimes differences can943indicate a bug, and in such a case it is more appropriate to fix the944bug instead of changing the example output.[133X945946[8X[10XcompareFunction[110X[8X[108X947[33X[0;6YThe function used to compare the output shown in the example and the948current output. See [2XTest[102X ([14XReference: Test[114X) for more details.[133X949950[8X[10XcheckWidth[110X[8X[108X951[33X[0;6YIf this option is a positive integer [10Xn[110X the function prints warnings if952an example contains any line with more than [10Xn[110X characters (input and953output lines are considered). By default this option is set to [9Xfalse[109X.[133X954955956957