From 15ba47fa5136fc4240cc8f0976ed7e5268e54dfd Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Mon, 15 Apr 2024 11:59:06 +0200 Subject: [PATCH 1/2] MAINT: various fixes to print CSS. This should among other fix #1745 When printing this hides - The pydata navbar - The announcement banner. - The "skip to main content" link. - The location breadcrumbs (in bd-header-article), without also hiding the container the full content is shifted by a dozen pixel hight and the end of the content get hidden behind the footer when printing. - The prev.next buttons a bottom of page. This does not hide the version warning banner as this is currently being worked on in another PR. I went the route of adding the bootstrat `d-print-none`, instead of adding custom css rules, I'm happy to do the opposite, but it seem the using bootstrap classes as that seems what is done in other places. I've also added a break-inside avoid in a few places, mostly to try-to avoid page breaks in the middle of codeblocks. --- .../assets/styles/components/_versionmodified.scss | 2 ++ .../assets/styles/content/_admonitions.scss | 2 ++ src/pydata_sphinx_theme/assets/styles/content/_code.scss | 1 + .../theme/pydata_sphinx_theme/components/breadcrumbs.html | 2 +- .../theme/pydata_sphinx_theme/layout.html | 8 ++++---- .../theme/pydata_sphinx_theme/sections/announcement.html | 2 +- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pydata_sphinx_theme/assets/styles/components/_versionmodified.scss b/src/pydata_sphinx_theme/assets/styles/components/_versionmodified.scss index 1e810e909..bf206f0a7 100644 --- a/src/pydata_sphinx_theme/assets/styles/components/_versionmodified.scss +++ b/src/pydata_sphinx_theme/assets/styles/components/_versionmodified.scss @@ -5,7 +5,9 @@ div.deprecated { margin: 1.5625em auto; padding: 0 0.6rem 0 0.6rem; overflow: hidden; + /* break-inside has replaced page-break-inside and is widely usable since 2019 */ page-break-inside: avoid; + break-inside: avoid; border-left: 0.2rem solid; border-color: var(--pst-color-info); border-radius: $admonition-border-radius; diff --git a/src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss b/src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss index 9a316c7d3..c158679c2 100644 --- a/src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss +++ b/src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss @@ -9,7 +9,9 @@ div.admonition, margin: 1.5625em auto; padding: 0 0.6rem 0.8rem 0.6rem; overflow: hidden; + /* break-inside has replaced page-break-inside and is widely usable since 2019 */ page-break-inside: avoid; + break-inside: avoid; border-left: $admonition-left-border-width solid; border-color: var(--pst-color-info); border-radius: $admonition-border-radius; diff --git a/src/pydata_sphinx_theme/assets/styles/content/_code.scss b/src/pydata_sphinx_theme/assets/styles/content/_code.scss index 8f4a264d3..07ea87398 100644 --- a/src/pydata_sphinx_theme/assets/styles/content/_code.scss +++ b/src/pydata_sphinx_theme/assets/styles/content/_code.scss @@ -12,6 +12,7 @@ div.literal-block-wrapper { flex-direction: column; width: unset; border-radius: $admonition-border-radius; + break-inside: avoid; } // Code blocks with captions diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html index 8b5595bf3..28d3dc896 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html @@ -10,7 +10,7 @@ {#- Hide breadcrumbs on the home page #} {% if title and pagename != root_doc %} -