question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better support for printing from dark mode

See original GitHub issue

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:

image

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:

print js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
wilhelmercommented, Oct 9, 2020

I can confirm that wrapping the theme definitions in @media not print works fine, also with custom color schemes.

Maybe that should also be documented in the Custom Color Schemes section. Something like “If your custom colors don’t look good when printed, wrap the definitions in …”

1reaction
squidfunkcommented, Oct 9, 2020

The only thing where this does not work is when using multiple color palettes through Insiders with bright primary and accent colors, e.g. slate with yellow as a primary. The slate theme would be reset, but the primary color wouldn’t. We need a solution for this, too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dark mode printer output | Apple Developer Forums
I want to print an NSView to the printer while in dark mode. For an NSTextField, I get a white background and white...
Read more >
Your Eyes Will Thank You if You Try This Microsoft Word Dark ...
To do this, click on File and Options. Go to the Display tab and look for the Printing Options area.
Read more >
Print in Dark Mode in OSX Mojave - Agenda Community
Just to add, Dark mode, High Sierra - exported PDF or printinbg a note, the font is grey. Switching to light mode as...
Read more >
Printing problem with Chrome Dark Mode flag enabled.
When I use the Chrome dark mode flag, anything I print in Chrome is way too light to read. This also happens using...
Read more >
How to turn your CURA into dark theme - YouTube
3D Printing Doctor ... This video shows how to swap to dark cura! ❤️ Don't forget to follow your @3dprintingdoctor for more.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found