{"id":41740589,"url":"https://github.com/loglux/fix-math-for-obsidian","last_synced_at":"2026-03-16T02:53:47.229Z","repository":{"id":318377642,"uuid":"1071043157","full_name":"loglux/fix-math-for-obsidian","owner":"loglux","description":"Convert LaTeX math delimiters to Obsidian format. Transforms \\[…\\] to $$…$$ and \\(…\\) to $…$ in your notes.","archived":false,"fork":false,"pushed_at":"2026-01-23T02:49:04.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-23T19:40:48.473Z","etag":null,"topics":["latex","markdown","math","mathematics","mathjax","obsidian","obsidian-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loglux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-06T19:35:40.000Z","updated_at":"2026-01-23T02:49:07.000Z","dependencies_parsed_at":"2025-10-06T21:26:23.015Z","dependency_job_id":"ae972bd4-b81c-49c0-9fe4-45946ff4ff6e","html_url":"https://github.com/loglux/fix-math-for-obsidian","commit_stats":null,"previous_names":["loglux/fix-math-for-obsidian"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/loglux/fix-math-for-obsidian","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Ffix-math-for-obsidian","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Ffix-math-for-obsidian/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Ffix-math-for-obsidian/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Ffix-math-for-obsidian/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loglux","download_url":"https://codeload.github.com/loglux/fix-math-for-obsidian/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loglux%2Ffix-math-for-obsidian/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28739420,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T22:12:27.248Z","status":"ssl_error","status_checked_at":"2026-01-24T22:12:10.529Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["latex","markdown","math","mathematics","mathjax","obsidian","obsidian-plugin"],"created_at":"2026-01-25T00:13:00.274Z","updated_at":"2026-03-16T02:53:47.222Z","avatar_url":"https://github.com/loglux.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fix Math for Obsidian\n\nA simple Obsidian plugin with a button and command to fix LaTeX math delimiters in your notes. It converts `\\[…\\]` → `$$…$$` and `\\(…\\)` → `$…$`, while intelligently detecting and converting plain parentheses and brackets that contain mathematical expressions. Code blocks are always preserved.\n\n## Why This Plugin?\n\nWhen you copy content with mathematical formulas from **ChatGPT**, **OpenWebUI**, or other AI assistants into Obsidian, the math often comes in LaTeX format using `\\(…\\)` for inline math and `\\[…\\]` for display math. However, Obsidian uses `$…$` and `$$…$$` delimiters.\n\nInstead of manually finding and replacing each formula, just click one button and all math delimiters in your note will be fixed automatically! 🪄\n\n## Why another LaTeX converter?\n\nWhile there are other plugins for converting LaTeX delimiters, this one focuses on:\n\n- **Simplicity** – a single command that only touches what is obviously maths.\n- **Intelligence** – detects mathematical expressions in plain parentheses like `(x=y)` and `(0/0)`.\n- **Transparency** – a small, readable TypeScript codebase.\n- **Safety** – leaves code blocks, existing `$…$` and non-math text alone.\n- **Statistics** – shows you exactly how many formulas were converted.\n\n## Features\n\n- **Ribbon button** on the sidebar for quick access.\n- **Command palette** integration: \"Fix math (current file)\".\n- **Real-time statistics**: Shows count of converted inline and block formulas.\n- **Status bar updates**: Displays conversion results and automatically resets.\n- Works only on the **currently open file**.\n- Does not touch existing `$…$` and `$$…$$` delimiters.\n- Preserves all content inside fenced code blocks (` ```…``` ` and `~~~…~~~`).\n- Detects maths in plain parentheses, including typical cases like:\n    - `(x=y)` – simple variable equations\n    - `(x\\to 1)` – LaTeX expressions\n    - `(0/0)` – fractions\n    - `(3x^{2} - 3 = 0)` – polynomials\n    - `(3x^{2} - 3)'` – derivatives with trailing primes\n    - `(p)` – single-letter variables\n    - `(345{,}678{,}123)` – LaTeX formatted large numbers\n- **NEW:** Detects single-line bracket math from AI assistants like Windows Copilot:\n    - `[ \\frac{a}{b}(c + d) = \\frac{ac}{b} + \\frac{ad}{b} ]` → converts to display math\n- Supports **quoted block math** in blockquotes:\n    - `\u003e \\[...\\]` (quoted backslash blocks)\n    - `\u003e [...]` (quoted bracket blocks) – handles multi-line quoted brackets from AI assistants\n\n## Supported conversions\n\n| Input format                                         | Detected as | Output format |\n| ---------------------------------------------------- | ----------- | ------------- |\n| `\\(...\\)`                                            | inline      | `$...$`       |\n| `\\[...\\]`                                            | block       | `$$...$$`     |\n| `\u003e \\[...\\]` *(quoted backslash block)*               | block       | `\u003e $$...$$`   |\n| `\u003e [...]` *(quoted bracket block, multi-line)*       | block       | `\u003e $$...$$`   |\n| `[ ... ]` *(if on separate lines and contains math)* | block       | `$$...$$`     |\n| `[ ... ]` *(single line with LaTeX, e.g. from AI)*  | block       | `$$...$$`     |\n| `( ... )` *(if contains math)*                       | inline      | `$...$`       |\n| ` ```...``` ` or `~~~...~~~`                         | code block  | unchanged     |\n\n## Installation\n\n### From release (recommended)\n\n1. Go to the **Releases** section of this repository.\n2. Download the latest versions of:\n    - `manifest.json`\n    - `main.js`\n3. In your Obsidian vault, navigate to:  \n   `.obsidian/plugins/fix-math/`\n4. Place both files in that folder.\n5. Restart Obsidian.\n6. Go to **Settings → Community plugins** and enable **Fix Math for Obsidian**.\n\n### From source (for developers)\n\n1. Clone this repository.\n2. Run:\n\n```bash\nnpm install\nnpm run build\n```\n\n- This will produce `main.js` next to `main.ts`.\n- Copy `manifest.json` and the built `main.js` into your vault's plugin folder:  \n  `.obsidian/plugins/fix-math/`.\n\n## How to Use\n\n1. Open the Markdown file you want to fix in Obsidian\n2. Either:\n    - Click the **wand icon** (🪄) in the left ribbon, or\n    - Open Command Palette (`Ctrl/Cmd+P`) and run **\"Fix math for Obsidian (current file)\"**\n3. You'll see a notification with conversion statistics:\n    - \"Converted 5 formulas (3 inline, 2 block)\" if changes were made\n    - \"No changes required\" if nothing needed fixing\n    - \"Error: failed to process file\" if something went wrong\n4. The **status bar** at the bottom will briefly display the result, then reset to \"Fix Math ready\"\n\n## Keyboard shortcut\n\nThe plugin does not set a default hotkey, but you can add one yourself:\n\n1. Open **Settings → Hotkeys**.\n2. Search for **\"Fix math (current file)\"**.\n3. Assign any shortcut you like, for example \u003ckbd\u003eCtrl\u003c/kbd\u003e+\u003ckbd\u003eShift\u003c/kbd\u003e+\u003ckbd\u003eM\u003c/kbd\u003e.\n\nThis makes it very convenient to fix maths in the current note with a single key press.\n\n## Tips for copying from AI assistants\n\n### Recommended Obsidian setting\n\nFor best results with AI-generated math content, go to **Settings → Editor** and **disable** the option **\"Convert HTML content to Markdown on paste\"**.\n\nWith this setting off, pasted content keeps its original structure — bracket math blocks `[...]`, matrix row separators `\\\\`, and equation signs `=` are all preserved as exported. The plugin then handles all known ChatGPT export artefacts automatically.\n\n\u003e If you prefer to keep the setting enabled, the plugin also handles the different artefacts produced by that mode.\n\n### Copying with math delimiters preserved\n\nWhen copying content from **ChatGPT**, **Claude**, **OpenWebUI**, or similar AI assistants:\n\n- **Always use the \"Copy\" button** located at the bottom-left of the generated response (usually appears on hover)\n- This ensures math expressions are copied with their LaTeX delimiters `\\( ... \\)` and `\\[ ... \\]`\n- Once pasted into Obsidian, simply run this plugin to convert them to `$ ... $` and `$$ ... $$`\n\n### If you already pasted text without delimiters\n\nIf you've already pasted text and the math expressions don't have any delimiters (just plain LaTeX commands like `\\frac{a}{b}` or `\\sum_{i=1}^n`):\n\n1. **Select the math expression** with your mouse or keyboard\n2. Press **Shift + $$** to wrap it in block math delimiters (`$$ ... $$`)\n   - For inline math, use **Shift + $** to wrap in inline delimiters (`$ ... $`)\n\nThis is Obsidian's built-in feature for wrapping selected text in math delimiters.\n\n**Example:**\n- Select: `\\frac{a}{b} = \\frac{c}{d}`\n- Press: **Shift + $$**\n- Result: `$$\\frac{a}{b} = \\frac{c}{d}$$`\n\n## Examples\n\n### Example 1: Basic LaTeX conversion\n\n**Before:**\n\n```markdown\nThis is inline math \\(x^2 + y^2 = z^2\\) in text.\n\nDisplay math:  \n\\[  \n\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}  \n\\]\n```\n\n**After:**\n\n```markdown\nThis is inline math $x^2 + y^2 = z^2$ in text.\n\nDisplay math:\n\n$$  \n\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}  \n$$\n```\n\n### Example 2: Smart parentheses detection\n\n**Before:**\n\n```markdown\nAnd a mixed example:  \n(0/0) is an indeterminate form, and (3x^{2}-3)' = 6x.\n\nSimple equations like (x=y) are also converted.\n```\n\n**After:**\n\n```markdown\nAnd a mixed example:  \n$0/0$ is an indeterminate form, and $(3x^{2}-3)' = 6x$.\n\nSimple equations like $x=y$ are also converted.\n```\n\n### Example 3: Quoted block math (backslash format)\n\n**Before:**\n\n```markdown\n\u003e Here's an important formula:\n\u003e \\[\n\u003e E = mc^2\n\u003e \\]\n```\n\n**After:**\n\n```markdown\n\u003e Here's an important formula:\n\u003e $$ E = mc^2 $$\n```\n\n### Example 4: Quoted bracket blocks (from AI assistants in blockquotes)\n\n**Before:**\n\n```markdown\n\u003e You can use the expression\n\u003e [\n\u003e \\cos(\\angle DEF) = \\frac{-92.99}{163.48}\n\u003e ]\n\u003e to find the angle.\n```\n\n**After:**\n\n```markdown\n\u003e You can use the expression\n\u003e $$\n\\cos(\\angle DEF) = \\frac{-92.99}{163.48}\n$$\n\u003e to find the angle.\n```\n\n### Example 5: Single-line brackets from AI assistants (Windows Copilot, ChatGPT)\n\n**Before:**\n\n```markdown\nThe student correctly applied the distributive property:\n[ \\frac{a}{b}(c + d) = \\frac{a(c + d)}{b} = \\frac{ac + ad}{b} = \\frac{ac}{b} + \\frac{ad}{b} ]\n\nThis shows understanding of algebraic fractions.\n```\n\n**After:**\n\n```markdown\nThe student correctly applied the distributive property:\n\n$$\n\\frac{a}{b}(c + d) = \\frac{a(c + d)}{b} = \\frac{ac + ad}{b} = \\frac{ac}{b} + \\frac{ad}{b}\n$$\n\nThis shows understanding of algebraic fractions.\n```\n\n### Example 6: LaTeX formatted numbers\n\n**Before:**\n\n```markdown\nThe population is approximately (7{,}900{,}000{,}000) people.\n\nScientific notation uses (6{.}022 \\times 10^{23}) for Avogadro's number.\n```\n\n**After:**\n\n```markdown\nThe population is approximately $7{,}900{,}000{,}000$ people.\n\nScientific notation uses $6{.}022 \\times 10^{23}$ for Avogadro's number.\n```\n\n## What gets converted?\n\nThe plugin intelligently detects mathematical expressions based on:\n\n- **LaTeX commands**: `\\to`, `\\sin`, `\\cos`, `\\text{...}`, etc.\n- **LaTeX number formatting**: `123{,}456` (thousands), `1{.}234` (decimals)\n- **Math operators**: `+`, `-`, `*`, `/`, `=`, `\u003c`, `\u003e`\n- **Mathematical symbols**: `_`, `^` (subscript/superscript), `→`, `∞`, `±`, `≥`, `≤`\n- **Numbers with operators**: `3 + 5`, `x^2`\n- **Pure numbers**: `0`, `-1`, `3.14`\n- **Single-letter variables**: `p`, `v`, `x'`\n- **Variable equations**: `x=y`, `a\u003cb`, `f\u003eg`\n\n## What stays unchanged?\n\n- **Natural language**: `(about this topic)` – contains full words\n- **Code blocks**: ` ```math content``` ` – never touched\n- **Existing delimiters**: `$formula$` and `$$formula$$` – already correct\n- **Non-math text**: `(hello world)` – no mathematical indicators\n- **Markdown links**: `[text](url)` and `[text]: url` – recognised as links, not math\n- **Wikilinks**: `[[page name]]` – Obsidian internal links\n- **Footnotes**: `[^ref]` – footnote references\n\n## Customisation\n\nBy default, block maths is wrapped as:\n\n```tex\n$$\n... \n$$\n```\n\nIf you prefer display formulae without extra blank lines around `$$`, you can tweak the `convertMath()` implementation in `main.ts` (or the compiled `main.js`) to change how block maths is wrapped.\n\n## Technical Details\n\n### How it works\n\n1. **Parse document**: Split into code blocks and text segments\n2. **Protect code**: Never modify content inside ` ``` ` or `~~~` fences\n3. **Convert LaTeX**: Transform `\\[...\\]` and `\\(...\\)` delimiters\n4. **Detect math**: Use heuristics to identify mathematical expressions in plain parentheses\n5. **Track statistics**: Count inline and block conversions\n6. **Update UI**: Show results in notification and status bar\n\n### Safety guarantees\n\n- ✅ Code blocks are always preserved\n- ✅ Existing `$...$` delimiters are never modified\n- ✅ Natural language in parentheses is ignored\n- ✅ No changes are made unless confident it's mathematics\n\n## Licence\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floglux%2Ffix-math-for-obsidian","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floglux%2Ffix-math-for-obsidian","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floglux%2Ffix-math-for-obsidian/lists"}