Template:TOC limit/doc

From Settlement AtWork Wiki
Jump to: navigation, search


This template inserts a Table of Contents which omits subheadings beyond a certain depth. The table obeys the same layout rules as the __TOC__ magic word. Omitted sections still have section edit links in the article body; the main use for this template is situations where you want section edit links for ease of editing but don't want to clutter the table of contents.

Usage

{{TOC limit}}

The template defaults to including only the first- and second-level headings, i.e. those numbered "1" and "1.1" in the TOC.

You can specify a different limit by adding a header level:

{{TOC limit|4}}

4 allows for third-level headings, i.e. "1.1.1", but omits any subheadings below that from the TOC.

The template works by hiding the lower levels with CSS. See MediaWiki:Common.css.

A suggested alternative is {{TOChidden}}.

TOC levels versus wikitext header levels

The heading levels in the TOC normally correspond to the header levels in the wikitext, so a "== Level-2 header ==" will normally generate the first-level ("1") TOC headings, a "=== Level-3 header ===" will normally generate the second-level ("1.1") TOC headings, and so on. This correspondence does not hold if the page contains "= Level-1 headers =" or skips header levels. For example, wikitext like this:

 == Level-2 heading (A) ==
 === Level-3 heading (B) ===
 == Level-2 heading (C) ==
 ====== Level-6 heading (D) ======
 = Level-1 heading (E) =
 == Level-2 heading (F) ==
 === Level-3 heading (G) ===

will generate a TOC like this:

Contents
  • 1 Level-2 heading (A)
    • 1.1 Level-3 heading (B)
  • 2 Level-2 heading (C)
    • 2.1 Level-6 heading (D)
  • 3 Level-1 heading (E)
    • 3.1 Level-2 heading (F)
      • 3.1.1 Level-3 heading (G)

Using {{TOC limit}} on this page would not hide header D, because even though it is a level-6 heading it is shown at the second level in the TOC. And it would hide header G even though it is a level-3 heading just like header B, because header G is shown at the third level in the TOC while header B is shown at the second level.

Conflicts

This template does not interact well with the {{TOC right}}, {{TOC left}}, {{TOC center}} templates. To achieve the correct effect, use those with a limit parameter. For example, {{TOC right|limit=2}} has the effect that {{TOC right}} and {{TOC limit|2}} would have—if they worked together.
http://wiki.settlementatwork.org/index.php?title=Template:TOC_limit/doc
wiki.settlementatwork.org
crawl=CC-MAIN-2020-10
20918
application/http; msgtype=response
sha1:LEDQOMSUQQP7JFPAXY3KAM3WKKGGW2I2
<urn:uuid:ef3cc1c2-346b-48a2-814f-d707031c3fe9>
2020-02-28T14:39:54Z
109.199.103.115
text/html
sha1:WNVXDHOIN43XQ6NULOW3ASXMN6PY2QI5
<urn:uuid:77573065-7536-4380-9086-f978669c44b9>
http://wiki.settlementatwork.org/index.php?title=Template:TOC_limit/doc
response
<urn:uuid:c61d94ab-a408-4214-892f-bc7a4c6040b3>
isPartOf: CC-MAIN-2020-10
publisher: Common Crawl
description: Wide crawl of the web for February 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-180.ec2.internal
software: Apache Nutch 1.16 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/