Skip to content

fix: preserve block equations ($$) in MarkdownShortcutPlugin#8194

Open
Anas0709 wants to merge 1 commit intofacebook:mainfrom
Anas0709:fix/block-equation-markdown-transformer
Open

fix: preserve block equations ($$) in MarkdownShortcutPlugin#8194
Anas0709 wants to merge 1 commit intofacebook:mainfrom
Anas0709:fix/block-equation-markdown-transformer

Conversation

@Anas0709
Copy link

@Anas0709 Anas0709 commented Mar 5, 2026

Summary

Fixes #6936

Block math equations ($$...$$) created via the toolbar were incorrectly converted to inline equations ($...$) when toggling markdown mode via the MarkdownShortcutPlugin.

Root cause: The EQUATION transformer's export function always returned $${equation}$ (inline syntax) regardless of whether the node was a block or inline equation. There was also no transformer to import/match $$...$$ patterns.

Changes

  • Added BLOCK_EQUATION transformer that handles $$...$$ syntax (export and import)
  • Updated EQUATION transformer to only export when the node is inline (node.__inline === true)
  • Placed BLOCK_EQUATION before EQUATION in PLAYGROUND_TRANSFORMERS so the $$ pattern is matched before the single $ pattern

Before / After

Before: inserting a block equation and clicking the Markdown button converted $$x^2 + y^2 = z^2$$$x^2 + y^2 = z^2$ (inline)

After: block equations are preserved as $$x^2 + y^2 = z^2$$ when toggling markdown mode

Block math equations created via the toolbar were incorrectly
converted to inline equations ($...$) when toggling markdown mode.

This adds a BLOCK_EQUATION transformer that handles $$...$$ syntax
and updates EQUATION to only export inline nodes. BLOCK_EQUATION is
placed before EQUATION in PLAYGROUND_TRANSFORMERS so the $$ pattern
is matched before the $ pattern.

Fixes facebook#6936
@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview, Comment Mar 5, 2026 4:02pm
lexical-playground Ready Ready Preview, Comment Mar 5, 2026 4:02pm

Request Review

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 5, 2026
@etrepum
Copy link
Collaborator

etrepum commented Mar 5, 2026

I’ll review after new tests are added that demonstrates that this solves the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Block math equation is falsely converted to inline equation on MarkdownShortcutPlugin

2 participants