Skip to content

[BUG] dcc.Markdown mishandles escaped dollar inside math expression #4122

Open

Description

@andre996

Thank you so much for helping improve the quality of Dash!

We do our best to catch bugs during the release process, but we rely on your help to find the ones that slip through.

Describe your context

  • Dash version: 4.5.0
  • Minimal example:
from dash import Dash, dcc

app = Dash(__name__)
app.layout = dcc.Markdown(
    r"""
    control: $\approx 3,150$

    escaped dollar: $\approx \$3,150$

    double backslash: $\approx \\$3,150$

    two-dollar delimiters: $$\approx \$3,150$$
    """,
    mathjax=True,
)

if __name__ == "__main__":
    app.run(debug=True)

In Dash 4.5.0, the escaped-dollar example is parsed/rendered incorrectly. The control case, the double-backslash example, and the $$...$$ example work as expected. The problematic input is r"escaped dollar: $\approx \$3,150$", where the intended escaped dollar inside the math expression is not preserved correctly.

Describe the bug
With dcc.Markdown(mathjax=True), an escaped dollar sign inside an inline math expression causes the expression to be parsed/rendered incorrectly. This appears to be a regression in the Markdown/math parsing pipeline introduced by the Markdown rewrite in PR #3960. The current regression test covers escaped dollar signs in ordinary Markdown text (outside math), but not an escaped dollar inside $...$.

Expected behavior
The escaped dollar should remain a literal dollar sign within the math expression, and the expression should render as intended. For example, r"escaped dollar: $\approx \$3,150$" should render approximately followed by $3,150.

this test works fine on Dash 4.4.1

Screenshots

Activity

  1. added theissue type on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions