Skip to content

dollarmath: inline $…$ spanning a newline parses inconsistently (second span leaks as raw text) #69

Description

@mmcky

Summary

When a paragraph contains two inline math spans that each cross a hard line break, the dollarmath inline parser handles them inconsistently: the first span parses as math, but the second one fails to parse and leaks the raw $…$ LaTeX as visible text (including the $ delimiters).

Minimal reproduction

test.md:

Now note that under the policy $\sigma
\equiv 0$, where the firm chooses never to exit, we have $T_\sigma v = \pi
+ \beta Q v$. Done.

Build with myst build --html and inspect the page AST.

Expected

Both inline spans render as math. LaTeX treats a single newline inside $…$ as a space, so $\sigma \equiv 0$ and $T_\sigma v = \pi + \beta Q v$ should both be math nodes.

Actual

The first span parses; the second leaks as literal text. The paragraph's children come out as:

node type value
text Now note that under the policy
inlineMath \sigma\n\equiv 0
text , where the firm chooses never to exit, we have $T_\sigma v = \pi + \beta Q v$. Done.

The second $…$ is emitted as a text node, so the raw LaTeX (delimiters included) is shown to the reader in the rendered HTML.

Environment

Observed on myst v1.10.1 (QuantEcon qe-v8 fork). Reproduces with the minimal test.md above in a stock book-theme project.

Context

This surfaced while converting the QuantEcon Dynamic Programming Volume I LaTeX source to MyST, where inline math frequently spans source line breaks. The converter side is being hardened to collapse those newlines, but the inconsistency here (one span OK, a structurally identical one leaking) looks like a genuine parser robustness bug worth fixing upstream too. Reported downstream in QuantEcon/book-dp-public#30.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions