Skip to content

dcc.Markdown(mathjax=True, dangerously_allow_html=True) combination #2003

Closed
@anders-kiaer

Description

Thanks for the MathJax support in the latest Dash version 🎉 I've been trying it out today, and there is small detail that (if possible to solve) would make it easier to integrate in our application.

We currently use dcc.Markdown(content, dangerously_allow_html=True) where user content has been through bleach and includes some allowed content pre-processed by us (e.g. <img> with text caption / centering support etc, <details>/<summary> parts).

It looks like dangerously_allow_html=True + mathjax=True works in some cases, and in some cases not. Given

from dash import Dash, dcc

app = Dash(__name__)

CONTENT = ...

app.layout = dcc.Markdown(CONTENT, dangerously_allow_html=True, mathjax=True)

app.run_server()

these are some experiments:

CONTENT
Math rendered
<details>
    <summary>Topic</summary>
    Some details
</details>
$E = mc^2$
✔️
<p>Some paragraph</p>
$E = mc^2$
✔️
<p>Some paragraph</p>
$E = mc^2$
<p>Some paragraph</p> $E = mc^2$
<p>Some paragraph with $E = mc^2$ inline math</p>

Easy fix to support the given combination of arguments to dcc.Markdown? If not we could reconsider our use case of supporting allowed html tags 🙂

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions