fix(markdown): don't remove char before # (#23151)

This commit is contained in:
Michael Kriese 2023-07-05 09:00:13 +02:00 committed by GitHub
parent 4b2f4abcb9
commit 9bc12da2a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ import { regEx } from './regex';
export function sanitizeMarkdown(markdown: string): string { export function sanitizeMarkdown(markdown: string): string {
let res = markdown; let res = markdown;
// Put a zero width space after every # followed by a digit // Put a zero width space after every # followed by a digit
res = res.replace(regEx(/\W#(\d)/gi), '#​$1'); res = res.replace(regEx(/(\W)#(\d)/gi), '$1#​$2');
// Put a zero width space after every @ symbol to prevent unintended hyperlinking // Put a zero width space after every @ symbol to prevent unintended hyperlinking
res = res.replace(regEx(/@/g), '@​'); res = res.replace(regEx(/@/g), '@​');
res = res.replace(regEx(/(`\[?@)​/g), '$1'); res = res.replace(regEx(/(`\[?@)​/g), '$1');