WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

Long TOC entries wraps around

Open kgish opened this issue 2 years ago • 2 comments

For my TOC I used the book example, which works great.

However, when the header is too long, it wraps down across to form an extra line.

How can I prevent this from happening, either by truncating it somehow (with an ellipsis) or whatever?

kgish avatar Sep 06 '23 11:09 kgish

Hi!

You can use the text-overflow property for that:

<style>
  div {
    border: 1px solid;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: pre;
    width: 8em;
  }
</style>
<div>lorem ipsum dolor sit amet</div>

liZe avatar Sep 08 '23 09:09 liZe

@kgish sidenote, you'll rarely if ever find something like this in a published work, so possibly reworking header titles might be the better option.

pmjdebruijn avatar Sep 08 '23 09:09 pmjdebruijn