Skip to content

Bug: Complex LaTeX Equations Not Rendering in Markdown Preview #99

@ThisIs-Developer

Description

@ThisIs-Developer

Description

Simple LaTeX equations are rendering correctly in markdown preview, but complex multiline mathematical expressions are failing to render.


Currently Working

Inline Equation

$$E = mc^2$$

Display Equations

$$\frac{\partial f}{\partial x} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$
$$\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6}$$

These render correctly.


Currently Broken

The following advanced multiline equations do NOT render:

$$
\mathcal{J}_{\text{CISPO}}(\theta) = E_{(q,a) \sim \mathcal{D},\, \{o_i\}_{i=1}^G \sim \pi_{\theta_{\text{old}}}(\cdot \mid q)}
\left[
\frac{1}{\sum_{i=1}^G |o_i|} \sum_{i=1}^G \sum_{t=1}^{|o_i|}
\text{sg}(\hat{r}_{i,t}(\theta))\, \hat{A}_{i,t} \log \pi_\theta(o_{i,t} \mid q, o_{i,\lt t})
\right],
$$
$$
\hat{r}_{i,t}(\theta) = \text{clip}\!\left(r_{i,t}(\theta),\; 0,\; 1 + \epsilon^{IS}_{high}\right).
$$
$$
\hat{A}_{i,t} = \sum_{p=t}^{T} \left(r_p^{\text{speed}} + r_p^{\text{perf}}\right) - B_i
$$

Possible Causes

Unsupported LaTeX Features

Current renderer may not support:

  • multiline block parsing
  • advanced macros
  • \mathcal
  • \text{}
  • nested subscripts/superscripts
  • escaped spacing commands
  • large operators
  • multiline environments

Likely Technical Issues

1. Missing Proper Math Engine

Current markdown parser may only support basic KaTeX/MathJax parsing.


2. Block Parsing Failure

Renderer may fail when:

  • $$ spans multiple lines
  • equation contains indentation/newlines

3. Unsupported Commands

Potential unsupported commands:

\text{}
\mathcal{}
\left[
\right]
\epsilon
\sim

Required Fix

Recommended Solution

Use full-featured math rendering support with:

  • KaTeX
    OR
  • MathJax

with proper block equation configuration.


Required Capabilities

The renderer must support:

  • multiline $$ ... $$
  • nested expressions
  • large equations
  • advanced symbols
  • scientific notation
  • AI/ML mathematical papers formatting

Important Rendering Requirement

Preserve Multiline Formatting

Do NOT collapse multiline equations into one line.


Expected Result

All provided equations should render correctly in preview exactly like:

  • GitHub markdown math
  • Obsidian
  • Jupyter Notebook
  • modern LaTeX-supported markdown editors

Additional Recommendation

Add Error Fallback

If equation parsing fails:

  • show readable error message
  • highlight invalid LaTeX section
  • avoid breaking entire preview rendering

Priority

High — complex scientific/technical markdown rendering currently broken.

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions