Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: do not use look behind regex (#7809)

Ammar Ahmed2078ef90813e
diff --git a/packages/editor/src/extensions/clipboard/clipboard-text-parser.ts b/packages/editor/src/extensions/clipboard/clipboard-text-parser.ts
index 041f421be..f0dd1c5af 100644
--- a/packages/editor/src/extensions/clipboard/clipboard-text-parser.ts
+++ b/packages/editor/src/extensions/clipboard/clipboard-text-parser.ts
@@ -108,10 +108,10 @@ const MARKDOWN_PATTERNS: MarkdownPattern[] = [
{ pattern: /\[:(.+?)\]/, score: 2, type: "footnote" },
// Weak indicators
- { pattern: /(?<!\*)\*\*[^*\n]+\*\*(?!\*)/m, score: 1, type: "bold" },
- { pattern: /(?<!\*)\*[^*\n]+\*(?!\*)/m, score: 1, type: "italic" },
- { pattern: /(?<!_)__[^_\n]+__(?!_)/m, score: 1, type: "boldUnderscore" },
- { pattern: /(?<!_)_[^_\n]+_(?!_)/m, score: 1, type: "italicUnderscore" },
+ { pattern: /(^|[^*])\*\*([^*\n]+)\*\*(?!\*)/m, score: 1, type: "bold" },
+ { pattern: /(^|[^*])\*([^*\n]+)\*(?!\*)/m, score: 1, type: "italic" },
+ { pattern: /(^|[^_])__([^_\n]+)__(?!_)/m, score: 1, type: "boldUnderscore" },
+ { pattern: /(^|[^_])_([^_\n]+)_(?!_)/m, score: 1, type: "italicUnderscore" },
{ pattern: /`[^`\n]+`/m, score: 1, type: "inlineCode" },
{ pattern: /~~[^~\n]+~~/m, score: 1, type: "strikethrough" },