Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

higlight_config argument to dcc.Markdown has by default no effect in dcc>=1.13 #968

Open
anders-kiaer opened this issue May 10, 2021 · 2 comments

Comments

@anders-kiaer
Copy link

anders-kiaer commented May 10, 2021

As stated in the dcc.Markdown documentation (https://dash.plotly.com/dash-core-components/markdown) you can use

highlight_config (dict; optional): Config options for syntax highlighting. highlight_config is a dict with keys:
theme (a value equal to: 'dark', 'light'; optional): Color scheme; default 'light'.

After dash-core-components==1.13, the settings of highlight_config has no effect. This 🪲 appears to be introduced in #871 where one css file (defining both light and dark theme) was changed with another css file defining only a light theme variation.

As stated on another page (https://dash.plotly.com/external-resources#md-syntax-highlight) in the docs, you can override default highlight.js style if you want other than e.g. the current GitHub style, however, I don't think it is intended from dcc point of view that the default dcc provided style needs to be overridden in order for higlight_config to have effect (if so it should be stated close to the highlight_config explanation probably in the documentation).

Test case:

import dash
import dash_core_components as dcc

app = dash.Dash()

app.layout = dcc.Markdown(
    """```
def some_function():
    return 42
```""",
    highlight_config={"theme": "dark"},
)

if __name__ == "__main__":
    app.run_server()

gives the same result as when {"theme": "light"}.

@alexcjohnson
Copy link
Collaborator

Good catch @anders-kiaer - that was not intended. We're adding our class hljs-dark for the dark theme, which indicates we need our own version of the dark theme regardless. I guess the easiest (assuming the hljs v10 bump didn't change its internally-applied classes) is to just bring back the .hljs-dark pieces of the pre-871 CSS file.

@AnnMarieW
Copy link
Contributor

AnnMarieW commented Oct 28, 2021

@alexcjohnson is this still on the radar? The highlight_config still has no effect
In the meantime, I figured out a workaround: https://community.plotly.com/t/how-to-change-the-theme-of-code-highlights-in-dcc-markdown/58004

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

No branches or pull requests

3 participants