User:Arcorann/TOCstyle

From Wikisource
Jump to navigation Jump to search

Current models[edit]

  1. D: description only
  2. DP: description then page number 2
  3. H5P: Wide hanging description (2nd line onwards indented by 5em), then page number (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.) 3
  4. 2H3P: Indented hanging description (1st line indented by 2em, 2nd line by 2+3 em) then page number (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.) 4
  5. CDPChapter number, description, page number 5
  6. D.P: Description with dot leader, then page
    ................................................................................................................................................................................................................................................................................................................................................................................................
    6
  7. D?P: Description with custom symbol leader, then page
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    7
  8. CD.P
    Chapter number, description with dot leader, page number
    ................................................................................................................................................................................................................................................................................................................................................................................................
    8
  9. C5D.P
    Chapter number, description with dot leader (backdented, page number
    ................................................................................................................................................................................................................................................................................................................................................................................................
    9
  10. 2CD.P
    Chapter number (indented 2em), description with dot leader, page number
    ................................................................................................................................................................................................................................................................................................................................................................................................
    10
  11. CH2.P
    ("Chapter, Large-hanging-indented description, dot-leader, Page") Output row is constructed from triples of input fields. The first field is presented as right-aligned within a minimum-width (4em) column, followed by a description field with 2em hanging indent and standard dot-leader trailing. Finally the third field is presented right-lower-aligned.
    ................................................................................................................................................................................................................................................................................................................................................................................................
    11
  12. mCHn.pP
    ("Generalised-depth/width" variant) of CH2.P above. Associated with chapter-width (default 5em, 4em in Ch2.P), depth (hanging indent, default 5em) and page-width (default 2em)
    ................................................................................................................................................................................................................................................................................................................................................................................................
    12
  13. CD.uP
    Variant of CD.P but the page number is undercut, so that the description extends into the page number column if necessary (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)13
    ................................................................................................................................................................................................................................................................................................................................................................................................
  14. mCHn.upP
    Undercut variant of mCHn.pP14
    ................................................................................................................................................................................................................................................................................................................................................................................................
  15. H5.P: H5P but with a dot leader
    ................................................................................................................................................................................................................................................................................................................................................................................................
    15
  16. Hn.P: Generalised depth versino of H5.P; associated with depth (default 5em)
    ................................................................................................................................................................................................................................................................................................................................................................................................
    16
  17. Hn.upP: Undercut version of Hn.P; associated with depth (default 5em) and page-width (default 2em)16
    ................................................................................................................................................................................................................................................................................................................................................................................................
  18. 2H3.P: 2H3P but with a dot leader (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)
    ................................................................................................................................................................................................................................................................................................................................................................................................
    18
  19. lrright
  20. lcrcentreright
  21. lccrcentrecentreright
  22. lcccrcentrecentrecentreright
  23. l: left aligned
  24. c: centre aligned
  25. r: right aligned
  26. j: justified text (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)
  27. h: single hanging (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)
  28. 7h2: hanging, but with clearances on the left and right (Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.)

Models that really should be covered[edit]

Comparisons of several different TOC templates[edit]

  • TOC line series:
    • One row at a time
    • Rarely seen.
  • TOC page listing series:
    • One row at a time, with or without dot leaders. Mixes table and div syntax.
    • Mostly deprecated, but still in use in some places.
  • TOC row series:
    • Reasonably versatile series, can be used for 3 or 4 column table layouts. Also can do ragged.
    • In common use.
  • TOCstyle:
    • Single template with many formats, Lua-based.
    • Adding formats is non-obvious (largely because the naming scheme is non-obvious...)
    • Outputs a weird structure (tables nested inside a list?)
  • SimpleTOC:
    • Uses a simple formatted div
    • Sometimes used for indices.
  • Raw table + index CSS:
    • Index CSS allows column formatting using nth-child(k)
    • Reasonably clean
  • es:Plantilla:Índice con puntos ()
    • One fixed 3-column model
    • Has autolinking
    • In Spanish

Various works[edit]

(add one that uses pure table and index CSS here)

Sample output code[edit]

Input:

{{TOC line|I.|[[Literary Lapses/My Financial Career|{{sc|My Financial Career}}]]|9}}
{{Dotted TOC line|XXXVIII.|[[Wikisource:Sandbox|{{sc|Sandbox}}]]|678}}

Output:

<table style="width:100%;">
<tr>
<td style="width:2.5em; max-width:2.5em; padding:0.0em 0.5em 0.0em 0.0em; vertical-align:top; text-align:right;">I.</td>
<td>
<div style="position:relative; width:100%;">
<div style="max-width:80%; text-align:left; text-indent:-1.0em; margin-left:1.0em;">
<div style="display:inline; position:relative; text-align:left; padding:0.0em 0.5em 0.0em 0.0em; background:transparent; z-index:2;">[[Literary Lapses/My Financial Career|<span class="smallcaps"  style="font-variant:small-caps;">My Financial Career</span>]]</div>
</div>
<div style="position:absolute; left:0px; bottom:0px; width:1.0em; height:0.75em; background:transparent; z-index:1;"></div>
<div style="position:absolute; right:0px; bottom:0px; width:100%; overflow:hidden; white-space:nowrap; text-align:right; z-index:0;"><div style="display:inline;float:left;width:0.0em;padding:0px 0px 0px 0px;white-space:nowrap;letter-spacing:inherit;"></div>
</div>
</div>
</td>
<td style="text-align:right; vertical-align:bottom; padding:0.0em 0.0em 0.0em 0.5em; width:2.0em;">9</td>

</tr>
</table>
<templatestyles src="Dotted TOC line/styles.css"/><table class="toc-line dotted-toc-line" >
<tr>
<td class="toc-line-chapter-text" style="">XXXVIII.</td>
<td class="toc-line-entry" >
<div class="toc-line-entry-inner">
<div class="toc-line-entry-text-outer" style="">
<div class="toc-line-entry-text" >[[Wikisource:Sandbox|<span class="smallcaps"  style="font-variant:small-caps;">Sandbox</span>]]</div>
</div>
<div class="toc-line-entry-text-space ws-noexport" style=""></div>
<div class="toc-line-dots-outer ws-noexport"><div class="toc-line-dots" >....................................................................................................................................................................................................................................................</div>
</div>
</div>
</td>
<td class="toc-line-page" style="">678</td>

</tr>
</table>

Render:

I. 9
XXXVIII.
Sandbox
....................................................................................................................................................................................................................................................
678

Input:

{{dotted TOC page listing|I.|[[Literary Lapses/My Financial Career|{{sc|My Financial Career}}]]|9}}

Output:

<templatestyles src="Dotted TOC page listing/styles.css" />
{| class="ws-summary wst-dtpl  "
| class="wst-dtpl_chaptertext"  | I.
|<div style="position:relative; width:100%;"><div style="max-width:80%; text-align:left; text-indent:-1.0em; margin-left:1.0em;"><div class="toc-line-entry-text wst-dtpl-background" style="display:inline; position:relative; text-align:left; padding:0.0em 0.5em 0.0em 0.0em;  z-index:2;">[[Literary Lapses/My Financial Career|<span class="smallcaps"  style="font-variant:small-caps;">My Financial Career</span>]]</div></div><div class="ws-noexport wst-dtpl-background" style="position:absolute; left:0px; bottom:0px; width:1.0em; height:1.00em;  z-index:1;"></div><div class="ws-noexport" style="position:absolute; right:0px; bottom:0px; width:100%; overflow:hidden; white-space:nowrap; text-align:right; z-index:0;"><div style="display:inline; float:right;">. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .</div></div></div>
|style="text-align:right; vertical-align:bottom; padding:0.0em 0.0em 0.0em 0.5em; width:2.0em;" | 9
|}

Input:

{{TOC begin}}
{{TOC row 1-1-1|I.|[[Literary Lapses/My Financial Career|{{sc|My Financial Career}}]]|9}}
{{TOC row 1-dot-1|XXXVIII.|[[Wikisource:Sandbox|{{sc|Sandbox}}]]|678}}
{{TOC end}}

Output:

<templatestyles src="TOC templates/styles/sandbox.css" />
{| class="ws-summary __toc_table wst-toc-table wst-toc-table-align-center "  

<templatestyles src="TOC templates/styles.css" />
|- class="__toc_row_1-m-1 __toc_row_1-1-1 wst-toc-row-1-1-1 " style=""
|I.
|[[Literary Lapses/My Financial Career|<span class="smallcaps"  style="font-variant:small-caps;">My Financial Career</span>]]
|9
<templatestyles src="TOC templates/styles.css" />
|- class="__toc_row_1-m-1 __toc_row_1-dot-1 wst-toc-row-1-dot-1 "
|  | XXXVIII. 
| <div class="wst-toc-dotcell"><div style="text-align:left; text-indent:-1.5em; margin-left:1.5em;"><div class="toc-line-entry-text wst-toc-dot-bg wst-toc-dotentry" >[[Wikisource:Sandbox|<span class="smallcaps"  style="font-variant:small-caps;">Sandbox</span>]]</div></div><div class="ws-noexport wst-toc-dot-bg wst-toc-dotempty" style="width:1.5em;"></div><div class="ws-noexport wst-toc-dotouter"><div class="wst-toc-dotinner">.     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .</div></div></div> 
|  | 678

|}

Render:

I. My Financial Career 9
XXXVIII.
.     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .     .
678

Input:

{{TOCstyle|model=CDP|row2model=CD.P
|I.|[[Literary Lapses/My Financial Career|{{sc|My Financial Career}}]]|9
|XXXVIII.|[[Wikisource:Sandbox|{{sc|Sandbox}}]]|678}}

Output:

<div class="table-of-contents ws-summary" style="max-width:100%; margin:0; padding:0;"><ol style="list-style:none;margin:0; padding:0;"><li style="margin:0; padding:0;"><table style="border-collapse:collapse;border-spacing:0 0;display:inline-table;vertical-align:middle;width:100%;"><tr><td style="padding-right:1em;white-space:nowrap;width:5em;text-align:right;vertical-align:top;">I.</td><td>[[Literary Lapses/My Financial Career|<span class="smallcaps"  style="font-variant:small-caps;">My Financial Career</span>]]</td><td style="white-space:nowrap;width:2em;text-align:right;vertical-align:bottom;">9
</td></tr></table></li><li style="margin:0; padding:0;"><table style="border-collapse:collapse;border-spacing:0 0;display:inline-table;vertical-align:middle;width:100%;"><tr><td style="padding-right:1em;white-space:nowrap;width:5em;text-align:right;vertical-align:top;">XXXVIII.</td><td style="position:relative;"><div style="text-align:justify;"><span style="background:white;padding:0 0.5em 0 0;position:relative;text-align:justify;z-index:2;">[[Wikisource:Sandbox|<span class="smallcaps"  style="font-variant:small-caps;">Sandbox</span>]]</span></div><div class="ws-noexport" style="overflow:hidden;position:absolute;right:0;bottom:0;text-align:right;white-space:nowrap;width:100%;z-index:0;"><span style="float:left;letter-spacing:4px;">................................................................................................................................................................................................................................................................................................................................................................................................</span></div></td><td style="white-space:nowrap;width:2em;text-align:right;vertical-align:bottom;">678</td></tr></table></li></ol></div>

Render:

  1. I.My Financial Career9
  2. XXXVIII.
    ................................................................................................................................................................................................................................................................................................................................................................................................
    678

Input:

{{ICP|I.|[[Literary Lapses/My Financial Career|{{sc|My Financial Career}}]]|9
|XXXVIII.|[[Wikisource:Sandbox|{{sc|Sandbox}}]]|678}}

Output (on esWS):

<templatestyles src="Plantilla:Índice con puntos/estilo.css" /><table class="ws-summary" style="margin-right:auto;border-collapse:collapse;empty-cells:hide;font-size:100%;border-spacing:0;margin-left:auto;width:100%"><tr><td style="text-align:right;max-width:2.5em;padding:0.0em 0.5em 0.0em 0.0em;vertical-align:middle;width:2.5em">I.</td><td colspan="1"><div class="icp1"><span class="icpito"> </span><span class="icp2">[[Literary Lapses/My Financial Career|<div id="" class="ws-sangria-colgante" >My Financial Career</div>]]</span><span class="icp3 ws-noexport">........................................................................................................................................................................................................</span><span class="icp4"> </span></div></td><td style="vertical-align:bottom;padding-left:1em;text-align:right;width:2.0em">9
</td></tr><tr><td style="text-align:right;max-width:2.5em;padding:0.0em 0.5em 0.0em 0.0em;vertical-align:middle;width:2.5em">XXXVIII.</td><td colspan="1"><div class="icp1"><span class="icpito"> </span><span class="icp2">[[Wikisource:Sandbox|<div id="" class="ws-sangria-colgante" >Sandbox</div>]]</span><span class="icp3 ws-noexport">........................................................................................................................................................................................................</span><span class="icp4"> </span></div></td><td style="vertical-align:bottom;padding-left:1em;text-align:right;width:2.0em">678</td></tr></table>

Proposals[edit]

  • Autolink: link chapter titles and/or page numbers automatically
  • Auto small caps
  • "TOCstyle simple", or something of that sort: for common models with a header row

Hypothetical replacement[edit]

Or: xkcd 927 time.

  • Table or div-based. None of this tables-wrapped-inside-an-ul crap (seriously why TOCstyle)
    • Probably
  • Indent things like ppoem does
  • Autolink, as above
  • Presets
  • Class-based formatting for column types (chapter num, title, description, page num)