Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Math Expression Breaks

Open defencedog opened this issue 5 months ago • 2 comments

Describe the bug This latex syntax is not getting rendered

 $ \ln(0.449) = (x - 1) \ln(50) \implies -0.80 = (x - 1) \times 3.91 \implies x = \mathbf{0.795 \text{ (or } \approx 80\% \text{ open)}} $

or

$$ \mathbf{Q_{\text{normalized}}(u) = \left( \frac{q(u)}{Q_{\text{avg}}} \right) \times 100\%} $$

or

$$ dh_f = f \frac{L \cdot du}{D} \frac{V_0^2(1 - u)^2}{2g} = \underbrace{\left( f \frac{L}{D} \frac{V_0^2}{2g} \right)}_{\text{Full Flow Friction } (h_{f,\text{full}})} (1 - u)^2 du $$

Device

  • OS: Win10xx64
  • App Version [e.g. v2.6.11]

Additional context Just paste it & it will not render properly. I believe \% is problematic

defencedog avatar Jun 10 '26 20:06 defencedog

Reproduced — your instinct about the backslash was right.

comrak runs CommonMark inline rules inside the math delimiters before KaTeX sees the source, so \% is consumed as an escape and reaches KaTeX as a bare %. In TeX % starts a comment, so the rest of the macro argument is swallowed and KaTeX raises Unexpected end of input in a macro argument.

Same root cause as #197 and #174. The existing guard only protects underscores inside $$; masking the whole delimited span before comrak and restoring after fixes all three. Working on it.

PathGao avatar Aug 02 '26 21:08 PathGao

Fixed in v2.7.0 by #402 — comrak was applying Markdown inline rules inside the math delimiters before KaTeX ever saw the source, so \% lost its backslash and the bare % started a TeX comment that swallowed the rest of the line.

#174 (_{1} becoming italics) and #197 (\\ eaten, so a multi-row aligned collapsed to one line) turned out to be the same bug. #402 masks the whole delimited span before parsing and restores it afterwards, instead of patching one character class at a time.

Could you confirm on your machine? Happy to reopen if it's still there.

PathGao avatar Aug 05 '26 10:08 PathGao