From a304d555ba15de2819c4ccf63f5ee5ae5ad45b47 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Sun, 31 Dec 2023 03:41:24 +0900 Subject: [PATCH] [fix] use two tildes --- src/ts/parser.ts | 24 +++++++++++++++++------- src/ts/process/index.ts | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ts/parser.ts b/src/ts/parser.ts index 027e319e..2f2f4cf0 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -22,12 +22,22 @@ const mconverted = new Marked({ } }) -const safeConvertor = new showdown.Converter({ - simpleLineBreaks: true, - strikethrough: true, - tables: true, - backslashEscapesHTMLTags: true -}) +mconverted.use({ + tokenizer: { + del(src) { + const cap = /^~~+(?=\S)([\s\S]*?\S)~~+/.exec(src); + if (cap) { + return { + type: 'del', + raw: cap[0], + text: cap[2], + tokens: [] + }; + } + return false; + } + } +}); @@ -176,7 +186,7 @@ export async function ParseMarkdown(data:string, charArg:(character|simpleCharac } export function parseMarkdownSafe(data:string) { - return DOMPurify.sanitize(safeConvertor.makeHtml(data), { + return DOMPurify.sanitize(mconverted.parse(data), { FORBID_TAGS: ["a", "style"], FORBID_ATTR: ["style", "href", "class"] }) diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 1817e452..2d85f7ab 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -265,7 +265,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n if(db.chainOfThought){ unformated.postEverything.push({ role: 'system', - content: `before respond everything, Think step by step as a ai assistant how would you respond inside xml tag.` + content: ` - before respond everything, Think step by step as a ai assistant how would you respond inside xml tag. this must be less than 5 paragraphs.` }) }