Skip to content

Commit

Permalink
Prevent page breaks in outputs when printing
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Nov 23, 2021
1 parent bc9802c commit 49b8de9
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions share/jupyter/nbconvert/templates/lab/index.html.j2
Expand Up @@ -41,9 +41,11 @@
{{ resources.include_css("static/theme-light.css") }}
{% endif %}
<style type="text/css">
/* Misc */
a.anchor-link {
display: none;
}
.highlight {
margin: 0.4em;
}
Expand All @@ -57,10 +59,60 @@ a.anchor-link {
overflow: hidden;
}
/* Output area styling: using table instead of flexbox so that we can use break-inside property */
.jp-CodeCell.jp-mod-outputsScrolled .jp-OutputArea-prompt {
min-width: calc(
var(--jp-cell-prompt-width) - var(--jp-private-cell-scrolling-output-offset)
);
}
.jp-OutputArea-child {
display: table;
width: 100%;
}
.jp-OutputPrompt {
display: table-cell;
vertical-align: top;
min-width: var(--jp-cell-prompt-width);
}
body[data-format='mobile'] .jp-OutputPrompt {
display: table-row;
}
.jp-OutputArea-output {
display: table-cell;
width: 100%;
}
body[data-format='mobile'] .jp-OutputArea-child .jp-OutputArea-output {
display: table-row;
}
.jp-OutputArea-output.jp-OutputArea-executeResult {
width: 100%;
}
/* block wrapper: using block instead of flexbox so that we can use break-inside property
note: in the case of JupyterLab, wrappers also include collapsers, hence the flexbox.
*/
.jp-Cell-inputWrapper, .jp-Cell-outputWrapper {
display: block;
}
/* Media print rules */
@media print {
body {
margin: 0;
}
.jp-OutputArea-child {
break-inside: avoid-page;
}
}
</style>

Expand Down

0 comments on commit 49b8de9

Please sign in to comment.