mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 08:30:58 -05:00
parent
e9977b2a76
commit
c2a729a5e0
1 changed files with 10 additions and 0 deletions
|
@ -184,6 +184,11 @@ const Container = styled.div<{ largeEmoji: boolean }>`
|
||||||
*/
|
*/
|
||||||
const RE_QUOTE = /(^(?:>\s){5})[>\s]+(.*$)/gm;
|
const RE_QUOTE = /(^(?:>\s){5})[>\s]+(.*$)/gm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regex for matching HTML tags
|
||||||
|
*/
|
||||||
|
const RE_HTML_TAGS = /^(<\/?[a-zA-Z0-9]+>)(.*$)/gm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitise Markdown input before rendering
|
* Sanitise Markdown input before rendering
|
||||||
* @param content Input string
|
* @param content Input string
|
||||||
|
@ -194,6 +199,11 @@ function sanitise(content: string) {
|
||||||
content
|
content
|
||||||
// Strip excessive blockquote indentation
|
// Strip excessive blockquote indentation
|
||||||
.replace(RE_QUOTE, (_, m0, m1) => m0 + m1)
|
.replace(RE_QUOTE, (_, m0, m1) => m0 + m1)
|
||||||
|
|
||||||
|
// Append empty character if string starts with html tag
|
||||||
|
// This is to avoid inconsistencies in rendering Markdown inside/after HTML tags
|
||||||
|
// https://github.com/revoltchat/revite/issues/733
|
||||||
|
.replace(RE_HTML_TAGS, (match) => `\u200E${match}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue