Fix#437.
Backward-incompatible change: the signature of weasyprint.urls.url_join has
changed to allow relative links without a base URI.
This feature doesn't look really safe at first sight, but I can't find
anything bad coming from these changes. If there's a bug, I take the blame.
Traceback (most recent call last):
[...]
File "/app/env/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 718, in split_text_box
'Expected nothing or a preserved line break' % (between,))
AssertionError: Got '1,' between two lines. Expected nothing or a preserved line break
The Assertion Error can be triggered with following minimal test case
(Adobe's Source Sans Pro font must be installed):
<style type="text/css">
p {
font-family: 'Source Sans Pro';
font-size: 24pt;
width: 275pt;
overflow-wrap: break-word;
}
</style>
<p>W1D1,W1D7,W2D14,W3D21,W4D28</p>
With the Adobe Source Sans Font the pango line wrapping algorithm
sometimes produces sporadic results. The wrapping seems to be dependent
on the following text, so that a short text doesn't "fit" on a line, but
does if it is followed by more text. This can be worked around in the
split_first_line() function by computing the resume offset at a later
point, so it is in sync with the actual wrapping behaviour.
See https://bugzilla.gnome.org/show_bug.cgi?id=777093.
As ::first-letter depends on white space handling, we must create the
box after collapsing spaces, not during the build of the box tree.
This commit makes WeasyPrint pass most of the W3C tests related to
first-letter (and never crash). Known problems left include:
- list markers are considered as the first letter,
- lines may break between the first letter and the rest of the text
(see #163 and #301),
- the CSS attributes are all kept, some should probably be removed (the
spec doesn't give a whole list).
Even if W3C tests makes me quite confident (some of them are crazy),
tests must be added in WeasyPrint too.
Python's tempfile.mkstemp already opens files, we don't have to open
them twice. The documentation is not really clear about that but
there's a good post on Logilab's blog: https://www.logilab.org/17873Fix#396.
It's funny but:
```
pip install --upgrade 'CairoSVG<2'
```
would pull CairoSVG-2.0.0rc6, while
```
pip install --upgrade 'CairoSVG<2.0.0'
```
would pull the 1.x branch (1.0.22 at time of writing).