Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for CSS leader() #247

Closed
E-M-P-I-R-E opened this issue Mar 20, 2015 · 5 comments · Fixed by #1309
Closed

Support for CSS leader() #247

E-M-P-I-R-E opened this issue Mar 20, 2015 · 5 comments · Fixed by #1309
Labels
feature New feature that should be supported sponsored Issues sponsored to be resolved faster

Comments

@E-M-P-I-R-E
Copy link

Stumbled across this style in the in CSS draft and was hoping some cases might be easy-pickings (I don't really know).

http://dev.w3.org/csswg/css-gcpm/#leaders

From that page

A leader [...] is a repeating pattern used to visually connect content across horizontal spaces.

Example

1. Loomings.....................1
2. The Carpet-Bag...............9
3. The Spouter-Inn.............13
@SimonSapin
Copy link
Member

Unfortunately, this is another part of GCPM that is largely unspecified. It is more of a whishlist than a spec. For example, what happens if the content without leader is more than one line?

@liZe liZe added the feature New feature that should be supported label Apr 25, 2015
@zopieux
Copy link

zopieux commented Jan 22, 2017

The specs seem a bit more clear about multi-line stuff, see eg.:

In this renditon, the User Agen has chosen to move "Adams" to the next line to preserve a visual connection:

|Douglas         |
|Adams.........42|

@pmjdebruijn
Copy link
Contributor

I'd love to see leader support as well, given the importance of proper table of contents in non-trivial documents.

As for line breaking style, any approach with leaders is better than having no leaders at all.

@dannyniu
Copy link

dannyniu commented Apr 1, 2020

Right now I simulate the effect with something similar to this:

<ol class=toc-list><!-- Table of Contents -->
<li><a href="#chapter1">1. Introduction</a></li>
<li><a href="#chapter2">2. Notations and Symbols</a></li>
...
</ol>
@media print
{
  ol.toc-list a {
    display:              inline-block;
    width:                87%;
    position:             relative;
    border-bottom:        dotted; /* can be other styles. */
  }

  ol.toc-list a::after {
    /* There is currently no ``leader()'' support in WeasyPrint. */
    position:     absolute;
    right:        0;
    content:      target-counter(attr(href url), page);
  }
}

@chrislad
Copy link

That's a nice workaround @dannyniu , it looks especially nice with a border width of 0.4.

I've used the solution suggested here: https://www.w3.org/Style/Examples/007/leaders.en.html
It's visually closer to what tables of content usually look like.

/* 80 dots ~= 40em */
ul.leaders {
  max-width: 40em;
  margin-left: 15px;
  margin-top: 2px;  
  margin-bottom: 2px;
  overflow: hidden;
  padding-left: 0;
  padding-top: 0px;
  padding-bottom: 0px;
  list-style: none;
}

ul.leaders li:before {
float: left;
width: 0;
white-space: nowrap;
content:
". . . . . . . . . . . . . . . . . . . . "
". . . . . . . . . . . . . . . . . . . . "
". . . . . . . . . . . . . . . . . . . . "
". . . . . . . . . . . . . . . . . . . . "
}

ul.leaders a:first-child {
  padding-right: 0.33em;
  background: white;
  text-decoration: none;
  color: black;
}

ul.leaders a + a::before {
  float: right;
  padding-left: 0.33em;
  background: white;
  text-decoration: none;
  color: black;
  content: target-counter(attr(href url), page);
} 
<ul class="leaders">
  <li><a href="#chapter01">Chapter 1</a> <a href="#chapter01"></a></li>
  <li><a href="#chapter02">Chapter 2</a> <a href="#chapter02"></a></li>
  <li><a href="#chapter03">Chapter 3</a> <a href="#chapter03"></a></li>
  <li><a href="#chapter04">Chapter 4</a> <a href="#chapter04"></a></li>
</ul>

@liZe liZe added the sponsored Issues sponsored to be resolved faster label Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature that should be supported sponsored Issues sponsored to be resolved faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants