Skip to content

Commit fca799b

Browse files
authored
🐛 FIX: Export Notebook as HTML with no page-breaks (jupyter-book#903)
1 parent a0109e5 commit fca799b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

jupyter_book/pdf.py

+16
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ async def _html_to_pdf(html_file, pdf_file):
4040
# Give it *some* margins to make it look a little prettier
4141
# I just made these up
4242
page_margins = {"left": "0in", "right": "0in", "top": ".5in", "bottom": ".5in"}
43+
await page.addStyleTag(
44+
{
45+
"content": """
46+
div.cell_input {
47+
-webkit-column-break-inside: avoid;
48+
page-break-inside: avoid;
49+
break-inside: avoid;
50+
}
51+
div.cell_output {
52+
-webkit-column-break-inside: avoid;
53+
page-break-inside: avoid;
54+
break-inside: avoid;
55+
}
56+
"""
57+
}
58+
)
4359
await page.pdf({"path": pdf_file, "margin": page_margins})
4460
await browser.close()
4561

0 commit comments

Comments
 (0)