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 footnotes #1509

Merged
merged 37 commits into from Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
88e589b
Allow the "footnote" value for "float"
liZe Nov 15, 2021
75e3435
Remove footnotes from the flow
liZe Nov 15, 2021
20fdc45
Replace footnotes by footnote-calls
liZe Nov 15, 2021
da1cd5e
Create and update footnote counter
liZe Nov 15, 2021
b36671b
Allow CSS to set properties for footnote-call pseudo-elements
liZe Nov 15, 2021
1c3fd97
Store footnotes in the layout context
liZe Nov 19, 2021
fe5fa64
Display footnotes at the bottom of the page
liZe Nov 23, 2021
9f61ce9
Put markers in footnotes
liZe Nov 23, 2021
2da0a6c
Update vertical max position when displaying footnotes
liZe Nov 23, 2021
c90886c
Don’t crash when footnote area has no style
liZe Nov 23, 2021
b633bef
Fix footnote style test condition
liZe Nov 26, 2021
a3b7f7f
Display footnotes on the next page when they don’t fit
liZe Nov 27, 2021
6a9dac4
Replace max_position_y by bottom_space
liZe Nov 27, 2021
36b7452
Insert footnotes after the layout of each line
liZe Nov 27, 2021
f5e520e
Don’t use AnonymousStyle, because it’s not computed style
grewn0uille Nov 29, 2021
8f60b81
Add style for footnotes testing
grewn0uille Nov 29, 2021
b5d3475
Fix current position tested when footnotes are added
liZe Nov 29, 2021
e6da2c9
Merge branch 'footnotes' of github.com:Kozea/WeasyPrint into footnotes
grewn0uille Nov 29, 2021
d42b0fa
Some footnotes tests
grewn0uille Nov 29, 2021
c5f03c2
More footnotes tests
grewn0uille Nov 30, 2021
dfc3d0a
Remove useless import
grewn0uille Dec 4, 2021
6f190a2
Add missing underlines and empty strings
liZe Dec 7, 2021
7aa0860
Make footnote call’s style inherit from the footnote’s parent
liZe Dec 7, 2021
232d9ef
Don’t test twice that footnotes are in the list
liZe Dec 7, 2021
313a09d
Handle footnote-display
liZe Dec 7, 2021
a702292
Fix inline footnotes test
liZe Dec 8, 2021
ed0916d
Fix more tests for footnotes
liZe Dec 8, 2021
5e6b21c
Fix last tests for footnotes
liZe Dec 8, 2021
7c8c291
Add reported footnote test
grewn0uille Dec 8, 2021
7126f1b
Remove useless color from tests
liZe Dec 8, 2021
f54da35
Report footnotes when previous footnotes are already reported
liZe Dec 8, 2021
8cc6b25
Handle footnote-policy
liZe Dec 9, 2021
d457486
Use the margin height to translate the footnote_area
liZe Dec 9, 2021
1800bb5
Add test for footnotes margins
liZe Dec 9, 2021
3f596ce
Fix footnotes for repaginated documents
liZe Dec 10, 2021
21484fa
Merge branch 'master' into footnotes
liZe Dec 11, 2021
87e4765
Update documentation
liZe Dec 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions docs/api_reference.rst
Expand Up @@ -391,16 +391,19 @@ to their position in the document:
You can also use `running elements`_ to put HTML boxes into the page margins
(but the ``start`` parameter of ``element()`` is not supported).

The other features of GCPM are **not** implemented:
Footnotes_ are supported. You can put a box in the footnote area using the
``float: footnote`` property. Footnote markers and footnote calls can be
defined using the ``::footnote-marker`` and ``::footnote-call``
pseudo-elements. You can also change the way footnotes are displayed using the
``footnote-display`` property (``compact`` is not supported), and influence
over the rendering of difficult pages with ``footnote-policy``.

- footnotes (``float: footnote``, ``footnote-display``, ``footnote`` counter,
``::footnote-call``, ``::footnote-marker``, ``@footnote`` rule,
``footnote-policy``);
- page groups (``:nth(X of pagename)`` pseudo-class).
Page groups (``:nth(X of pagename)`` pseudo-class) are not supported.

.. _CSS Generated Content for Paged Media Module: http://www.w3.org/TR/css-gcpm-3/
.. _Page selectors: https://www.w3.org/TR/css-gcpm-3/#document-page-selectors
.. _running elements: https://www.w3.org/TR/css-gcpm-3/#running-elements
.. _Footnotes: https://www.w3.org/TR/css-gcpm-3/#footnotes

CSS Generated Content Module Level 3
++++++++++++++++++++++++++++++++++++
Expand Down
134 changes: 134 additions & 0 deletions tests/draw/test_footnotes.py
@@ -0,0 +1,134 @@
"""
weasyprint.tests.test_draw.test_footnotes
-----------------------------------------

Test how footnotes are drawn.

"""

from ..testing_utils import assert_no_logs
from . import assert_pixels


@assert_no_logs
def test_inline_footnote():
assert_pixels('span_footnote', 9, 7, '''
RRRRRRRR_
RRRRRRRR_
_________
_________
_________
RRRRRRRR_
RRRRRRRR_
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 7px;
background: white;
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
span {
float: footnote;
}
</style>
<div>abc<span>de</span></div>''')


@assert_no_logs
def test_block_footnote():
assert_pixels('div_footnote', 9, 7, '''
RRRRRRRR_
RRRRRRRR_
_________
_________
_________
RRRRRRRR_
RRRRRRRR_
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 7px;
background: white;
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div.footnote {
float: footnote;
}
</style>
<div>abc<div class="footnote">de</div></div>''')


@assert_no_logs
def test_long_footnote():
assert_pixels('long_footnote', 9, 7, '''
RRRRRRRR_
RRRRRRRR_
_________
RRRRRRRR_
RRRRRRRR_
RR_______
RR_______
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 7px;
background: white;
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
span {
float: footnote;
}
</style>
<div>abc<span>de f</span></div>''')


@assert_no_logs
def test_footnote_margin():
assert_pixels('footnote_margin', 9, 7, '''
RRRRRRRR_
RRRRRRRR_
_________
_________
_RRRRRR__
_RRRRRR__
_________
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 9px 7px;
background: white;

@footnote {
margin: 1px;
}
}
div {
color: red;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
span {
float: footnote;
}
</style>
<div>abc<span>d</span></div>''')
2 changes: 1 addition & 1 deletion tests/layout/test_block.py
Expand Up @@ -708,7 +708,7 @@ def test_box_decoration_break_slice_bottom_padding(): # pragma: no cover
# break between a parent and its last child, put last child on next page.
# TODO: at the end of block_container_layout, we should check that the box
# with its bottom border/padding doesn't cross the bottom line. If it does,
# we should re-render the box with a max_position_y including the bottom
# we should re-render the box with a bottom_space including the bottom
# border/padding.
page_1, page_2 = render_pages('''
<style>
Expand Down