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

Handle target-* #604

Merged
merged 58 commits into from
May 1, 2018
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4519ba5
introduce TARGET_COLLECTOR for target-counter, -counters and -text
Tontyna Feb 11, 2018
fed74d1
cleanup code to pass Travis CI check
Tontyna Feb 16, 2018
925466f
cleanup code once more to pass Travis CI check
Tontyna Feb 16, 2018
cce1f39
BugFix: Logging Errors
Tontyna Feb 17, 2018
2b2eebd
Merge branch 'master' into target-counter
Tontyna Feb 25, 2018
087cb3a
cleanup code to pass Travis CI check
Tontyna Feb 25, 2018
d35f455
once again: cleanup code to pass Travis CI check
Tontyna Feb 25, 2018
57f3234
Reduce duplicate code in css validation
Tontyna Feb 26, 2018
71cee36
consolidate (tuples) and [lists]
Tontyna Feb 26, 2018
f68a5fa
Prepare removal of duplicate code
Tontyna Mar 3, 2018
c0c706f
Remove duplicate code: target-* for all
Tontyna Mar 3, 2018
f66c8d0
Merge branch 'master' into target-counter
Tontyna Mar 13, 2018
1c2b9b1
Merge branch 'master' into target-counter
Tontyna Mar 19, 2018
3071432
Merge branch 'master' into target-counter
Tontyna Mar 20, 2018
1ebd36e
Merge branch 'target-counter' of https://github.com/Tontyna/WeasyPrin…
liZe Mar 25, 2018
b60fb46
Get content string from content list
liZe Mar 25, 2018
a6366e3
Clean some docstrings
liZe Mar 25, 2018
21743a8
Remove debug messages and fix some minor typos
liZe Mar 25, 2018
3e5e00f
Clean and remove useless functions
liZe Mar 25, 2018
59a81dc
Don't pre-compute string-set
liZe Mar 25, 2018
c49f302
Merge branch 'master' into target-collector
liZe Mar 27, 2018
9020b4b
Remove intermediate steps logging
liZe Mar 27, 2018
3cdb176
Merge branch 'master' into target-collector
liZe Mar 27, 2018
5c64c2d
Clean docstring
liZe Mar 27, 2018
1039e35
Replace enum by simple string
liZe Mar 27, 2018
07865f6
Don't use a global target collector
liZe Mar 27, 2018
6b43c83
Clean targets.py
liZe Mar 27, 2018
023f66c
Merge branch 'master' into target-collector
liZe Mar 29, 2018
293c01a
Allow optional commas to separate functions arguments
liZe Mar 30, 2018
0a4f2d9
Split validation module
liZe Mar 31, 2018
0eedd2f
Move common image validation functions into utils
liZe Mar 31, 2018
3d915c0
Move and start cleaning content property validation
liZe Mar 31, 2018
85a65d7
Clean CSS functions
liZe Apr 2, 2018
cb4fa7e
Use parentheses at the end of functions keywords
liZe Apr 3, 2018
be71ce2
Handle attr() fallback value
liZe Apr 3, 2018
770e3ec
Fix some fallback values of attr()
liZe Apr 3, 2018
7b76f96
Fix syntax
liZe Apr 3, 2018
4058894
Add perentheses to target-* keywords too
liZe Apr 3, 2018
1386007
Lint
liZe Apr 3, 2018
2be9959
Clean many things about properties validation and computed values
liZe Apr 14, 2018
f960553
Move CSS utils file
liZe Apr 15, 2018
d832e76
Fix get_target and lookup_target
liZe Apr 15, 2018
c49c14c
Clean target collection
liZe Apr 15, 2018
f3f7652
Parse an ident instead of a string as second attr() attribute
liZe Apr 15, 2018
0fc46a5
Fix attr() parsing for url type
liZe Apr 15, 2018
2694cac
Use 'url' keyword everywhere
liZe Apr 15, 2018
0814b06
Add some tests about target-*()
liZe Apr 15, 2018
d2a6833
Always include token type when dealing with URLs
liZe Apr 16, 2018
85b5b76
Fix and add tests about target-counters
liZe Apr 18, 2018
3b1f649
Improve target-counters tests
liZe Apr 18, 2018
f54ab9c
Add tests for target-text
liZe Apr 18, 2018
324ca50
rectify index
Tontyna Apr 22, 2018
72d90ce
Merge pull request #620 from Tontyna/contrib2target
liZe Apr 22, 2018
a4ddcbc
Dont crash when element/target-collector is None
Tontyna Apr 23, 2018
f57cbf3
Merge branch 'master' into target-collector
liZe Apr 30, 2018
b7c5b1c
Merge pull request #621 from Tontyna/contrib2target
liZe Apr 30, 2018
54cf467
Merge branch 'target-collector' of github.com:Kozea/WeasyPrint into t…
liZe Apr 30, 2018
7d79d90
Remove useless comments
liZe Apr 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add some tests about target-*()
liZe committed Apr 15, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 0814b06e7dcdc5a2206aae6678deb1c3ece61835
74 changes: 74 additions & 0 deletions weasyprint/tests/test_target.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
weasyprint.tests.test_target
----------------------------

Test the CSS cross references using target-*() functions.

:copyright: Copyright 2018 Simon Sapin and contributors, see AUTHORS.
:license: BSD, see LICENSE for details.

"""

from .testing_utils import FakeHTML, assert_no_logs


@assert_no_logs
def test_target_counter():
document = FakeHTML(string='''
<style>
div:first-child { counter-reset: div }
div { counter-increment: div }
#id1::before { content: target-counter('#id4', div) }
#id2::before { content: 'test ' target-counter('#id1' div) }
#id3::before { content: target-counter(url(#id4), div, lower-roman) }
#id4::before { content: target-counter('#id3', div) }
</style>
<body>
<div id="id1"></div>
<div id="id2"></div>
<div id="id3"></div>
<div id="id4"></div>
''')
page, = document.render().pages
html, = page._page_box.children
body, = html.children
div1, div2, div3, div4 = body.children
before = div1.children[0].children[0].children[0]
assert before.text == '4'
before = div2.children[0].children[0].children[0]
assert before.text == 'test 1'
before = div3.children[0].children[0].children[0]
assert before.text == 'iv'
before = div4.children[0].children[0].children[0]
assert before.text == '3'


@assert_no_logs
def test_target_counter_attr():
document = FakeHTML(string='''
<style>
div:first-child { counter-reset: div }
div { counter-increment: div }
div::before { content: target-counter(attr(data-count), div) }
#id2::before { content: target-counter(attr(data-count, url), div) }
#id4::before {
content: target-counter(attr(data-count), div, lower-alpha) }
</style>
<body>
<div id="id1" data-count="#id4"></div>
<div id="id2" data-count="#id1"></div>
<div id="id3" data-count="#id2"></div>
<div id="id4" data-count="#id3"></div>
''')
page, = document.render().pages
html, = page._page_box.children
body, = html.children
div1, div2, div3, div4 = body.children
before = div1.children[0].children[0].children[0]
assert before.text == '4'
before = div2.children[0].children[0].children[0]
assert before.text == '1'
before = div3.children[0].children[0].children[0]
assert before.text == '2'
before = div4.children[0].children[0].children[0]
assert before.text == 'c'