RTL Math Fix
Minimal VS Code extension for Hebrew or other RTL Markdown documents where embedded LaTeX math renders visually flipped in the built-in Markdown preview.
Features
The extension adds a small status bar toggle only while a Markdown preview is open:
RTL Math: OFF leaves previews unchanged.
RTL Math: ON injects the bundled CSS override into Markdown previews.
The extension does not require a workspace and does not write to markdown.styles. It uses VS Code's Markdown preview extension API to inject the CSS while rendering the preview.
Usage
- Open a Markdown file.
- Open the built-in Markdown preview.
- Use the
RTL Math: ON/OFF status bar item, or run Toggle RTL Math Fix from the Command Palette.
The status bar item is only visible while a Markdown preview tab is open.
Extension Settings
The default state is off. Set this user setting to start with the fix enabled before you use the toggle:
{
"rtlMathFix.enabled": true
}
The status bar toggle stores its state globally.
What It Changes
When enabled, the extension adds this CSS to Markdown previews:
.katex,
.math,
.mermaid,
mjx-container {
direction: ltr !important;
unicode-bidi: isolate !important;
}
.katex-display,
.math-block {
direction: ltr !important;
unicode-bidi: isolate !important;
}
Development
- Open this folder in VS Code.
- Press
F5.
- In the Extension Development Host, open a Markdown file.
- Run
Markdown: Open Preview or Markdown: Open Preview to the Side.
- Use the
RTL Math: ON/OFF status bar item, or run Toggle RTL Math Fix from the Command Palette.
Package a VSIX
Install dependencies and build the package:
npm install
npm run package
This creates a .vsix file that can be installed with:
code --install-extension rtl-math-fix-0.0.1.vsix