Skip to content

Commit dfbb26c

Browse files
authored
Test for table with user css (#50)
1 parent e2e533e commit dfbb26c

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

tests/test/test_tables.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""Tables related.
2+
3+
make test T=test_tables.py
4+
"""
5+
from . import TestBase
6+
7+
8+
class TestTables(TestBase):
9+
"""Tables content."""
10+
11+
def test_table(self):
12+
"""Convert table content to html."""
13+
from markdown_pdf import Section, MarkdownPdf
14+
15+
text = """
16+
I have some tables content in bellow, but after generate pdf file, table not appear.
17+
| Description | Qty | Unit price | Amount |
18+
|-----------------------------|-----|------------|-----------|
19+
| Premium Plan | 1 | €1,000.00 | €1,000.00 |
20+
| May 24, 2025 – May 24, 2026 | | | |
21+
"""
22+
css = """
23+
table {
24+
width: 100%;
25+
border-spacing: 0;
26+
}
27+
28+
th, td {
29+
border: 1px solid #d0d7de;
30+
padding: 8px;
31+
text-align: left;
32+
}
33+
34+
tr {
35+
border-bottom: 1px solid #d0d7de;
36+
}
37+
38+
td {
39+
background-clip: padding-box;
40+
}
41+
"""
42+
pdf = MarkdownPdf()
43+
pdf.add_section(Section(text), user_css=css)
44+
pdf.save(self.build("table_css.pdf"))

0 commit comments

Comments
 (0)