toc

{toc}

Plugin: Table of Contents Plugin

Generate a table of contents based on what headings are present in the current page.

Description

The difference between this and toc-zone is that the this macro will list all headings on the page, while toc-zone will only list those within its body.

Each heading level is indented progressively.

Usage

{toc:type=[list, flat]|outline=[true, false]|style=[style option]|indent=[css quantity]}

Parameters

Name Required Default Description
type
'list'
The type of TOC to output. May be 'list' or 'flat'.
outline
false
If true each item will be prefixed by a hierarcical number (e.g. '1.3').
style
'none'
The style of bullet-point to use for each item. Any CSS styles are valid.
separator
'brackets'
The type of separator when in 'flat' mode. May be any of the following:
  • 'brackets' - Each item is surrounded by square brackets ('[', ']').
  • 'braces' - Each item is surrounded by curly braces ('{', '}').
  • 'parens' - Each item is surrounded by parentheses ('(', ')').
  • 'pipe' - Each item is separated by a pipe ('|').
  • anything - Each item is separated by the value supplied. Nothing is placed on the outsides of the list.
indent
When displayed as a 'list', the amount to indent each heading level. Note: This is a CSS quantity, so make sure you use the quantity type (eg. '10px' not '10').
minLevel
1
The minimum level to report headings for, inclusive. Eg. '2' will list 'h2.' and 'h3.' headings, but not 'h1.'.
maxLevel
7
The maximum level to report headings for, inclusive. Eg. '2' will list 'h1.' and 'h2.' headings, but not 'h3.' or above.
include
If set, any headings not matching the regular expression will be ignored. Due to '|' being the parameter separator in macros, use a comma (',') where you would have usually used '|'. If you need to match a comma, use its escape code - \\x2C.
exclude
If set, any headings which do match the regular expression will be ignored. Due to '|' being the parameter separator in macros, use a comma (',') where you would have usually used '|'. If you need to match a comma, use its escape code - \\x2C.
name
Parameter description goes here.
printable
true
If set to false, the TOC will not be visible when printing.
class
If specified, a <div> surrounding the TOC will be output with the specified 'class' attribute. Use CSS styles to customise the look of the TOC.

Examples

The examples are based on a page with the following basic content:

h1. Level 1
h2. Level 1.1
h3. Level 1.1.1
h2. Level 1.2
h3. Level 1.2.1
h1. Level 2
h2. Level 2.1

Basic Table of Contents

This will list all headings of level 1 or 2 in outline style.

{toc:style=outline|maxLevel=2}

Filtered Table of Contents

This will list all headings that end with '.1' or '.2' as a flat list with each item separated by ' - '. See Sun's Regex documentation for details on how to use this.

{toc:style=flat|separator= - |include=.*\.[1//2]}

See Also

Labels

macro macro Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.