Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! ✅Check out the new docs.

Markdown component doesn't render html tags

Hello,

I’m currently trying to change the text color in a Markdown component. Since Markdown is compatible with HTML, I’m using the <font> tag.

Here’s the tiniest reproducible example I can think of:

import dash

app = dash.Dash()
app.layout = dcc.Markdown('''<font color="red">Am I red yet?</font>''')
app.run_server(debug=True)

The rendering inside my browser is:

<font color="red">Am I red yet?</font>

I’ve tried with other tags and it seems they are considered as plain text instead of tags. Is this behavior for security reasons?

Thanks!

did you ever figure out a solution to this?
I have a similar usecase where I’d like to invoke some simple HTML inside of the markdown block, and it’s impractical to close/reopen dcc.Markdown just to do that.

I wonder if this would cause an issue though with the desire to avoid ‘no raw html’?

I am also looking for ways to change style inside dcc.Markdown but that’s probably not available now. The code below can change the colour.

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div(dcc.Markdown('''Am I red yet?'''), style={'color':'red'})
app.run_server(debug=True)
1 Like