Skip to content
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 backslash appear in url with inline markdown sequences #2246

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/plugins/markdown/inline/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/app/plugins/markdown/utils.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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,
Expand Down