fix backslash inserted in links upon edit (#2246)
authorAjay Bura <32841439+ajbura@users.noreply.github.com>
Tue, 4 Mar 2025 06:32:13 +0000 (17:32 +1100)
committerGitHub <noreply@github.com>
Tue, 4 Mar 2025 06:32:13 +0000 (17:32 +1100)
* fix backslash appear in url with inline markdown sequences

* fix markdown chars not escaping on edit

src/app/plugins/markdown/inline/rules.ts
src/app/plugins/markdown/utils.ts

index bc76f60a12a910a2ffae7f802b4fc220dfb9b1d7..77bcbd57ab13bf8ea5f6bd5a2f5323b5b79ae6ae 100644 (file)
@@ -112,6 +112,7 @@ export const LinkRule: InlineMDRule = {
 };
 
 export const INLINE_SEQUENCE_SET = '[*_~`|]';
+export const CAP_INLINE_SEQ = `${URL_NEG_LB}${INLINE_SEQUENCE_SET}`;
 const ESC_SEQ_1 = `\\\\(${INLINE_SEQUENCE_SET})`;
 const ESC_REG_1 = new RegExp(`${URL_NEG_LB}${ESC_SEQ_1}`);
 export const EscapeRule: InlineMDRule = {
index 5ebd958cba656d0922b20c53490b79f3d91a675b..0038df135ce9cabdc4f79d0a5d509b8ea11429cf 100644 (file)
@@ -1,6 +1,6 @@
 import { findAndReplace } from '../../utils/findAndReplace';
 import { ESC_BLOCK_SEQ, UN_ESC_BLOCK_SEQ } from './block/rules';
-import { EscapeRule, INLINE_SEQUENCE_SET } from './inline/rules';
+import { EscapeRule, CAP_INLINE_SEQ } from './inline/rules';
 import { runInlineRule } from './inline/runner';
 import { replaceMatch } from './internal';
 
@@ -27,7 +27,7 @@ export const unescapeMarkdownInlineSequences = (text: string): string =>
  * @returns The plain-text with markdown escape sequences added (e.g., `"some \*italic\*"`)
  */
 export const escapeMarkdownInlineSequences = (text: string): string => {
-  const regex = new RegExp(`(${INLINE_SEQUENCE_SET})`, 'g');
+  const regex = new RegExp(`(${CAP_INLINE_SEQ})`, 'g');
   const parts = findAndReplace(
     text,
     regex,