I am using dash to produce an app. I need to write a sentence or two explaining the app. I am using code like this
dcc.Markdown(dedent('''
## Plot of Y_p vs. x_i, z_j shows blah blah blah
''')),
this produces the sentence shown, number of hashtags determine size of font
What I need to do is write subscripts and superscripts instead of for example x_i, I for it to output an actual subscript. Is this possible in the DC markdown? Is there another solution?
PS: I already tried 'x_i' , r'x_i' ,text/etc…
Any suggestions appreciated. I should mention that I was able to get subscripts and superscripts to work in html.Div() , by inserting html.Div([‘z’,html.Sub(‘j’)]), and I was able to get the subscripts to show in my actual plot by using text. These methods did not work in dcc.Markdown
And so most Markdown implementations fallback to HTML tags when you need further formatting features, including React Markdown, on their live demo this works:
Plot of Y<sub>p</sub> vs. x<sub>i</sub>, z<sub>j</sub> shows blah blah blah
But as you can see there are different HTML escaping procedures, it seems dcc.Markdown defaults to “escape” mode. Now it has an argument called dangerously_allow_html so I would assume this would work:
dcc.Markdown(
dangerously_allow_html=True,
children=dedent(
'''
Plot of Y<sub>p</sub> vs. x<sub>i</sub>, z<sub>j</sub> shows blah blah blah
'''
)
)
But when I try it seems to use the “skip” html mode, not the “raw” html mode. So what I would say you have here is a bug in dcc.Markdown, I suggest you report it here with an example: https://github.com/plotly/dash-core-components/issues
It might be a regression from 0.39 to 0.40 as well, I would check the version of Dash you have. Later tonight I will check both versions.
Okay! Looks like it broke between 0.39 and 0.40, I will report a bug later tonight!
Edit: Never-mind, I created 3 environments at home, 0.38, 0.39, and 0.40, and the only one it correctly works on for me it 0.40. So I’m very confused but as long as it works for you I’m glad!