mirror of
https://github.com/cinnyapp/cinny.git
synced 2024-11-20 06:49:52 +01:00
Fix broken emoji with md pattern in shortcode (#1514)
* fix broken emoji with md pattern in shortcode * fix html regex when generating editor output
This commit is contained in:
parent
3cef074c9e
commit
a2cbe79787
1 changed files with 10 additions and 6 deletions
|
@ -51,21 +51,25 @@ const elementToCustomHtml = (node: CustomElement, children: string): string => {
|
|||
return `<ul>${children}</ul>`;
|
||||
|
||||
case BlockType.Mention:
|
||||
return `<a href="https://matrix.to/#/${node.id}">${node.name}</a>`;
|
||||
return `<a href="https://matrix.to/#/${encodeURIComponent(node.id)}">${sanitizeText(
|
||||
node.name
|
||||
)}</a>`;
|
||||
case BlockType.Emoticon:
|
||||
return node.key.startsWith('mxc://')
|
||||
? `<img data-mx-emoticon src="${node.key}" alt="${node.shortcode}" title="${node.shortcode}" height="32">`
|
||||
: node.key;
|
||||
? `<img data-mx-emoticon src="${node.key}" alt="${sanitizeText(
|
||||
node.shortcode
|
||||
)}" title="${sanitizeText(node.shortcode)}" height="32" />`
|
||||
: sanitizeText(node.key);
|
||||
case BlockType.Link:
|
||||
return `<a href="${node.href}">${node.children}</a>`;
|
||||
return `<a href="${encodeURIComponent(node.href)}">${node.children}</a>`;
|
||||
case BlockType.Command:
|
||||
return `/${node.command}`;
|
||||
return `/${sanitizeText(node.command)}`;
|
||||
default:
|
||||
return children;
|
||||
}
|
||||
};
|
||||
|
||||
const HTML_TAG_REG = /<([a-z]+)(?![^>]*\/>)[^<]*<\/\1>/;
|
||||
const HTML_TAG_REG = /<([\w-]+)(?:[^/>]*)(?:(?:\/>)|(?:>.*?<\/\1>))/;
|
||||
const ignoreHTMLParseInlineMD = (text: string): string => {
|
||||
if (text === '') return text;
|
||||
const match = text.match(HTML_TAG_REG);
|
||||
|
|
Loading…
Reference in a new issue