mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 16:40:58 -05:00
fix: don't collapse whitespace / newlines
This commit is contained in:
parent
a234e3a582
commit
07fd598bf9
1 changed files with 10 additions and 0 deletions
|
@ -189,6 +189,11 @@ const RE_QUOTE = /(^(?:>\s){5})[>\s]+(.*$)/gm;
|
||||||
*/
|
*/
|
||||||
const RE_HTML_TAGS = /^(<\/?[a-zA-Z0-9]+>)(.*$)/gm;
|
const RE_HTML_TAGS = /^(<\/?[a-zA-Z0-9]+>)(.*$)/gm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regex for matching empty lines
|
||||||
|
*/
|
||||||
|
const RE_EMPTY_LINE = /^\s*?$/gm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitise Markdown input before rendering
|
* Sanitise Markdown input before rendering
|
||||||
* @param content Input string
|
* @param content Input string
|
||||||
|
@ -204,6 +209,11 @@ function sanitise(content: string) {
|
||||||
// This is to avoid inconsistencies in rendering Markdown inside/after HTML tags
|
// This is to avoid inconsistencies in rendering Markdown inside/after HTML tags
|
||||||
// https://github.com/revoltchat/revite/issues/733
|
// https://github.com/revoltchat/revite/issues/733
|
||||||
.replace(RE_HTML_TAGS, (match) => `\u200E${match}`)
|
.replace(RE_HTML_TAGS, (match) => `\u200E${match}`)
|
||||||
|
|
||||||
|
// Replace empty lines with non-breaking space
|
||||||
|
// because remark renderer is collapsing empty
|
||||||
|
// or otherwise whitespace-only lines of text
|
||||||
|
.replace(RE_EMPTY_LINE, "")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue