New Feature: leader()
A new feature, leader()
, has been added in WeasyPrint 🎉.
leader()
has been added thanks to the financial
support of Simonsoft. It has been
a real pleasure to develop this feature with them.
You would love to get a new feature, a bug fix, or some support on WeasyPrint? Don’t hesitate to get in touch with us! Or if you simply want to see the project grow beautifully, you can donate on OpenCollective 😉.
What is leader()
and how to use it?
A leader is a repeating pattern used to visually connect content across horizontal spaces, like in tables of contents for example.
The function leader()
is a possible value of the
content
property and creates leaders. You can have "."
leaders, "_" leaders, " " leaders or any string you want as
leader!
Using this function replaces the hack which consists in adding dots manually in the content property.
Limitations and testing
There are currently some limitations. Indeed, the behaviour of
leader()
may be undefined when the width
is not defined, or the leader string is larger than the box or if there
are several leaders for the same line.
As long as the containing box width is defined, leader()
works, even with RTL text:
or with floating elements around:
The leader()
feature has been developed exclusively for the
pydyf version and won’t be backported to the Cairo version. That’s a
good reason to give a try to the master branch
if not already done 😉.