ren yi116 downloadsAutomatically cleans up LaTeX formulas pasted from web pages or AI chats, preserving text formatting.
An Obsidian plugin that automatically cleans up LaTeX formulas when you paste content from web pages or AI chats. It fixes broken formulas (\\(...\\) → $...$, \\[...\\] → $$...$$, double escapes, HTML entities, Unicode math symbols, nested corrupted escapes, split command names) while preserving the formatting of your normal text.
Status: submitted to the Obsidian community plugin marketplace (pending review). Until it's listed, install manually with the steps below.
\\[0,2π] style escaped brackets in headings (not math) are preservedThis plugin needs only two files: main.js and manifest.json (all code lives in main.js, no build step).
0.1.1)main.js and manifest.json<your-vault>/.obsidian/plugins/latex-paste-cleaner/.obsidian folder is hidden — enable "show hidden files" if you can't see it)latex-paste-cleaner-main (or latex-paste-cleaner-0.1.1)latex-paste-cleaner (the folder name must match the plugin id, otherwise Obsidian won't load it)<your-vault>/.obsidian/plugins/If the plugin doesn't appear in the list, restart Obsidian completely.
Just paste. When the clipboard contains LaTeX math signals, the plugin cleans the formulas automatically — that's it.
Ctrl+P / Cmd+P)Open Settings → Community plugins → Latex Paste Cleaner:
| Setting | Description |
|---|---|
| Language | 中文 / English — switches all settings text and the command name |
| Enable paste interception | Automatically clean pasted content when it contains math signals. Disable to keep only the manual command. |
| Paste mode | HTML surgery (preserve formatting, default) / Plain text (most reliable) |
| Fix HTML entities in text regions | Restore < → < etc. outside math regions. Math regions are always fixed. |
$ escaping)Obsidian's built-in "Convert pasted HTML to Markdown" escapes $ signs in pasted HTML, which breaks inline math rendering even with this plugin. If formulas don't render after an HTML paste:
cd <plugin-dir>
node tests/test-cleaner.cjs # 67 tests, no dependencies
The plugin is a single main.js file (Obsidian's plugin loader does not support relative requires). Core functions are additionally exported for Node testing via a mock obsidian module.
\frac, \\(, $$ etc.); plain text pasting is completely unaffectedMIT