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

Prevent page breaks in outputs when printing #1679

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Changes from all commits
Commits
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
Prevent page breaks in outputs when printing
  • Loading branch information
SylvainCorlay committed Dec 8, 2021
commit 84197fa9eba8220724e47d80db7f262f9d1ea89f
52 changes: 52 additions & 0 deletions share/jupyter/nbconvert/templates/lab/index.html.j2
Original file line number Diff line number Diff line change
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