Conversation
…inline math Use negative lookahead to exclude $ $ pattern, avoiding creation of empty math nodes with italic placeholder styling. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts the inline math markdown shortcut regex to avoid treating Class diagram for MathPlugin inline math shortcut regex updateclassDiagram
class MathPlugin {
+kernel
+constructor(kernel)
+init()
}
class IMarkdownShortCutService {
<<interface>>
+registerMarkdownShortCut(shortcut)
}
class MarkdownShortCut {
+regExp
+replace(textNode, match)
}
class MathInlineNodeFactory {
+$createMathInlineNode(code)
}
MathPlugin --> IMarkdownShortCutService : requires
MathPlugin --> MarkdownShortCut : registers
MarkdownShortCut --> MathInlineNodeFactory : uses
class InlineMathRegExp {
+pattern "/\\$([^\\s$](?:[^$]*[^\\s$])?)\\$\\s?$/"
}
MarkdownShortCut --> InlineMathRegExp : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
👍 @Innei |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The implemented regex doesn’t match the described approach in the PR (negative lookahead for
$\s*$); consider either switching to the negative lookahead version or updating the description so future readers aren’t confused about the intent. - The new pattern forbids leading/trailing spaces inside inline math (e.g.
$ x$,$x $), not just the$ $/$ $cases mentioned; double-check this stricter behavior is desired or relax the regex to only exclude fully-blank math content.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The implemented regex doesn’t match the described approach in the PR (negative lookahead for `$\s*$`); consider either switching to the negative lookahead version or updating the description so future readers aren’t confused about the intent.
- The new pattern forbids leading/trailing spaces inside inline math (e.g. `$ x$`, `$x $`), not just the `$ $` / `$ $` cases mentioned; double-check this stricter behavior is desired or relax the regex to only exclude fully-blank math content.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
commit: |
…corresponding tests Introduced `isLikelyMathContent` function to heuristically determine if a string resembles a math formula. Added unit tests to validate its functionality, covering various math and non-math inputs. Updated the math plugin to utilize this function for better inline math detection. Signed-off-by: Innei <tukon479@gmail.com>
|
❤️ Great PR @Innei ❤️ |
### [Version 4.0.2](v4.0.1...v4.0.2) <sup>Released on **2026-03-09**</sup> #### 🐛 Bug Fixes - **math**: Prevent dollar-space-dollar from being misidentified as inline math. <br/> <details> <summary><kbd>Improvements and Fixes</kbd></summary> #### What's fixed * **math**: Prevent dollar-space-dollar from being misidentified as inline math, closes [#125](#125) ([e742978](e742978)) </details> <div align="right"> [](#readme-top) </div>
|
🎉 This PR is included in version 4.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Fixes the issue where typing
$ $(dollar, space, dollar) incorrectly triggered inline math, creating an empty math node with italic placeholder styling.Changes
(?!\s*$)in the inline math regex to exclude the dollar-space-dollar pattern$ $and$ $no longer match$x$,$E=mc^2$still work correctlyMade with Cursor
Summary by Sourcery
Bug Fixes:
$ $and similar empty dollar-delimited sequences from being parsed as inline math placeholders.