Fix inline code formatting for text enclosed in backticks #4468
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.