Page MenuHomePhabricator

Line break and indent for long entries in TOC
Closed, ResolvedPublic

Description

When long entries in TOC are wrapped, the second line should be indented.

Example: https://de.wikipedia.org/wiki/Baltikum (reduce window size until section 4.4 in TOC is wrapped)
4.4 Okkupation und Zwangseingliederung in die Sowjetunion
1940 bis 1990

Second line should be in line with "Okkupation".
4.4 Okkupation und Zwangseingliederung in die Sowjetunion
1940 bis 1990

(LaTeX does so, too. Example)

Proposed code change in dewiki:
#toc li { text-indent: -2em; padding-left: 2em; }

Event Timeline

Thgoiter raised the priority of this task from to Needs Triage.
Thgoiter updated the task description. (Show Details)
Thgoiter subscribed.
Aklapper triaged this task as Lowest priority.Mar 12 2015, 1:52 PM

Better solution:

.tocnumber {
	display: table-cell;
	padding-right: 0.5em;
}
.toctext {
	display: table-cell;
}

Change 196541 had a related patch set uploaded (by Gerrit Patch Uploader):
TOC: Separate columns for tocnumber and toctext

https://gerrit.wikimedia.org/r/196541

Screenshots with Firefox

Before:

T92481_before.png (127×800 px, 8 KB)

After:

T92481_after.png (122×802 px, 7 KB)

Krinkle moved this task from Incoming to For Review on the Design board.
Krinkle moved this task from For Review to Incoming on the Design board.
Krinkle moved this task from Incoming to Stalled/More Info Needed on the Design board.

Change 196541 merged by jenkins-bot:
TOC: Separate columns for tocnumber and toctext

https://gerrit.wikimedia.org/r/196541

If users have underlining for links enabled in their preferences, and are using Firefox (maybe other browsers too), the table-cell styling of the inner span's is blocking inheritance of the underline styling from the links apparently.

I see some info on MDN, indicating that this is quirks mode behavior (or at least was at some point). Adding text-decoration: inherit to the same lines would restore normal behavior.

Change 251565 had a related patch set uploaded (by Gerrit Patch Uploader):
TOC: Workaround for missing underlines in Firefox

https://gerrit.wikimedia.org/r/251565

http://www.sitepoint.com/web-foundations/text-decoration-css-property/

Any text decoration setting on a descendant box can never “undo” the text decorations of an ancestor box.

Paraphrasing from http://stackoverflow.com/posts/4377895/revisions

For any browser except IE: just add display:table; to the child's style to cancel out an ancestor's text-decoration. For some reason in FF you can use any of table, block, list-item or table-caption but these don't work in Safari/Chrome.

But then it's either a bug, or no longer a quirks mode thing as far as I can tell. Been trying to find more clues in the specs, but haven't been able to find any confirmation one way or the other.

Setting table-caption also has significant side effects if someone wrapped the TOC inside a table...
Perhaps we should just revert...

The problem of increased spacing when TOC is in a table can mitigated by D135.

Setting table-caption also has significant side effects if someone wrapped the TOC inside a table...
Perhaps we should just revert...

I'm all for that. This "solution" was poorly conceived first because span.tocnumber and span.toctext are both wrapped by a single <a href=#...> anchor tag (all inline level elements) to begin with plus the overlooked additional pseudo ::after entry inserting a "space" between those two spans set to display:inline-block. Please refer to the following to see this illustrated in html.

<div class="toc" id="toc">
<div id="toctitle">
  <h2>Contents</h2>
  <span class="toctoggle">&nbsp;[<a id="togglelink" href="#">hide</a>]&nbsp;</span>
</div>
<ul>
<li class="toclevel-1 tocsection-1">
  <a href="#Copy_and_paste_table_using_VE">
    <span class="tocnumber">1</span> <span class="toctext">Copy and paste table using VE</span>
  </a>
</li>
<li class="toclevel-1 tocsection-2">
  <a href="#Help_in_fixing_a_cite_error">
    <span class="tocnumber">2</span> <span class="toctext">Help in fixing a cite error</span>
  </a>
</li>
. . .
</ul>
</div>

Changing the display behavior of the spans to table cells "splits" the anchor and violates the spec. -- if anything the anchor should be re-defined as either display: table-row or maybe even display: inline-table.

The bigger problem with the change to display:table-cell is the space between the spans being generated by...

.tocnumber::after {
    content: " ";
    display: inline-block;
    width: 0.5em;
}

That - in effect - makes the composition of the "faux table row" (the <a> anchor) a table-cell (span.tocumber), an inline block (the space inserted ::after span.tocnumber) and another table-cell (span.toctext). All three should be inline and/or inline-blocks OR all table-cells using 3 spans instead of two (dropping the ::after insertion for parser generation of a middle [3rd] span).

I have other points with the css for .toc/#toc but they aren't directly related to the problems introduced with the change to table-cell 'display'

Change 251565 merged by jenkins-bot:
TOC: Restore missing underlines in Firefox

https://gerrit.wikimedia.org/r/251565