dash-core-components
dash-core-components copied to clipboard
`higlight_config` argument to `dcc.Markdown` has by default no effect in `dcc>=1.13`
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 :beetle: 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"}.
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.
@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