Skip to content

Commit f60c972

Browse files
committed
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 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.
1 parent 9ade2e8 commit f60c972

File tree

6 files changed

+10
-4
lines changed

6 files changed

+10
-4
lines changed

src/pydata_sphinx_theme/assets/styles/components/_versionmodified.scss

+2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ div.deprecated {
55
margin: 1.5625em auto;
66
padding: 0 0.6rem 0 0.6rem;
77
overflow: hidden;
8+
/* break-inside has replaced page-break-inside and is widely usable since 2019 */
89
page-break-inside: avoid;
10+
break-inside: avoid;
911
border-left: 0.2rem solid;
1012
border-color: var(--pst-color-info);
1113
border-radius: $admonition-border-radius;

src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss

+3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ div.admonition,
88
margin: 1.5625em auto;
99
padding: 0 0.6rem 0.8rem 0.6rem;
1010
overflow: hidden;
11+
/* break-inside has replaced page-break-inside and is widely usable since 2019 */
1112
page-break-inside: avoid;
13+
break-inside: avoid;
14+
1215
border-left: 0.2rem solid;
1316
border-color: var(--pst-color-info);
1417
border-radius: $admonition-border-radius;

src/pydata_sphinx_theme/assets/styles/content/_code.scss

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ div.literal-block-wrapper {
1212
flex-direction: column;
1313
width: unset;
1414
border-radius: $admonition-border-radius;
15+
break-inside: avoid;
1516
}
1617

1718
// Code blocks with captions

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
{#- Hide breadcrumbs on the home page #}
1212
{% if title and pagename != root_doc %}
13-
<nav aria-label="{{ _('Breadcrumb') }}">
13+
<nav aria-label="{{ _('Breadcrumb') }}" class="d-print-none">
1414
<ul class="bd-breadcrumbs">
1515
{# Home icon #}
1616
<li class="breadcrumb-item breadcrumb-home">

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
{# A button hidden by default to help assistive devices quickly jump to main content #}
3838
{# ref: https://www.youtube.com/watch?v=VUR0I5mqq7I #}
39-
<a id="pst-skip-link" class="skip-link" href="#main-content">{{ _("Skip to main content") }}</a>
39+
<a id="pst-skip-link" class="skip-link d-print-none" href="#main-content">{{ _("Skip to main content") }}</a>
4040

4141
{%- endblock %}
4242

@@ -74,7 +74,7 @@
7474
{% include "sections/announcement.html" %}
7575
{%- endif %}
7676
{% block docs_navbar %}
77-
<header class="bd-header navbar navbar-expand-lg bd-navbar">
77+
<header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
7878
{%- include "sections/header.html" %}
7979
</header>
8080
{% endblock docs_navbar %}

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/sections/announcement.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{# If we are remote, add a script to make an HTTP request for the value on page load #}
44
{%- if is_remote %}
55
<script>
6-
document.write(`<div class="bd-header-announcement"></div>`);
6+
document.write(`<div class="bd-header-announcement d-print-none"></div>`);
77
fetch("{{ theme_announcement }}")
88
.then(res => {return res.text();})
99
.then(data => {

0 commit comments

Comments
 (0)