-
Notifications
You must be signed in to change notification settings - Fork 4k
Closed
Labels
change requestIssue requests a new feature or improvementIssue requests a new feature or improvementresolvedIssue is resolved, yet unreleased if openIssue is resolved, yet unreleased if open
Description
I checked that...
- ... the documentation does not mention anything about my idea
- ... to my best knowledge, my idea wouldn't break something for other users
- ... there are no open or closed issues that are related to my idea
Description
When using dark mode, printing a page results in barely readable text:
instead, when printing, mkdocs-material could temporarily switch to light mode, and then back.
Use Cases
well, printing obviously.
Screenshots / Mockups
Here is some javascript I adapted from https://stackoverflow.com/a/11060206/5525118 to make it work for mkdocs-material
function change_material_theme(to="default") {
body = document.getElementsByTagName('body')[0];
var current_color_theme = body.getAttribute('data-md-color-scheme')
var beforePrint = function() {
console.log('Functionality to run before printing.');
body.setAttribute("data-md-color-scheme", to);
};
var afterPrint = function() {
console.log('Functionality to run after printing');
body.setAttribute("data-md-color-scheme", current_color_theme);
};
if (window.matchMedia) {
var mediaQueryList = window.matchMedia('print');
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
beforePrint();
} else {
afterPrint();
}
});
}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
}And here's a GIF with the script in action:
Metadata
Metadata
Assignees
Labels
change requestIssue requests a new feature or improvementIssue requests a new feature or improvementresolvedIssue is resolved, yet unreleased if openIssue is resolved, yet unreleased if open

