Package: tcllib, Version: CVS HEAD
doctoc_lang_intro -
doctoc language introduction
This document is an informal introduction to version 1.1 of the doctoc markup language based on a multitude of examples. After reading this a writer should be ready to understand the two parts of the formal specification, i.e. the doctoc language syntax specification and the doctoc language command reference.
Each markup command is a Tcl command surrounded by a matching pair of [ and ]. Inside of these delimiters the usual rules for a Tcl command apply with regard to word quotation, nested commands, continuation lines, etc. I.e.
... [division_start {Appendix 1}] ...
... [item thefile \\ label {file description}] ...
[toc_begin GROUPTITLE TITLE] [toc_end]This also shows us that all doctoc documents consist of only one part where we will list items and divisions.
The user is free to mix these as she sees fit. This is a change from version 1 of the language, which did not allow this mixing, but only the use of either a series of items or a series of divisions.
We will discuss the commands for each of these two possibilities in the next sections.
Symbolic names are used to preserve the convertibility of this format to any output format. The actual name of any file will be inserted by the chosen formatting engine when converting the input, based on a mapping from symbolic to actual names given to the engine.
Here a made up example for a table of contents of this document:
[toc_begin Doctoc {Language Introduction}] [item 1 DESCRIPTION] [item 1.1 {Basic structure}] [item 1.2 Items] [item 1.3 Divisions] [item 2 {FURTHER READING}] [toc_end]
This kind of structure can be made more explicit in the doctoc language by using divisions. Instead of using a series of plain items we use a series of divisions for the major references, and then place the nested items inside of these.
Of course, instead of the nested items we can again use divisions and thus nest arbitrarily deep.
A division is marked by two commands instead of one, one to start it, the other to close the last opened division. They are:
Using this we can recast the last example like this
[toc_begin Doctoc {Language Introduction}] [division_start DESCRIPTION] [item 1 {Basic structure}] [item 2 Items] [item 3 Divisions] [division_end] [division_start {FURTHER READING}] [division_end] [toc_end]
Or, to demonstrate deeper nesting
[toc_begin Doctoc {Language Introduction}] [division_start DESCRIPTION] [division_start {Basic structure}] [item 1 Do] [item 2 Re] [division_end] [division_start Items] [item a Fi] [item b Fo] [item c Fa] [division_end] [division_start Divisions] [item 1 Sub] [item 1 Zero] [division_end] [division_end] [division_start {FURTHER READING}] [division_end] [toc_end]And do not forget, it is possible to freely mix items and divisions, and to have empty divisions.
[toc_begin Doctoc {Language Introduction}] [item 1 Do] [division_start DESCRIPTION] [division_start {Basic structure}] [item 2 Re] [division_end] [item a Fi] [division_start Items] [item b Fo] [item c Fa] [division_end] [division_start Divisions] [division_end] [division_end] [division_start {FURTHER READING}] [division_end] [toc_end]
Instead of only whitespace the two templating commands include and vset are also allowed, to enable the writer to either set and/or import configuration settings relevant to the table of contents. I.e. it is possible to write
[include FILE] [vset VAR VALUE] [toc_begin GROUPTITLE TITLE] ... [toc_end]Even more important, these two commands are allowed anywhere where a markup command is allowed, without regard for any other structure.
[toc_begin GROUPTITLE TITLE] [include FILE] [vset VAR VALUE] ... [toc_end]The only restriction include has to obey is that the contents of the included file must be valid at the place of the inclusion. I.e. a file included before toc_begin may contain only the templating commands vset and include, a file included in a division may contain only items or divisions commands, etc.
Our example of their use are the sources of the last sentence in the previous paragraph, with some highlighting added.
... These commands, [cmd lb] and [cmd lb] respectively, are required because our use of [lb] and [rb] to bracket markup commands makes it impossible to directly use [lb] and [rb] within the text. ...
To be able to validate a document while writing it, it is also recommended to familiarize oneself with Tclapps' ultra-configurable dtp.
On the other hand, doctoc is perfectly suited for the automatic generation from doctools documents, and this is the route Tcllib's easy and simple dtplite goes, creating a table of contents for a set of documents behind the scenes, without the writer having to do so on their own.
doctoc_intro, doctoc_lang_syntax, doctoc_lang_cmdref
markup, semantic markup, doctoc markup, doctoc language, doctoc syntax, doctoc commands