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

Code blocks produced by code shortcode has wrong background colors #208

Closed
i-give-up opened this issue Sep 26, 2017 · 1 comment
Closed

Comments

@i-give-up
Copy link
Contributor

i-give-up commented Sep 26, 2017

Seems to only happen to code blocks that are syntax-highlighted, i.e. <pre> elements that are wrapped in <div class="highlight">.

You can see affected code blocks on List Page Templates page but the issue is present in other pages too.

Below is a screenshot of the List Page Templates page that illustrates this issue. The code block above isn't syntax-highlighted so it doesn't have this issue whereas the code block below is syntax-highlighted and thus exhibiting this issue.

templates-lists-1506412247502

The cause seems to be this CSS rule background-color: inherit; for .highlight pre which causes <pre> to inherit the blue background color of the containing <div> block. There is a background-color: #f0f0f0; for .chroma but it isn't used due to lower specificity.

I think removing these two CSS properties for .highlight pre should fix this

  • background-color: inherit;
  • padding: .5em;

As far as I can tell, these properties are there because the output of Pygments (default syntax highlighter up until Hugo 0.27) doesn't have <code> inside <pre>.

I wonder if a new rule should be added instead

.highlight pre.chroma {
    background-color: #fff;
    padding: 0;
}

so that regardless of which syntax highlighter one is using, those code blocks won't look weird.

@digitalcraftsman
Copy link
Member

Hello @i-give-up,

thanks for opening this issue. Some users on Twitter mentioned it as well. As this issue has to be fixed in the repo for the docs' theme I created an issue there. However, I'll link your issue as a reference since it contains some helpful details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants