feat: add inline KaTeX math support#167
Conversation
📝 WalkthroughWalkthroughThis PR adds inline LaTeX math support ( ChangesInline math feature
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/plainText.ts (1)
550-567: 💤 Low valueConsider clarifying comment specificity.
The comment on line 550 mentions "but only if not starting with a digit (to avoid stripping prices like $19.99)", but this guard only applies to inline math (
$...$), not block math ($$...$$). While the implementation is correct, the comment could be more precise to avoid confusion.Optional comment improvement
- // Remove block math ($$...$$) and inline math ($...$), but only if not starting with a digit (to avoid stripping prices like $19.99) + // Remove block math ($$...$$) unconditionally and inline math ($...$) only if not starting with a digit (to avoid stripping prices like $19.99)Implementation note: The Rust implementation achieves the same result as the TypeScript version using a slightly different approach (callback-based digit check vs. negative lookahead), which is appropriate for the Rust regex crate's API.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/plainText.ts` around lines 550 - 567, Update the imprecise comment that reads "but only if not starting with a digit (to avoid stripping prices like $19.99)" to explicitly state that this digit-check guard applies only to inline math delimiters ($...$) and not to block math ($$...$$); locate the comment in src/lib/plainText.ts near the inline-math regex/handling logic and reword it to clarify the scope (inline vs block math) so readers understand the guard's applicability without changing the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib/plainText.ts`:
- Around line 550-567: Update the imprecise comment that reads "but only if not
starting with a digit (to avoid stripping prices like $19.99)" to explicitly
state that this digit-check guard applies only to inline math delimiters ($...$)
and not to block math ($$...$$); locate the comment in src/lib/plainText.ts near
the inline-math regex/handling logic and reword it to clarify the scope (inline
vs block math) so readers understand the guard's applicability without changing
the implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b2fad5ca-9aba-404a-99a8-f9051c23a2e9
📒 Files selected for processing (7)
src-tauri/src/lib.rssrc/App.csssrc/components/editor/Editor.tsxsrc/components/editor/MathExtensions.tssrc/components/editor/SlashCommand.tsxsrc/lib/plainText.tssrc/lib/shortcuts.ts
Summary
This PR adds inline KaTeX support to the editor so expressions written as
$...$are converted into inline math, alongside the existing block math syntax.What changed
$Demo
Enregistrement.de.l.ecran.2026-06-05.a.13.01.07.mov
How to test
$a+b$and verify it converts into inline math when the closing$is typed$a+b$followed by space and enter$$a+b$$still works$19.99is not convertedSummary by CodeRabbit
Release Notes
New Features
Improvements