-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix inline code formatting for text enclosed in backticks #4468
Fix inline code formatting for text enclosed in backticks #4468
Conversation
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
bcaef5c
to
7e7ae19
Compare
🦋 Changeset detectedLatest commit: 66c8f9b The changes in this PR will be included in the next version bump. This PR includes changesets to release 54 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @marwan37, sorry for the long wait!
This change introduced the following issue: I spent some time trying to tweak the RegExp to keep this fix and avoid the bug that introduced, but I have a feeling that tweaking the RegExp will not be enough, I think the @marwan37 Think you can have a look since you were the original author of this change? (cc @nperez0111 for awareness; not sure if a fix for this is that straightforward, but if it's not, maybe a revert could be in order?) |
@rfgamaral what version are you using, because we've changed the regex since this was closed to remove the backtracking in: #5916 |
I tried with both the version that introduced this PR, and the latest, the issue exists on both. That PR changed the implementation of the regex to not include lookbehind assertions (unsupported by Safari below 16.4), but it kept the RegExp change that introduces the new behaviour described in this PR (which also introduces the bug I just described). You can replicate the bug I described in the default text editor example (which I'm assuming is always using the latest production version). |
Please describe your changes
In the current implementation of the @tiptap/extension-code, the regex pattern does not correctly format text enclosed in backticks when they are immediately preceded or followed by any character other than whitespace.
How did you accomplish your changes
Updated the
inputRegex
andpasteRegex
patterns to the following:The regex uses negative lookbehind and lookahead assertions to ensure that only single backticks are considered for formatting to avoid conflicts with potential code block syntax or other uses of multiple backticks.
How have you tested your changes
Tested in various scenarios to ensure that it correctly formats text as inline code blocks, and that it doesn't conflict with other extensions.
How can we verify your changes
npm run start
and navigate to any playgroundRemarks
This change enhances the flexibility of the inline code formatting.
Checklist
Related issues
#4467
Issue #338 in BlockNote - Original issue where the bug was identified and discussed.