mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-03-12 14:10:01 +01:00
fix backslash inserted in links upon edit (#2246)
* fix backslash appear in url with inline markdown sequences * fix markdown chars not escaping on edit
This commit is contained in:
parent
1206ffced2
commit
0c5ff65639
2 changed files with 3 additions and 2 deletions
|
@ -112,6 +112,7 @@ export const LinkRule: InlineMDRule = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const INLINE_SEQUENCE_SET = '[*_~`|]';
|
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_SEQ_1 = `\\\\(${INLINE_SEQUENCE_SET})`;
|
||||||
const ESC_REG_1 = new RegExp(`${URL_NEG_LB}${ESC_SEQ_1}`);
|
const ESC_REG_1 = new RegExp(`${URL_NEG_LB}${ESC_SEQ_1}`);
|
||||||
export const EscapeRule: InlineMDRule = {
|
export const EscapeRule: InlineMDRule = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { findAndReplace } from '../../utils/findAndReplace';
|
import { findAndReplace } from '../../utils/findAndReplace';
|
||||||
import { ESC_BLOCK_SEQ, UN_ESC_BLOCK_SEQ } from './block/rules';
|
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 { runInlineRule } from './inline/runner';
|
||||||
import { replaceMatch } from './internal';
|
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\*"`)
|
* @returns The plain-text with markdown escape sequences added (e.g., `"some \*italic\*"`)
|
||||||
*/
|
*/
|
||||||
export const escapeMarkdownInlineSequences = (text: string): string => {
|
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(
|
const parts = findAndReplace(
|
||||||
text,
|
text,
|
||||||
regex,
|
regex,
|
||||||
|
|
Loading…
Reference in a new issue