From 622a886478965e9fcd1837c12eca520552b843ee Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Mon, 15 Jan 2018 16:59:01 +0000 Subject: [PATCH] Patch out bootstrap rule forcing black and white printing Closes gh-840 --- setupbase.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/setupbase.py b/setupbase.py index 6a30d7d180..df91a12fe8 100644 --- a/setupbase.py +++ b/setupbase.py @@ -398,6 +398,28 @@ def run(self): update_package_data(self.distribution) +def patch_out_bootstrap_bw_print(): + """Hack! Manually patch out the bootstrap rule that forces printing in B&W. + + We haven't found a way to override this rule with another one. + """ + print_less = pjoin(static, 'components', 'bootstrap', 'less', 'print.less') + with open(print_less) as f: + lines = f.readlines() + + for ix, line in enumerate(lines): + if 'Black prints faster' in line: + break + else: + return # Already patched out, nothing to do. + + rmed = lines.pop(ix) + print("Removed line", ix, "from bootstrap print.less:") + print("-", rmed) + print() + with open(print_less, 'w') as f: + f.writelines(lines) + class CompileCSS(Command): """Recompile Notebook CSS @@ -424,6 +446,8 @@ def run(self): self.run_command('jsdeps') env = os.environ.copy() env['PATH'] = npm_path + + patch_out_bootstrap_bw_print() for src, dst in zip(self.sources, self.targets): try: