MathJax NBSP Cleaner: Clean MathJax Formatting Automatically
When writing MathJax equations or editing formatted text, Anki's editor frequently writes double spaces into literal   strings. This corrupts MathJax rendering and clutters formulas - incredibly frustrating when using LaTeX inside cards!
MathJax NBSP Cleaner silently runs in the background of your card editor, automatically detecting and converting   characters back into normal spaces every time a field loses focus (before MathJax rendering triggers) by directly injecting raw HTML data.
Key Features
- Automatic Focus-Out Cleaning: Sanitizes fields immediately upon unfocusing (
focusout), right before MathJax re-renders your note preview.
- Targeted MathJax Correction: Specifically targets escaped
  artefacts to restore proper LaTeX/MathJax expressions without altering unintended elements.
- Deep Field Detection: Traverses regular DOM elements, shadow roots (Shadow DOM), and nested iframes to ensure every editor field is monitored simultaneously.
- Dynamic Field Monitoring: Uses a
MutationObserver to immediately attach cleaners to any dynamically generated fields without requiring an editor reload.
- Native Change Dispatch: Emits native input events directly to the editor after sanitising, ensuring Anki registers and saves the corrected text instantly.
- Duplicate Prevention: Built-in script and listener flags prevent duplicate observers and multi-firing event handlers.
Usage
No configuration, shortcuts, or menus required. Install the add-on, restart Anki, and edit your MathJax notes as usual—the cleaner functions completely automatically in the background.