Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch out bootstrap rule forcing black and white printing #3212

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions setupbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is enough specific to patch the proper line, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be. The original file is not very long:

https://github.com/twbs/bootstrap/blob/v3.3.7/less/print.less

break
else:
return # Already patched out, nothing to do.

rmed = lines.pop(ix)
print("Removed line", ix, "from bootstrap print.less:")
print("-", rmed)
print()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this empty print here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes a blank line, so the text above is slightly easier to pick out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough 👍

with open(print_less, 'w') as f:
f.writelines(lines)

class CompileCSS(Command):
"""Recompile Notebook CSS

Expand All @@ -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:
Expand Down