fix: escape ambiguous Mfm marks from html
This commit is contained in:
parent
1a46d1394c
commit
a4a96f0026
1 changed files with 8 additions and 1 deletions
|
@ -19,6 +19,13 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||||
return appendChildren(childNodes, background).join("").trim();
|
return appendChildren(childNodes, background).join("").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We only exclude text containing asterisks, since the other marks can almost be considered intentionally used.
|
||||||
|
*/
|
||||||
|
function escapeAmbiguousMfmMarks(text: string) {
|
||||||
|
return text.includes("*") ? `<plain>${text}</plain>` : text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get only the text, ignoring all formatting inside
|
* Get only the text, ignoring all formatting inside
|
||||||
* @param node
|
* @param node
|
||||||
|
@ -62,7 +69,7 @@ export function fromHtml(html: string, hashtagNames?: string[]): string {
|
||||||
background = "",
|
background = "",
|
||||||
): (string | string[])[] {
|
): (string | string[])[] {
|
||||||
if (treeAdapter.isTextNode(node)) {
|
if (treeAdapter.isTextNode(node)) {
|
||||||
return [node.value];
|
return [escapeAmbiguousMfmMarks(node.value)];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip comment or document type node
|
// Skip comment or document type node
|
||||||
|
|
Loading…
Reference in a new issue