Skip to content

Code highlighting colours the whole line in --md-code-hl-color #6017

Closed
@mocdaniel

Description

@mocdaniel

Context

I'm working on a freshly setup instance of Material for MkDocs and code highlighting seems to be off, compared to the results shown in the docs.

strange code highlighting

Bug description

Compared to the example from the docs, the result rendered on my end is

a) yellowish instead of blue

b) renders the whole line in --md-code-hl-color instead of just the left border and the remainder in --md-code-hl-color according to my dev tools:

.highlight .hll {
    background-color: var(--md-code-hl-color);
    display: block;
    margin: 0 -1.1764705882em;
    padding: 0 1.1764705882em;
}

My related configuration looks like this, I went by the book, i.e. the docs, if not mistaken:

markdown_extensions:
  - abbr
  - admonition
  - attr_list
  - md_in_html
  - pymdownx.details
  - pymdownx.highlight:
      use_pygments: true
      pygments_lang_class: true
      line_spans: __span
  - pymdownx.snippets
  - pymdownx.superfences
  - pymdownx.tabbed:
      alternate_style: true

Related links

I took a good look at the pygments/Highlight configuration:

as well as the docs regarding how to do highlighting and how to theme it:

I managed to get the bluish highlight working this way, but it still covered the whole line in the darker variant and omitted the --light variant altogether.

Reproduction

9.3.1-highlight-wrong-css.zip

Steps to reproduce

  1. Enable code highlighting as per my example and the documentation linked above
  2. Run mkdocs serve or mkdocs build
  3. Open the result and see code highlighting be different from the examples in the docs linked above

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions