mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 08:38:37 +00:00
chore: disable list behaviour if line starts with plus
This commit is contained in:
2
external/lang
vendored
2
external/lang
vendored
Submodule external/lang updated: 7caef69bad...bb3470b838
@@ -199,6 +199,11 @@ const RE_HTML_TAGS = /^(<\/?[a-zA-Z0-9]+>)(.*$)/gm;
|
|||||||
*/
|
*/
|
||||||
const RE_EMPTY_LINE = /^\s*?$/gm;
|
const RE_EMPTY_LINE = /^\s*?$/gm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regex for matching line starting with plus
|
||||||
|
*/
|
||||||
|
const RE_PLUS = /^\s*\+(?:$|[^+])/gm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sanitise Markdown input before rendering
|
* Sanitise Markdown input before rendering
|
||||||
* @param content Input string
|
* @param content Input string
|
||||||
@@ -215,6 +220,11 @@ function sanitise(content: string) {
|
|||||||
// 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}`)
|
||||||
|
|
||||||
|
// Append empty character if line starts with a plus
|
||||||
|
// which would usually open a new list but we want
|
||||||
|
// to avoid that behaviour in our case.
|
||||||
|
.replace(RE_PLUS, (match) => `\u200E${match}`)
|
||||||
|
|
||||||
// Replace empty lines with non-breaking space
|
// Replace empty lines with non-breaking space
|
||||||
// because remark renderer is collapsing empty
|
// because remark renderer is collapsing empty
|
||||||
// or otherwise whitespace-only lines of text
|
// or otherwise whitespace-only lines of text
|
||||||
|
|||||||
Reference in New Issue
Block a user