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

Conversation

takluyver
Copy link
Member

A thoroughly ugly hack. Bootstrap forces all text to be black when printing, resulting in a long running issue (#840). I tried to override it with color: inherit !important, but that didn't produce the right results. I can't find any way to tell LESS to remove a rule or act as if it didn't exist. So the only thing I can think to do is to patch the source we get from bootstrap to get rid of the rule entirely.

Frustratingly, it looks like bootstrap is fixing this (getting rid of the rule) for v4, but it's also moving from LESS to SCSS, so we can't easily switch to the new version.

Closes gh-840

@takluyver
Copy link
Member Author

The test failures on Travis appear to be genuine failures from nbval. I just released 0.8, which catches some discrepancies that earlier versions of nbval missed. CC @vidartf .

Copy link
Member

@Carreau Carreau left a comment

Choose a reason for hiding this comment

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

It's been long standing enough. +1 for hackish solution.

Copy link
Member

@damianavila damianavila left a comment

Choose a reason for hiding this comment

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

It is ugly but it is a long standing issue and doing it less hacky way implies a lot of additional complexity.

+1 as well.

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 👍

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

@Carreau Carreau merged commit 0254c8b into jupyter:master Jan 22, 2018
@Carreau
Copy link
Member

Carreau commented Jan 22, 2018

Thanks both !

@damianavila
Copy link
Member

@mpacer @takluyver, we need to update the css in the CDN so nbconvert can catch this change.
Will open an issue to track this need.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Color printing should be an option (or should be the default?)
3 participants