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; }

Details

Related Gerrit Patches:

Event Timeline

Thgoiter created this task.Mar 12 2015, 7:17 AM
Thgoiter raised the priority of this task from to Needs Triage.
Thgoiter updated the task description. (Show Details)
Thgoiter added a subscriber: Thgoiter.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 12 2015, 7:17 AM
Thgoiter updated the task description. (Show Details)Mar 12 2015, 8:01 AM

This is not a parser issue.

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:

After:

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.
Krinkle moved this task from Triaged to For Review on the Design board.Nov 1 2015, 11:22 PM

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

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

Jdforrester-WMF closed this task as Resolved.Nov 3 2015, 2:03 AM
Jdforrester-WMF claimed this task.
Fomafix claimed this task.Nov 5 2015, 12:02 PM
Fomafix removed a project: Patch-For-Review.
TheDJ added a subscriber: TheDJ.Nov 6 2015, 7:41 PM

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

TheDJ added a comment.Nov 7 2015, 1:45 PM

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.

TheDJ added a comment.Nov 8 2015, 3:15 PM

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

@TheDJ Can you give an example?

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

GOIII added a subscriber: GOIII.EditedNov 18 2015, 1:44 AM

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