![]() |
ActiveTcl User Guide
|
![]() |
doctoc_fmt - Specification of a simple Tcl Markup Language for Tables of Contents
TABLE OF
CONTENTS
SYNOPSIS
DESCRIPTION
FORMAT
SPECIFICATION
OVERVIEW
GRAMMAR
COMMANDS
NOTES
EXAMPLE
SEE ALSO
KEYWORDS
COPYRIGHT
|
This document specifies version 1 of a text format for tables of contents. The name of this format is doctoc and it provides all the necessary commands to write a table of contents for a group of documents. It is intended to complement both the doctools format for writing documentation and the docidx format for writing keyword indices. The formal specifications for these two formats can be found in the companion documents doctools_fmt and docidx_fmt . A third companion document describes the package doctools::toc, which provides commands for the processing of text in doctoc format.
Like for the formats doctools and docidx a generic framework for the conversion of doctoc to any number of different output formats is provided. This framework is provided by the package doctools::toc.
Anyone who wishes to write a toc formatting engine which plugs into this framework has to read the document doctoc_api . This is the formal specification of the API between the framework and its engines.
While doctools is similar to LaTeX doctoc is only superficially so. Input written in this format consists of a series of markup commands, which may be separated by whitespace. Other text is not allowed. The best comparison would be to imagine a LaTeX document with all regular text removed.
The format used to mark commands is different from LaTeX however. All text between matching pairs of [ and ] is a command, possibly with arguments. Note that both brackets have to be on the same line for a command to be recognized.
The overall syntax of a table of contents is best captured in a formal context-free grammar. Our notation for the grammar is EBNF. Strings will stand for markup commands, however their arguments (if they have any) are not part of the grammar. Our grammar contains lexical elements as well.
First we specify the whitespace at the lexical level, which also includes comments.
COMMENT ::= "comment" WHITE ::= { '\n' | '\t' | ' ' | '\r' | COMMENT } |
Then we define rules for all the keywords. Here we introduce our knowledge that all commands can be separated by whitespace, and also that the inclusion of other files may happen essentially everywhere, like the definition of document variables. The content of any included file has to fit into the including file according to the location in the grammar the inclusion is at.
BEGIN ::= "toc_begin" WHITE DEFUN END ::= "toc_end" WHITE DIV_START ::= "division_start" WHITE DEFUN DIV_END ::= "division_end" WHITE DEFUN ITEM ::= "item" WHITE DEFUN INCLUDE ::= "include" WHITE VSET ::= "vset" WHITE DEFUN ::= { INCLUDE | VSET } |
At last we can specify the whole table of contents.
TOC ::= DEFUN BEGIN CONTENTS END CONTENTS ::= (ITEMS | SECTIONS) ITEMS ::= ITEM { ITEM } SECTIONS ::= SECTION { SECTION } SECTION ::= DIV_START CONTENTS DIV_END |
Here we specify the commands used in the grammar. Some commands specified here were not used in the grammar at all. The usage of these commands is confined to the arguments of other commands.
It is possible to generate a table of contents in doctoc format automatically from a collection of documents in doctools format. All is needed is a special doctools formatting engine which extracts the relevant metadata and some glue code to convert this data to doctoc .
The application dtplite is an example for this.
The example is a table of contents for all manpages in the module base64 .
[toc_begin Base64 {Table Of Contents}] [item base64.man base64 {Procedures to encode and decode base64} [item uuencode.man uuencode {encode/decoding a binary file}] [item yencode.man yencode {encode/decoding a binary file}] [toc_end] |
doctoc_api , doctoc_fmt , doctools::toc , doctools_fmt
HTML , LaTeX , TMML , doctoc , documentation , generic markup , keywords , markup , nroff , table of contents , toc
Copyright © 2003-2004 Andreas Kupries
<andreas_kupries@users.sourceforge.net>