mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 07:57:52 +03:00
Tests for line-clamp
This commit is contained in:
parent
cbc6322022
commit
d8454db295
@ -116,3 +116,70 @@ def test_text_align_rtl_trailing_whitespace():
|
||||
<p style="direction: ltr"> abc </p>
|
||||
<p style="direction: ltr"> ‏abc </p>
|
||||
''')
|
||||
|
||||
|
||||
def test_max_lines_ellipsis():
|
||||
assert_pixels('max_lines_ellipsis', 10, 10, '''
|
||||
BBBBBBBB__
|
||||
BBBBBBBB__
|
||||
BBBBBBBBBB
|
||||
BBBBBBBBBB
|
||||
__________
|
||||
__________
|
||||
__________
|
||||
__________
|
||||
__________
|
||||
__________
|
||||
''', '''
|
||||
<style>
|
||||
@page {size: 10px 10px;}
|
||||
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||
p {
|
||||
block-ellipsis: auto;
|
||||
color: blue;
|
||||
font-family: weasyprint;
|
||||
font-size: 2px;
|
||||
max-lines: 2;
|
||||
}
|
||||
</style>
|
||||
<p>
|
||||
abcd efgh ijkl
|
||||
</p>
|
||||
''')
|
||||
|
||||
|
||||
def test_line_clamp():
|
||||
assert_pixels('line_clamp', 10, 10, '''
|
||||
BBBBBBBB__
|
||||
BBBBBBBB__
|
||||
BBBBBBBB__
|
||||
BBBBBBBB__
|
||||
BBBBBBBBBB
|
||||
BBBBBBBBBB
|
||||
__________
|
||||
__________
|
||||
__________
|
||||
__________
|
||||
''', '''
|
||||
<style>
|
||||
@page {size: 10px 10px;}
|
||||
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||
p {
|
||||
color: blue;
|
||||
font-family: weasyprint;
|
||||
font-size: 2px;
|
||||
line-clamp: 3 "(…)";
|
||||
}
|
||||
</style>
|
||||
|
||||
<p>
|
||||
aaaa
|
||||
bbbb
|
||||
cccc
|
||||
dddd
|
||||
eeee
|
||||
ffff
|
||||
gggg
|
||||
hhhh
|
||||
</p>
|
||||
''')
|
||||
|
@ -1050,3 +1050,55 @@ def test_text_floating_pre_line():
|
||||
<div style="float: left; white-space: pre-line">This is
|
||||
oh this end </div>
|
||||
''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_max_lines():
|
||||
page, = render_pages('''
|
||||
<style>
|
||||
@page {size: 10px 10px;}
|
||||
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||
p {
|
||||
font-family: weasyprint;
|
||||
font-size: 2px;
|
||||
max-lines: 2;
|
||||
}
|
||||
</style>
|
||||
<p>
|
||||
abcd efgh ijkl
|
||||
</p>
|
||||
''')
|
||||
html, = page.children
|
||||
body, = html.children
|
||||
p, = body.children
|
||||
line1, line2 = p.children
|
||||
text1, = line1.children
|
||||
text2, = line2.children
|
||||
assert text1.text == 'abcd'
|
||||
assert text2.text == 'efgh'
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_continue():
|
||||
page, = render_pages('''
|
||||
<style>
|
||||
@page {size: 10px 4px;}
|
||||
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||
div {
|
||||
continue: discard;
|
||||
font-family: weasyprint;
|
||||
font-size: 2px;
|
||||
}
|
||||
</style>
|
||||
<div>
|
||||
abcd efgh ijkl
|
||||
</div>
|
||||
''')
|
||||
html, = page.children
|
||||
body, = html.children
|
||||
p, = body.children
|
||||
line1, line2 = p.children
|
||||
text1, = line1.children
|
||||
text2, = line2.children
|
||||
assert text1.text == 'abcd'
|
||||
assert text2.text == 'efgh'
|
||||
|
Loading…
Reference in New Issue
Block a user