diff --git a/.changeset/famous-bags-breathe.md b/.changeset/famous-bags-breathe.md new file mode 100644 index 00000000000..597fac7755b --- /dev/null +++ b/.changeset/famous-bags-breathe.md @@ -0,0 +1,5 @@ +--- +"@tiptap/extension-code": patch +--- + +Update inline code formatting for text enclosed in backticks diff --git a/packages/extension-code/src/code.ts b/packages/extension-code/src/code.ts index 068804b512e..642765ba380 100644 --- a/packages/extension-code/src/code.ts +++ b/packages/extension-code/src/code.ts @@ -34,14 +34,20 @@ declare module '@tiptap/core' { } /** - * Matches inline code. + * Regular expressions to match inline code blocks enclosed in backticks. + * It matches: + * - An opening backtick, followed by + * - Any text that doesn't include a backtick (captured for marking), followed by + * - A closing backtick. + * This ensures that any text between backticks is formatted as code, + * regardless of the surrounding characters (exception being another backtick). */ -export const inputRegex = /(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/ +export const inputRegex = /(?