mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-01-29 01:28:29 +00:00
improve code logic
This commit is contained in:
parent
bc5a9f5c0a
commit
bcb8d6aea0
|
@ -11,12 +11,14 @@ export type OutputOptions = {
|
|||
|
||||
const textToCustomHtml = (node: FormattedText, opts: OutputOptions): string => {
|
||||
let string = sanitizeText(node.text);
|
||||
if (opts.allowTextFormatting && node.bold) string = `<strong>${string}</strong>`;
|
||||
if (opts.allowTextFormatting && node.italic) string = `<i>${string}</i>`;
|
||||
if (opts.allowTextFormatting && node.underline) string = `<u>${string}</u>`;
|
||||
if (opts.allowTextFormatting && node.strikeThrough) string = `<s>${string}</s>`;
|
||||
if (opts.allowTextFormatting && node.code) string = `<code>${string}</code>`;
|
||||
if (opts.allowTextFormatting && node.spoiler) string = `<span data-mx-spoiler>${string}</span>`;
|
||||
if (opts.allowTextFormatting) {
|
||||
if (node.bold) string = `<strong>${string}</strong>`;
|
||||
if (node.italic) string = `<i>${string}</i>`;
|
||||
if (node.underline) string = `<u>${string}</u>`;
|
||||
if (node.strikeThrough) string = `<s>${string}</s>`;
|
||||
if (node.code) string = `<code>${string}</code>`;
|
||||
if (node.spoiler) string = `<span data-mx-spoiler>${string}</span>`;
|
||||
}
|
||||
|
||||
if (opts.allowMarkdown && string === sanitizeText(node.text)) {
|
||||
string = parseInlineMD(string);
|
||||
|
|
Loading…
Reference in a new issue