The KaTeX to MathJax plugin streamlines the integration of mathematical expressions into Obsidian by converting KaTeX notation to MathJax format. This is particularly useful for users who copy mathematical content from platforms like ChatGPT, which often use KaTeX. The plugin features automatic conversion upon pasting, ensuring that your notes maintain proper formatting without extra effort. Additionally, users can manually convert text within individual notes or across the entire vault using the command palette. This functionality enhances the usability of mathematical expressions in your notes, making it easier to work with complex equations and maintain a polished appearance in your documents.
Changelog – KaTeX → MathJax Converter Plugin
Fixes
Prevent inline
$…$wrapping inside display$$…$$blocks- Re-ordered processing in
processMath:
- Wrap math-dominant lines (
wrapBareMathLinesOutside) first. - Only then apply inline conversions (
convertInlineDelims,wrapInlineBareLatex) outside display spans.
- Added guard in
isMathLineto skip any line that already contains a$.
- Re-ordered processing in
Features
New settings toggles in the settings tab:
Plain parentheses ( … ) as delimiters → converts
(x^2+1)→$x^2+1$when LaTeX-like.Plain brackets [ … ] as delimiters → same logic for
[a,b].Convert bare inline LaTeX → detects and wraps tokens like:
90^\circ→$90^{\circ}$\sqrt{…}→$\sqrt{…}$\frac{…}{…}→$\frac{…}{…}$simple subscripts/superscripts like
x_i,y^2.Wrap single math lines → isolated equations like
a^2 + b^2 = c^2become:
$$ a^2 + b^2 = c^2 $$- Wrap matrix/align environments → wraps bare
\begin{bmatrix} … \end{bmatrix}into display math.
Enhancements
Comprehensive LaTeX-like detector (
isLatexLike)
Expanded to cover:- Greek letters
- Calculus operators (
\partial,\nabla,\sum,\int) - Vector/matrix environments
- Common functions (
sin,cos,log,exp, etc.) - Unicode math symbols (≤, ≥, ∞, ∇, etc.)
Better guards for parentheses/brackets
- Avoids converting
(a)list markers or[link](url)syntax. - Uses local context (
contextIsMathy) to only treat(n)etc. as math in math-heavy prose.
- Avoids converting